From 7992532ce931c11916f9c060781d87f1e7d05957 Mon Sep 17 00:00:00 2001 From: Ghost <62809003+Ghost6446@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:33:40 +0100 Subject: [PATCH] fix error 409 --- Src/Api/film.py | 8 +++++++- Src/Api/page.py | 9 +++++++-- Src/Util/FFmpeg/util.py | 7 ++++++- requirements.txt | 1 - 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Src/Api/film.py b/Src/Api/film.py index 417c913..3644e19 100644 --- a/Src/Api/film.py +++ b/Src/Api/film.py @@ -18,7 +18,13 @@ def get_iframe(id_title, domain): if req.ok: url_embed = BeautifulSoup(req.text, "lxml").find("iframe").get("src") req_embed = requests.get(url_embed, headers = {"User-agent": get_headers()}).text - return BeautifulSoup(req_embed, "lxml").find("body").find("script").text + + try: + return BeautifulSoup(req_embed, "lxml").find("body").find("script").text + except: + console.log("[red]Cant play this video, (video not available)") + sys.exit(0) + else: console.log(f"[red]Error: {req.status_code}") sys.exit(0) diff --git a/Src/Api/page.py b/Src/Api/page.py index e302a56..02b0701 100644 --- a/Src/Api/page.py +++ b/Src/Api/page.py @@ -5,14 +5,19 @@ from Src.Util.Helper.headers import get_headers from Src.Util.Helper.console import console # General import -import requests, sys +import requests, sys, json +from bs4 import BeautifulSoup def domain_version(): req_repo = requests.get("https://raw.githubusercontent.com/Ghost6446/Streaming_comunity_data/main/data.json", headers={'user-agent': get_headers()}) if req_repo.ok: - return req_repo.json()['domain'], req_repo.json()['version'] + site_req = requests.get(f"https://streamingcommunity.{req_repo.json()['domain']}/").text + soup = BeautifulSoup(site_req, "lxml") + version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version'] + + return version, req_repo.json()['version'] else: console.log(f"[red]Error: {req_repo.status_code}") diff --git a/Src/Util/FFmpeg/util.py b/Src/Util/FFmpeg/util.py index b65ff40..f8f4a7d 100644 --- a/Src/Util/FFmpeg/util.py +++ b/Src/Util/FFmpeg/util.py @@ -15,7 +15,12 @@ def merge_ts_files(video_path, audio_path, output_path): input_audio = ffmpeg.input(audio_path) logging.debug(f"Merge video ts: {input_video}, with audio ts: {input_audio}, to: {output_path}") - ffmpeg_command = ffmpeg.output(input_video, input_audio, output_path, format='mpegts', acodec='copy', vcodec='copy', loglevel='quiet').compile() + ffmpeg_command = ffmpeg.output(input_video, input_audio, output_path, + format='mpegts', + acodec='copy', + vcodec='copy', + loglevel='quiet', + ).compile() try: subprocess.run(ffmpeg_command, check=True, stderr=subprocess.PIPE) diff --git a/requirements.txt b/requirements.txt index e9d6a44..99c4b3d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,3 @@ rich random-user-agent ffmpeg-python cryptography==3.4.8 # Problem with new version -moviepy