Add some fix (#260)

* Add cache for tmbd

* Remove run_get_select_title

* Add generic display_episodes_list
This commit is contained in:
Dark1291 2025-02-11 15:10:07 +01:00 committed by GitHub
parent b482d944f1
commit 8fe6f64fed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 158 additions and 299 deletions

View File

@ -567,9 +567,9 @@ python3 telegram_bot.py
| [AltadefinizioneGratis](https://altadefinizionegratis.pro/) | ✅ | -ALT |
| [AnimeUnity](https://animeunity.so/) | ✅ | -ANI |
| [Ilcorsaronero](https://ilcorsaronero.link/) | ✅ | `-ILC` |
| [CB01New](https://cb01new.media/) | ✅ | -CB0 |
| [CB01New](https://cb01new.gold/) | ✅ | -CB0 |
| [DDLStreamItaly](https://ddlstreamitaly.co/) | ✅ | -DDL |
| [GuardaSerie](https://guardaserie.meme/) | ✅ | -GUA |
| [GuardaSerie](https://guardaserie.now/) | ✅ | -GUA |
| [MostraGuarda](https://mostraguarda.stream/) | ✅ | -MOS |
| [StreamingCommunity](https://streamingcommunity.paris/) | ✅ | -STR |

View File

@ -1,16 +1,15 @@
# 02.07.24
import sys
import subprocess
from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
# Logic class
from .site import title_search, run_get_select_title, media_search_manager
from .site import title_search, media_search_manager, table_show_manager
from .title import download_title
@ -40,7 +39,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
if len_database > 0:
# Select title from list
select_title = run_get_select_title()
select_title = get_select_title(table_show_manager, media_search_manager)
# Download title
download_title(select_title)

View File

@ -13,7 +13,6 @@ from StreamingCommunity.Util.table import TVShowManager
# Logic class
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.Api.Template.Util import search_domain
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
@ -77,11 +76,4 @@ def title_search(word_to_search: str) -> int:
print(f"Error parsing a film entry: {e}")
# Return the number of titles found
return media_search_manager.get_length()
def run_get_select_title():
"""
Display a selection of titles and prompt the user to choose one.
"""
return get_select_title(table_show_manager, media_search_manager)
return media_search_manager.get_length()

View File

@ -7,11 +7,12 @@ from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
# Logic class
from .site import title_search, run_get_select_title, media_search_manager
from .site import title_search, media_search_manager, table_show_manager
from .film import download_film
@ -60,7 +61,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
if len_database > 0:
# Select title from list
select_title = run_get_select_title()
select_title = get_select_title(table_show_manager, media_search_manager)
# Download only film
download_film(select_title)

View File

@ -13,7 +13,6 @@ from StreamingCommunity.Util.table import TVShowManager
# Logic class
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.Api.Template.Util import search_domain
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
@ -107,11 +106,4 @@ def title_search(title_search: str) -> int:
bot.send_message(f"Lista dei risultati:", choices)
# Return the number of titles found
return media_search_manager.get_length()
def run_get_select_title():
"""
Display a selection of titles and prompt the user to choose one.
"""
return get_select_title(table_show_manager, media_search_manager)
return media_search_manager.get_length()

View File

@ -2,16 +2,16 @@
import sys
import subprocess
from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
# Logic class
from .site import title_search, run_get_select_title, media_search_manager
from .site import title_search, media_search_manager, table_show_manager
from .film_serie import download_film, download_series
@ -58,7 +58,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
if len_database > 0:
# Select title from list (type: TV \ Movie \ OVA)
select_title = run_get_select_title()
select_title = get_select_title(table_show_manager, media_search_manager)
if select_title.type == 'Movie' or select_title.type == 'OVA':
download_film(select_title)

View File

@ -16,7 +16,6 @@ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
# Logic class
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.Api.Template.Util import search_domain
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
@ -182,11 +181,4 @@ def title_search(title: str) -> int:
bot.send_message(f"Lista dei risultati:", choices)
# Return the length of media search manager
return media_search_manager.get_length()
def run_get_select_title():
"""
Display a selection of titles and prompt the user to choose one.
"""
return get_select_title(table_show_manager, media_search_manager)
return media_search_manager.get_length()

View File

@ -5,10 +5,11 @@ from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
# Logic class
from .site import title_search, run_get_select_title, media_search_manager
from .site import title_search, media_search_manager, table_show_manager
from .film import download_film
@ -39,7 +40,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
if len_database > 0:
# Select title from list
select_title = run_get_select_title()
select_title = get_select_title(table_show_manager, media_search_manager)
# !!! ADD TYPE DONT WORK FOR SERIE
download_film(select_title)

View File

@ -12,7 +12,6 @@ from StreamingCommunity.Util.table import TVShowManager
# Logic class
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.Api.Template.Util import search_domain
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
@ -73,11 +72,4 @@ def title_search(word_to_search: str) -> int:
print(f"Error parsing a film entry: {e}")
# Return the number of titles found
return media_search_manager.get_length()
def run_get_select_title():
"""
Display a selection of titles and prompt the user to choose one.
"""
return get_select_title(table_show_manager, media_search_manager)
return media_search_manager.get_length()

View File

@ -6,10 +6,11 @@ from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
# Logic class
from .site import title_search, run_get_select_title, media_search_manager
from .site import title_search, media_search_manager, table_show_manager
from .series import download_thread
@ -40,7 +41,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
if len_database > 0:
# Select title from list
select_title = run_get_select_title()
select_title = get_select_title(table_show_manager, media_search_manager)
# Download only film
if "Serie TV" in str(select_title.type):

View File

@ -1,7 +1,6 @@
# 13.06.24
import os
import sys
from urllib.parse import urlparse
from typing import Tuple
@ -10,13 +9,17 @@ from typing import Tuple
from StreamingCommunity.Util.console import console
from StreamingCommunity.Util.message import start_message
from StreamingCommunity.Util.os import os_manager
from StreamingCommunity.Util.table import TVShowManager
from StreamingCommunity.Lib.Downloader import MP4_downloader
# Logic class
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
from StreamingCommunity.Api.Template.Util import manage_selection, map_episode_title, validate_episode_selection
from StreamingCommunity.Api.Template.Util import (
manage_selection,
map_episode_title,
validate_episode_selection,
display_episodes_list
)
# Player
@ -111,39 +114,3 @@ def download_thread(dict_serie: MediaItem):
if kill_handler:
break
kill_handler = download_video(i_episode, scape_info_serie, video_source)[1]
def display_episodes_list(obj_episode_manager) -> str:
"""
Display episodes list and handle user input.
Returns:
last_command (str): Last command entered by the user.
"""
# Set up table for displaying episodes
table_show_manager = TVShowManager()
table_show_manager.set_slice_end(10)
# Add columns to the table
column_info = {
"Index": {'color': 'red'},
"Name": {'color': 'magenta'},
}
table_show_manager.add_column(column_info)
# Populate the table with episodes information
for i, media in enumerate(obj_episode_manager):
table_show_manager.add_tv_show({
'Index': str(i+1),
'Name': media.get('name'),
})
# Run the table and handle user input
last_command = table_show_manager.run()
if last_command == "q":
console.print("\n[red]Quit [white]...")
sys.exit(0)
return last_command

View File

@ -16,7 +16,6 @@ from StreamingCommunity.Util.table import TVShowManager
# Logic class
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.Api.Template.Util import search_domain
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
@ -89,11 +88,4 @@ def title_search(word_to_search: str) -> int:
logging.error("No table content found.")
return -999
return -9999
def run_get_select_title():
"""
Display a selection of titles and prompt the user to choose one.
"""
return get_select_title(table_show_manager, media_search_manager)
return -9999

View File

@ -5,10 +5,11 @@ from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
# Logic class
from .site import title_search, run_get_select_title, media_search_manager
from .site import title_search, media_search_manager, table_show_manager
from .series import download_series
@ -39,7 +40,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
if len_database > 0:
# Select title from list
select_title = run_get_select_title()
select_title = get_select_title(table_show_manager, media_search_manager)
# Download only film
download_series(select_title)

View File

@ -1,19 +1,24 @@
# 13.06.24
import os
import sys
from typing import Tuple
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Util.message import start_message
from StreamingCommunity.Util.table import TVShowManager
from StreamingCommunity.Lib.Downloader import HLS_Downloader
# Logic class
from StreamingCommunity.Api.Template.Util import manage_selection, map_episode_title, dynamic_format_number, validate_selection, validate_episode_selection
from StreamingCommunity.Api.Template.Util import (
manage_selection,
map_episode_title,
dynamic_format_number,
validate_selection,
validate_episode_selection,
display_episodes_list
)
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
@ -161,40 +166,4 @@ def download_series(dict_serie: MediaItem) -> None:
else:
# Otherwise, let the user select specific episodes for the single season
download_episode(scape_info_serie, i_season, download_all=False)
def display_episodes_list(obj_episode_manager) -> str:
"""
Display episodes list and handle user input.
Returns:
last_command (str): Last command entered by the user.
"""
# Set up table for displaying episodes
table_show_manager = TVShowManager()
table_show_manager.set_slice_end(10)
# Add columns to the table
column_info = {
"Index": {'color': 'red'},
"Name": {'color': 'magenta'},
}
table_show_manager.add_column(column_info)
# Populate the table with episodes information
for media in obj_episode_manager:
table_show_manager.add_tv_show({
'Index': str(media.get('number')),
'Name': media.get('name'),
})
# Run the table and handle user input
last_command = table_show_manager.run()
if last_command == "q":
console.print("\n[red]Quit [white]...")
sys.exit(0)
return last_command
download_episode(scape_info_serie, i_season, download_all=False)

View File

@ -13,7 +13,6 @@ from StreamingCommunity.Util.table import TVShowManager
# Logic class
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.Api.Template.Util import search_domain
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
@ -80,11 +79,4 @@ def title_search(word_to_search: str) -> int:
print(f"Error parsing a film entry: {e}")
# Return the number of titles found
return media_search_manager.get_length()
def run_get_select_title():
"""
Display a selection of titles and prompt the user to choose one.
"""
return get_select_title(table_show_manager, media_search_manager)
return media_search_manager.get_length()

View File

@ -11,10 +11,15 @@ from bs4 import BeautifulSoup
# Internal utilities
from StreamingCommunity.Util.headers import get_headers
from StreamingCommunity.Util._jsonConfig import config_manager
# Logic class
from StreamingCommunity.Api.Template .Class.SearchType import MediaItem
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
# Variable
max_timeout = config_manager.get_int("REQUESTS", "timeout")
class GetSerieInfo:
@ -40,19 +45,12 @@ class GetSerieInfo:
try:
# Make an HTTP request to the series URL
response = httpx.get(self.url, headers=self.headers, timeout=15)
response = httpx.get(self.url, headers=self.headers, timeout=max_timeout, follow_redirects=True)
response.raise_for_status()
# Parse HTML content of the page
soup = BeautifulSoup(response.text, "html.parser")
# Find the container of seasons
table_content = soup.find('div', class_="tt_season")
# Count the number of seasons
seasons_number = len(table_content.find_all("li"))
# Extract the name of the series
self.tv_name = soup.find("h1", class_="front_title").get_text(strip=True)
return seasons_number
@ -60,7 +58,7 @@ class GetSerieInfo:
except Exception as e:
logging.error(f"Error parsing HTML page: {e}")
return -999
return -1
def get_episode_number(self, n_season: int) -> List[Dict[str, str]]:
"""
@ -75,7 +73,7 @@ class GetSerieInfo:
try:
# Make an HTTP request to the series URL
response = httpx.get(self.url, headers=self.headers, timeout=15)
response = httpx.get(self.url, headers=self.headers, timeout=max_timeout, follow_redirects=True)
response.raise_for_status()
# Parse HTML content of the page
@ -83,8 +81,6 @@ class GetSerieInfo:
# Find the container of episodes for the specified season
table_content = soup.find('div', class_="tab-pane", id=f"season-{n_season}")
# Extract episode information
episode_content = table_content.find_all("li")
list_dict_episode = []
@ -107,4 +103,4 @@ class GetSerieInfo:
except Exception as e:
logging.error(f"Error parsing HTML page: {e}")
return []
return []

View File

@ -6,10 +6,11 @@ from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
# Logic class
from .site import title_search, run_get_select_title, media_search_manager
from .site import title_search, media_search_manager, table_show_manager
from .title import download_title
@ -40,7 +41,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
if len_database > 0:
# Select title from list
select_title = run_get_select_title()
select_title = get_select_title(table_show_manager, media_search_manager)
# Download title
download_title(select_title)

View File

@ -7,7 +7,6 @@ from StreamingCommunity.Util.table import TVShowManager
# Logic class
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.Api.Template.Util import search_domain
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
from .util.ilCorsarScraper import IlCorsaroNeroScraper
@ -62,11 +61,4 @@ async def title_search(word_to_search: str) -> int:
print(f"Error parsing a film entry: {e}")
# Return the number of titles found
return media_search_manager.get_length()
def run_get_select_title():
"""
Display a selection of titles and prompt the user to choose one.
"""
return get_select_title(table_show_manager, media_search_manager)
return media_search_manager.get_length()

View File

@ -7,11 +7,12 @@ from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
# Logic class
from .site import get_version_and_domain, title_search, run_get_select_title, media_search_manager
from .site import get_version_and_domain, title_search, table_show_manager, media_search_manager
from .film import download_film
from .series import download_series
@ -62,7 +63,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
if len_database > 0:
# Select title from list
select_title = run_get_select_title()
select_title = get_select_title(table_show_manager, media_search_manager)
if select_title.type == 'tv':
download_series(select_title, site_version)

View File

@ -1,20 +1,25 @@
# 3.12.23
import os
import sys
from typing import Tuple
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Util.message import start_message
from StreamingCommunity.Util.table import TVShowManager
from StreamingCommunity.Lib.Downloader import HLS_Downloader
from StreamingCommunity.TelegramHelp.telegram_bot import TelegramSession, get_bot_instance
# Logic class
from .util.ScrapeSerie import ScrapeSerie
from StreamingCommunity.Api.Template.Util import manage_selection, map_episode_title, dynamic_format_number, validate_selection, validate_episode_selection
from StreamingCommunity.Api.Template.Util import (
manage_selection,
map_episode_title,
dynamic_format_number,
validate_selection,
validate_episode_selection,
display_episodes_list
)
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
@ -114,7 +119,7 @@ def download_episode(index_season_selected: int, scrape_serie: ScrapeSerie, vide
else:
# Display episodes list and manage user selection
last_command = display_episodes_list(scrape_serie)
last_command = display_episodes_list(scrape_serie.episode_manager.episodes)
list_episode_select = manage_selection(last_command, episodes_count)
try:
@ -204,55 +209,4 @@ def download_series(select_season: MediaItem, version: str) -> None:
# Get script_id
script_id = TelegramSession.get_session()
if script_id != "unknown":
TelegramSession.deleteScriptId(script_id)
def display_episodes_list(scrape_serie) -> str:
"""
Display episodes list and handle user input.
Returns:
last_command (str): Last command entered by the user.
"""
if TELEGRAM_BOT:
bot = get_bot_instance()
# Set up table for displaying episodes
table_show_manager = TVShowManager()
table_show_manager.set_slice_end(10)
# Add columns to the table
column_info = {
"Index": {'color': 'red'},
"Name": {'color': 'magenta'},
"Duration": {'color': 'green'}
}
table_show_manager.add_column(column_info)
# Populate the table with episodes information
if TELEGRAM_BOT:
choices = []
for i, media in enumerate(scrape_serie.episode_manager.episodes):
table_show_manager.add_tv_show({
'Index': str(media.number),
'Name': media.name,
'Duration': str(media.duration)
})
if TELEGRAM_BOT:
choice_text = f"{media.number} - {media.name} ({media.duration} min)"
choices.append(choice_text)
if TELEGRAM_BOT:
if choices:
bot.send_message(f"Lista episodi:", choices)
# Run the table and handle user input
last_command = table_show_manager.run()
if last_command == "q" or last_command == "quit":
console.print("\n[red]Quit [white]...")
sys.exit(0)
return last_command
TelegramSession.deleteScriptId(script_id)

View File

@ -19,7 +19,6 @@ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
# Logic class
from StreamingCommunity.Api.Template import get_select_title
from StreamingCommunity.Api.Template.Util import search_domain
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
@ -147,11 +146,4 @@ def title_search(title_search: str, domain: str) -> int:
bot.send_message(f"Lista dei risultati:", choices)
# Return the number of titles found
return media_search_manager.get_length()
def run_get_select_title():
"""
Display a selection of titles and prompt the user to choose one.
"""
return get_select_title(table_show_manager, media_search_manager)
return media_search_manager.get_length()

View File

@ -2,4 +2,11 @@
from .recall_search import execute_search
from .get_domain import search_domain
from .manage_ep import manage_selection, map_episode_title, validate_episode_selection, validate_selection, dynamic_format_number
from .manage_ep import (
manage_selection,
map_episode_title,
validate_episode_selection,
validate_selection,
dynamic_format_number,
display_episodes_list
)

View File

@ -1,12 +1,15 @@
# 19.06.24
import sys
import logging
from typing import List
# Internal utilities
from StreamingCommunity.Util._jsonConfig import config_manager
from StreamingCommunity.Util.console import console
from StreamingCommunity.Util.os import os_manager
from StreamingCommunity.Util._jsonConfig import config_manager
from StreamingCommunity.Util.table import TVShowManager
# Config
@ -176,4 +179,45 @@ def validate_episode_selection(list_episode_select: List[int], episodes_count: i
# Prompt the user for valid input again
input_episodes = input(f"Enter valid episode numbers (1-{episodes_count}): ")
list_episode_select = list(map(int, input_episodes.split(',')))
list_episode_select = list(map(int, input_episodes.split(',')))
def display_episodes_list(episodes_manager) -> str:
"""
Display episodes list and handle user input.
Returns:
last_command (str): Last command entered by the user.
"""
# Set up table for displaying episodes
table_show_manager = TVShowManager()
table_show_manager.set_slice_end(10)
# Add columns to the table
column_info = {
"Index": {'color': 'red'},
"Name": {'color': 'magenta'},
"Duration": {'color': 'blue'}
}
table_show_manager.add_column(column_info)
# Populate the table with episodes information
for i, media in enumerate(episodes_manager):
name = media.get('name') if isinstance(media, dict) else getattr(media, 'name', None)
duration = media.get('duration') if isinstance(media, dict) else getattr(media, 'duration', None)
episode_info = {
'Index': str(i + 1),
'Name': name,
'Duration': duration
}
table_show_manager.add_tv_show(episode_info)
# Run the table and handle user input
last_command = table_show_manager.run()
if last_command in ("q", "quit"):
console.print("\n[red]Quit [white]...")
sys.exit(0)
return last_command

View File

@ -93,7 +93,6 @@ class M3U8_Segments:
self.info_maxRetry = 0
self.info_nRetry = 0
self.info_nFailed = 0
self.active_retries = 0
self.active_retries_lock = threading.Lock()
@ -208,7 +207,7 @@ class M3U8_Segments:
- index (int): The index of the segment.
- progress_bar (tqdm): Progress counter for tracking download progress.
- backoff_factor (float): The backoff factor for exponential backoff (default is 1.5 seconds).
"""
"""
for attempt in range(REQUEST_MAX_RETRY):
if self.interrupt_flag.is_set():
return
@ -310,6 +309,8 @@ class M3U8_Segments:
except queue.Empty:
self.current_timeout = min(MAX_TIMEOOUT, self.current_timeout * 1.1)
time.sleep(0.05)
if self.stop_event.is_set():
break
@ -325,6 +326,7 @@ class M3U8_Segments:
- type (str): Type of download: 'video' or 'audio'
"""
if TELEGRAM_BOT:
# Viene usato per lo screen
console.log("####")
@ -336,7 +338,8 @@ class M3U8_Segments:
unit='s',
ascii='░▒█',
bar_format=self._get_bar_format(description),
mininterval=0.05,
mininterval=0.6,
maxinterval=1.0,
file=sys.stdout, # Using file=sys.stdout to force in-place updates because sys.stderr may not support carriage returns in this environment.
)

View File

@ -382,47 +382,6 @@ class M3U8_Subtitle:
return subtitle
return None
def download_all(self, custom_subtitle):
"""
Download all subtitles listed in the object's attributes, filtering based on a provided list of custom subtitles.
Parameters:
- custom_subtitle (list): A list of custom subtitles to download.
Returns:
list: A list containing dictionaries with subtitle information including name, language, and URI.
"""
output = [] # Initialize an empty list to store subtitle information
# Iterate through all available subtitles
for obj_subtitle in self.subtitle_get_all_uris_and_names():
# Check if the subtitle name is not in the list of custom subtitles, and skip if not found
if obj_subtitle.get('name') not in custom_subtitle:
continue
# Send a request to retrieve the subtitle content
logging.info(f"Download subtitle: {obj_subtitle.get('name')}")
response_subitle = httpx.get(obj_subtitle.get('uri'))
try:
# Try to extract the VTT URL from the subtitle content
sub_parse = M3U8_Parser()
sub_parse.parse_data(obj_subtitle.get('uri'), response_subitle.text)
url_subititle = sub_parse.subtitle[0]
output.append({
'name': obj_subtitle.get('name'),
'language': obj_subtitle.get('language'),
'uri': url_subititle
})
except Exception as e:
logging.error(f"Cant download: {obj_subtitle.get('name')}, error: {e}")
return output
class M3U8_Parser:
def __init__(self):
@ -560,7 +519,6 @@ class M3U8_Parser:
- m3u8_obj: The M3U8 object containing encryption keys.
"""
try:
if m3u8_obj.key is not None:
if self.keys is None:
self.keys = {
@ -569,7 +527,6 @@ class M3U8_Parser:
'uri': m3u8_obj.key.uri
}
except Exception as e:
logging.error(f"Error parsing encryption keys: {e}")
sys.exit(0)
@ -634,7 +591,6 @@ class M3U8_Parser:
"""
Initialize variables for video, audio, and subtitle playlists.
"""
self._video = M3U8_Video(self.video_playlist)
self._audio = M3U8_Audio(self.audio_playlist)
self._subtitle = M3U8_Subtitle(self.subtitle_playlist)
@ -668,4 +624,4 @@ class M3U8_Parser:
if return_string:
return f"[yellow]{int(hours)}[red]h [yellow]{int(minutes)}[red]m [yellow]{int(seconds)}[red]s"
else:
return {'h': int(hours), 'm': int(minutes), 's': int(seconds)}
return {'h': int(hours), 'm': int(minutes), 's': int(seconds)}

View File

@ -101,6 +101,8 @@ class TheMovieDB:
self.api_key = api_key
self.base_url = "https://api.themoviedb.org/3"
#self.genres = self._fetch_genres()
self._cached_trending_tv = None
self._cached_trending_movies = None
def _make_request(self, endpoint, params=None):
"""
@ -162,17 +164,37 @@ class TheMovieDB:
def display_trending_tv_shows(self):
"""
Fetch and display the top 5 trending TV shows of the week.
Uses cached data if available, otherwise makes a new request.
"""
data = self._make_request("trending/tv/week").get("results", [])
self._display_top_5("Trending TV shows", data, name_key='name')
if self._cached_trending_tv is None:
self._cached_trending_tv = self._make_request("trending/tv/week").get("results", [])
self._display_top_5("Trending TV shows", self._cached_trending_tv, name_key='name')
def refresh_trending_tv_shows(self):
"""
Force a refresh of the trending TV shows cache.
"""
self._cached_trending_tv = self._make_request("trending/tv/week").get("results", [])
return self._cached_trending_tv
def display_trending_films(self):
"""
Fetch and display the top 5 trending films of the week.
Uses cached data if available, otherwise makes a new request.
"""
data = self._make_request("trending/movie/week").get("results", [])
self._display_top_5("Trending films", data, name_key='title')
if self._cached_trending_movies is None:
self._cached_trending_movies = self._make_request("trending/movie/week").get("results", [])
self._display_top_5("Trending films", self._cached_trending_movies, name_key='title')
def refresh_trending_films(self):
"""
Force a refresh of the trending films cache.
"""
self._cached_trending_movies = self._make_request("trending/movie/week").get("results", [])
return self._cached_trending_movies
def search_movie(self, movie_name: str):
"""
Search for a movie by name and return its TMDB ID.

View File

@ -65,7 +65,7 @@
"domain": "pro"
},
"guardaserie": {
"domain": "meme"
"domain": "now"
},
"mostraguarda": {
"domain": "stream"
@ -82,7 +82,7 @@
"domain": "so"
},
"cb01new": {
"domain": "media"
"domain": "gold"
},
"1337xx": {
"domain": "to"