check ffmpeg

This commit is contained in:
Ghost 2024-01-24 18:52:11 +01:00
parent ae34aee2e8
commit 3846220a6e
8 changed files with 95 additions and 15 deletions

View File

@ -3,7 +3,7 @@
# Class import
from Src.Util.Helper.headers import get_headers
from Src.Util.Helper.console import console
from Src.Util.m3u8 import dw_m3u8
from Src.Util.FFmpeg.m3u8 import dw_m3u8
# General import
import requests, os, re, json, sys
@ -52,7 +52,7 @@ def get_m3u8_url(json_win_video, json_win_param, render_quality):
def get_m3u8_key(json_win_video, json_win_param, title_name, token_render):
req = requests.get('https://vixcloud.co/storage/enc.key', headers={
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={title_name.replace(" ", "+")}&referer=1&expires={json_win_param["expires"]}',
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={title_name}&referer=1&expires={json_win_param["expires"]}',
})
if req.ok:
@ -63,7 +63,7 @@ def get_m3u8_key(json_win_video, json_win_param, title_name, token_render):
def get_m3u8_audio(json_win_video, json_win_param, title_name, token_render):
req = requests.get(f'https://vixcloud.co/playlist/{json_win_video["id"]}', params={'token': json_win_param['token'], 'expires': json_win_param["expires"] }, headers={
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={title_name.replace(" ", "+")}&referer=1&expires={json_win_param["expires"]}'
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={title_name}&referer=1&expires={json_win_param["expires"]}'
})
if req.ok:

View File

@ -3,7 +3,7 @@
# Class import
from Src.Util.Helper.headers import get_headers
from Src.Util.Helper.console import console, msg
from Src.Util.m3u8 import dw_m3u8
from Src.Util.FFmpeg.m3u8 import dw_m3u8
# General import
import requests, os, re, json, sys
@ -84,7 +84,7 @@ def get_m3u8_url(json_win_video, json_win_param, render_quality):
def get_m3u8_key_ep(json_win_video, json_win_param, tv_name, n_stagione, n_ep, ep_title, token_render):
req = requests.get('https://vixcloud.co/storage/enc.key', headers={
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={tv_name.replace("-", "+")}&referer=1&expires={json_win_param["expires"]}&description=S{n_stagione}%3AE{n_ep}+{ep_title.replace(" ", "+")}&nextEpisode=1',
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={tv_name}&referer=1&expires={json_win_param["expires"]}&description=S{n_stagione}%3AE{n_ep}+{ep_title}&nextEpisode=1',
})
if req.ok:
@ -95,7 +95,7 @@ def get_m3u8_key_ep(json_win_video, json_win_param, tv_name, n_stagione, n_ep, e
def get_m3u8_audio(json_win_video, json_win_param, tv_name, n_stagione, n_ep, ep_title, token_render):
req = requests.get(f'https://vixcloud.co/playlist/{json_win_video["id"]}', params={'token': json_win_param['token'], 'expires': json_win_param["expires"] }, headers={
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={tv_name.replace("-", "+")}&referer=1&expires={json_win_param["expires"]}&description=S{n_stagione}%3AE{n_ep}+{ep_title.replace(" ", "+")}&nextEpisode=1'
'referer': f'https://vixcloud.co/embed/{json_win_video["id"]}?token={json_win_param[token_render]}&title={tv_name}&referer=1&expires={json_win_param["expires"]}&description=S{n_stagione}%3AE{n_ep}+{ep_title}&nextEpisode=1'
})
if req.ok:

View File

@ -1,7 +1,9 @@
# 13.09.2023
# General import
# Class import
from Src.Util.Helper.console import console
# General import
import os, requests, time
# Variable
@ -20,14 +22,23 @@ def main_update():
json = requests.get(f"https://api.github.com/repos/{repo_user}/{repo_name}/releases").json()[0]
stargazers_count = requests.get(f"https://api.github.com/repos/{repo_user}/{repo_name}").json()['stargazers_count']
last_version = json['name']
down_count = json['assets'][0]['download_count']
if down_count > 0 and stargazers_count > 0: percentual_stars = round(stargazers_count / down_count * 100, 2)
else: percentual_stars = 0
if down_count > 0 and stargazers_count > 0:
percentual_stars = round(stargazers_count / down_count * 100, 2)
else:
percentual_stars = 0
if get_install_version() != last_version:
console.print(f"[red]=> A new version is available: [green]{json['zipball_url']}")
console.print(f"[red]=> Versione: [yellow]{json['name']}")
else:
console.print(f"[red]=> Everything up to date")
console.print(f"[red]=> Last version: [yellow]{json['name']}")
if get_install_version() != last_version: console.print(f"[red]=> A new version is available")
else: console.print("[red]=> Everything up to date")
print("\n")
console.print(f"[red]{repo_name} was downloaded [yellow]{down_count} [red]times, but only [yellow]{percentual_stars}% [red]of You(!!) have starred it. \n\

View File

@ -0,0 +1,48 @@
# 24.01.2023
# Class import
from Src.Util.Helper.console import console
# Import
import subprocess, os, requests, zipfile, sys
def download_ffmpeg():
# Specify the URL for the FFmpeg binary zip file for Windows
ffmpeg_url = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z"
# Name of the directory where FFmpeg will be extracted
ffmpeg_dir = "ffmpeg"
console.print("[yellow]Downloading FFmpeg...[/yellow]")
# Download the FFmpeg zip file
response = requests.get(ffmpeg_url)
os.makedirs(ffmpeg_dir, exist_ok=True)
# Save the zip file
zip_file_path = os.path.join(ffmpeg_dir, "ffmpeg.zip")
with open(zip_file_path, "wb") as zip_file:
zip_file.write(response.content)
with zipfile.ZipFile(zip_file_path, "r") as zip_ref:
zip_ref.extractall(ffmpeg_dir)
# Add the FFmpeg directory to the system PATH
ffmpeg_bin_dir = os.path.join(os.getcwd(), ffmpeg_dir, "bin")
os.environ["PATH"] += os.pathsep + ffmpeg_bin_dir
os.remove(zip_file_path)
def check_ffmpeg():
try:
subprocess.run(["ffmpeg", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
console.print("[blue]FFmpeg [white]=> [red]Add to system path")
except subprocess.CalledProcessError:
console.print("[cyan]FFmpeg is not in the PATH. Downloading and adding to the PATH...[/cyan]")
try:
download_ffmpeg()
sys.exit(0) # Exit
except:
console.print("[red]Unable to download or add FFmpeg to the PATH.[/red]")
sys.exit(0) # Exit

View File

@ -11,7 +11,7 @@ from cryptography.hazmat.backends import default_backend
# Class import
from Src.Util.Helper.console import console
from Src.Util.Helper.headers import get_headers
from Src.Util.Helper.util import there_is_audio, merge_ts_files
from Src.Util.FFmpeg.util import there_is_audio, merge_ts_files
# Disable warning

13
Src/Util/Helper/os.py Normal file
View File

@ -0,0 +1,13 @@
# 24.01.24
# Import
import shutil, os
def remove_folder(folder_path):
if os.path.exists(folder_path):
try:
shutil.rmtree(folder_path)
except OSError as e:
print(f"Error removing folder '{folder_path}': {e}")
else:
print(f"Folder '{folder_path}' does not exist.")

14
run.py
View File

@ -7,6 +7,8 @@ from Src.Api.tv import main_dw_tv as download_tv
from Src.Util.Helper.message import msg_start
from Src.Util.Helper.console import console, msg
from Src.Upload.update import main_update
from Src.Util.FFmpeg.installer import check_ffmpeg
from Src.Util.Helper.os import remove_folder
# General import
import sys
@ -16,11 +18,17 @@ domain, site_version = Page.domain_version()
def main():
remove_folder("tmp")
msg_start()
try: main_update()
except: console.print("[blue]Req github [white]=> [red]Failed")
console.print(f"[blue]Find system [white]=> [red]{sys.platform} \n")
try:
main_update()
except:
console.print("[blue]Req github [white]=> [red]Failed")
console.print(f"[blue]Find system [white]=> [red]{sys.platform}")
check_ffmpeg()
print("\n")
film_search = msg.ask("\n[blue]Insert word to search in all site: ").strip()
db_title = Page.search(film_search, domain)