Skip to content

Commit 6523121

Browse files
Arrowarcarellice
andauthored
Bumv v3.4.0
* Improve M3U8_CONVERSION * Swtich to client * Ruff fix * Fix memory * 2 * PR 3.4.0 (ADDED year in movie filename) (#414) * Improve M3U8_CONVERSION * Improve M3U8_CONVERSION * ADDED year in film filename * Update domains.json * Update domains.json * Fix missing newline in domains.json Add missing newline at the end of domains.json * Add http_client for hls downloader * Fix download_subtitle * fix ruff * Remove ms * Add default value --------- Co-authored-by: carellice <[email protected]>
1 parent 7ab2102 commit 6523121

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+361
-649
lines changed

GUI/config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"specific_list_audio": [
3333
"ita"
3434
],
35-
"download_subtitle": true,
3635
"merge_subs": true,
3736
"specific_list_subtitles": [
3837
"ita",

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ mpd_url = "https://example.com/stream.mpd"
146146
license_url = "https://example.com/get_license"
147147

148148
dash_process = DASH_Downloader(
149-
cdm_device=get_wvd_path(),
150149
license_url=license_url,
151150
mpd_url=mpd_url,
152151
output_path="output.mp4",
@@ -231,7 +230,6 @@ To enable qBittorrent integration, follow the setup guide [here](https://github.
231230
"specific_list_audio": [
232231
"ita"
233232
],
234-
"download_subtitle": true,
235233
"merge_subs": true,
236234
"specific_list_subtitles": [
237235
"ita", // Specify language codes or use ["*"] to download all available subtitles

StreamingCommunity/Api/Player/hdplayer.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99
# Internal utilities
1010
from StreamingCommunity.Util.headers import get_userAgent
1111
from StreamingCommunity.Util.http_client import create_client
12-
from StreamingCommunity.Util.config_json import config_manager
1312

1413

15-
# Variable
16-
MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout")
17-
REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify')
18-
1914

2015
class VideoSource:
2116
def __init__(self):

StreamingCommunity/Api/Player/mediapolisvod.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
# 11.04.25
22

33

4-
# External libraries
5-
import httpx
6-
7-
84
# Internal utilities
9-
from StreamingCommunity.Util.config_json import config_manager
5+
from StreamingCommunity.Util.http_client import create_client
106
from StreamingCommunity.Util.headers import get_headers
117

128

13-
# Variable
14-
MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout")
15-
REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify')
16-
179
class VideoSource:
18-
1910
@staticmethod
2011
def extract_m3u8_url(video_url: str) -> str:
2112
"""Extract the m3u8 streaming URL from a RaiPlay video URL."""
@@ -29,7 +20,7 @@ def extract_m3u8_url(video_url: str) -> str:
2920
return "Error: Unable to determine video JSON URL"
3021

3122
try:
32-
response = httpx.get(video_url, headers=get_headers(), timeout=MAX_TIMEOUT, verify=REQUEST_VERIFY)
23+
response = create_client(headers=get_headers()).get(video_url)
3324
if response.status_code != 200:
3425
return f"Error: Failed to fetch video data (Status: {response.status_code})"
3526

@@ -50,8 +41,8 @@ def extract_m3u8_url(video_url: str) -> str:
5041
'cont': element_key,
5142
'output': '62',
5243
}
53-
stream_response = httpx.get('https://mediapolisvod.rai.it/relinker/relinkerServlet.htm', params=params, headers=get_headers(), timeout=MAX_TIMEOUT, verify=REQUEST_VERIFY)
54-
44+
45+
stream_response = create_client(headers=get_headers()).get('https://mediapolisvod.rai.it/relinker/relinkerServlet.htm', params=params)
5546
if stream_response.status_code != 200:
5647
return f"Error: Failed to fetch stream URL (Status: {stream_response.status_code})"
5748

StreamingCommunity/Api/Player/supervideo.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,13 @@
77
# External libraries
88
import jsbeautifier
99
from bs4 import BeautifulSoup
10-
from curl_cffi import requests
1110

1211

1312
# Internal utilities
14-
from StreamingCommunity.Util.config_json import config_manager
13+
from StreamingCommunity.Util.http_client import create_client_curl
1514
from StreamingCommunity.Util.headers import get_headers
1615

1716

18-
# Variable
19-
MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout")
20-
REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify')
21-
22-
2317
class VideoSource:
2418
def __init__(self, url: str) -> None:
2519
"""
@@ -42,10 +36,11 @@ def make_request(self, url: str) -> str:
4236
- str: The response content if successful, None otherwise.
4337
"""
4438
try:
45-
response = requests.get(url, headers=self.headers, timeout=MAX_TIMEOUT, impersonate="chrome136", verify=REQUEST_VERIFY)
39+
response = create_client_curl(headers=self.headers).get(url)
4640
if response.status_code >= 400:
4741
logging.error(f"Request failed with status code: {response.status_code}")
4842
return None
43+
4944
return response.text
5045

5146
except Exception as e:

StreamingCommunity/Api/Player/sweetpixel.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,11 @@
33
import logging
44

55

6-
# External libraries
7-
8-
96
# Internal utilities
10-
from StreamingCommunity.Util.config_json import config_manager
117
from StreamingCommunity.Util.headers import get_userAgent
128
from StreamingCommunity.Util.http_client import create_client
139

1410

15-
# Variable
16-
MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout")
17-
REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify')
18-
1911
class VideoSource:
2012
def __init__(self, site_url, episode_data, session_id, csrf_token):
2113
"""Initialize the VideoSource with session details, episode data, and URL."""
@@ -44,4 +36,4 @@ def get_playlist(self):
4436

4537
except Exception as e:
4638
logging.error(f"Error in new API system: {e}")
47-
return None
39+
return None

StreamingCommunity/Api/Player/vixcloud.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@
66

77

88
# External libraries
9-
import httpx
109
from bs4 import BeautifulSoup
1110
from rich.console import Console
1211

1312

1413
# Internal utilities
1514
from StreamingCommunity.Util.headers import get_userAgent
16-
from StreamingCommunity.Util.config_json import config_manager
15+
from StreamingCommunity.Util.http_client import create_client
1716
from .Helper.Vixcloud.util import WindowVideo, WindowParameter, StreamsCollection
1817
from .Helper.Vixcloud.js_parser import JavaScriptParser
1918

2019

2120
# Variable
22-
MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout")
23-
REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify')
2421
console = Console()
2522

2623

@@ -57,7 +54,7 @@ def get_iframe(self, episode_id: int) -> None:
5754
}
5855

5956
try:
60-
response = httpx.get(f"{self.url}/iframe/{self.media_id}", headers=self.headers, params=params, timeout=MAX_TIMEOUT, verify=REQUEST_VERIFY)
57+
response = create_client(headers=self.headers).get(f"{self.url}/iframe/{self.media_id}", params=params)
6158
response.raise_for_status()
6259

6360
# Parse response with BeautifulSoup to get iframe source
@@ -100,7 +97,7 @@ def get_content(self) -> None:
10097
"""
10198
try:
10299
if self.iframe_src is not None:
103-
response = httpx.get(self.iframe_src, headers=self.headers, timeout=MAX_TIMEOUT, verify=REQUEST_VERIFY)
100+
response = create_client(headers=self.headers).get(self.iframe_src)
104101
response.raise_for_status()
105102

106103
# Parse response with BeautifulSoup to get content
@@ -110,14 +107,6 @@ def get_content(self) -> None:
110107
# Parse script to get video information
111108
self.parse_script(script_text=script)
112109

113-
except httpx.HTTPStatusError as e:
114-
if e.response.status_code == 404:
115-
console.print("[yellow]This content will be available soon![/yellow]")
116-
return
117-
118-
logging.error(f"Error getting content: {e}")
119-
raise
120-
121110
except Exception as e:
122111
logging.error(f"Error getting content: {e}")
123112
raise
@@ -178,15 +167,15 @@ def get_embed(self, episode_id: int):
178167
str: Parsed script content
179168
"""
180169
try:
181-
response = httpx.get(f"{self.url}/embed-url/{episode_id}", headers=self.headers, timeout=MAX_TIMEOUT, verify=REQUEST_VERIFY)
170+
response = create_client(headers=self.headers).get(f"{self.url}/embed-url/{episode_id}")
182171
response.raise_for_status()
183172

184173
# Extract and clean embed URL
185174
embed_url = response.text.strip()
186175
self.iframe_src = embed_url
187176

188177
# Fetch video content using embed URL
189-
video_response = httpx.get(embed_url, verify=REQUEST_VERIFY)
178+
video_response = create_client(headers=self.headers).get(embed_url)
190179
video_response.raise_for_status()
191180

192181
# Parse response with BeautifulSoup to get content of the scriot

StreamingCommunity/Api/Site/altadefinizione/film.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from StreamingCommunity.Util.http_client import create_client
1616
from StreamingCommunity.Util.message import start_message
1717
from StreamingCommunity.Util.config_json import config_manager
18-
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance, TelegramSession
18+
from StreamingCommunity.TelegramHelp.telegram_bot import TelegramSession
1919

2020

2121
# Logic class
@@ -44,18 +44,6 @@ def download_film(select_title: MediaItem) -> str:
4444
Return:
4545
- str: output path if successful, otherwise None
4646
"""
47-
if site_constant.TELEGRAM_BOT:
48-
bot = get_bot_instance()
49-
bot.send_message(f"Download in corso:\n{select_title.name}", None)
50-
51-
# Viene usato per lo screen
52-
console.print(f"## Download: [red]{select_title.name} ##")
53-
54-
# Get script_id
55-
script_id = TelegramSession.get_session()
56-
if script_id != "unknown":
57-
TelegramSession.updateScriptId(script_id, select_title.name)
58-
5947
start_message()
6048
console.print(f"\n[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{select_title.name}[/cyan] \n")
6149

@@ -93,7 +81,7 @@ def download_film(select_title: MediaItem) -> str:
9381
master_playlist = video_source.get_playlist()
9482

9583
# Define the filename and path for the downloaded film
96-
title_name = os_manager.get_sanitize_file(select_title.name) + extension_output
84+
title_name = os_manager.get_sanitize_file(select_title.name, select_title.date) + extension_output
9785
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(extension_output, ""))
9886

9987
# Download the film using the m3u8 playlist, and output filename

StreamingCommunity/Api/Site/altadefinizione/site.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33

44
# External libraries
5-
import httpx
65
from bs4 import BeautifulSoup
76
from rich.console import Console
87

98

109
# Internal utilities
1110
from StreamingCommunity.Util.config_json import config_manager
1211
from StreamingCommunity.Util.headers import get_userAgent
12+
from StreamingCommunity.Util.http_client import create_client
1313
from StreamingCommunity.Util.table import TVShowManager
1414
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
1515

@@ -46,12 +46,7 @@ def title_search(query: str) -> int:
4646
console.print(f"[cyan]Search url: [yellow]{search_url}")
4747

4848
try:
49-
response = httpx.post(
50-
search_url,
51-
headers={'user-agent': get_userAgent()},
52-
timeout=max_timeout,
53-
follow_redirects=True
54-
)
49+
response = create_client(headers={'user-agent': get_userAgent()}).get(search_url)
5550
response.raise_for_status()
5651

5752
except Exception as e:

StreamingCommunity/Api/Site/altadefinizione/util/ScrapeSerie.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@
44

55

66
# External libraries
7-
import httpx
87
from bs4 import BeautifulSoup
98

109

1110
# Internal utilities
1211
from StreamingCommunity.Util.headers import get_userAgent
13-
from StreamingCommunity.Util.config_json import config_manager
12+
from StreamingCommunity.Util.http_client import create_client
1413
from StreamingCommunity.Api.Player.Helper.Vixcloud.util import SeasonManager
1514

1615

17-
# Variable
18-
max_timeout = config_manager.get_int("REQUESTS", "timeout")
19-
20-
2116
class GetSerieInfo:
2217
def __init__(self, url):
2318
"""
@@ -34,7 +29,7 @@ def collect_season(self) -> None:
3429
"""
3530
Retrieve all episodes for all seasons
3631
"""
37-
response = httpx.get(self.url, headers=self.headers)
32+
response = create_client(headers=self.headers).get(self.url)
3833
soup = BeautifulSoup(response.text, "html.parser")
3934
self.series_name = soup.find("title").get_text(strip=True).split(" - ")[0]
4035

0 commit comments

Comments
 (0)