mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Dinamic manage_selection() and map_episode_title()
This commit is contained in:
parent
62a6c74b60
commit
f4d01a69f3
@ -1,4 +1,4 @@
|
||||
# 02.05.24
|
||||
# 19.06.24
|
||||
|
||||
import logging
|
||||
|
@ -1,4 +1,5 @@
|
||||
# 19.06.24
|
||||
|
||||
from .site import get_select_title
|
||||
from .Util.get_domain import search_domain
|
||||
from .Util.get_domain import search_domain
|
||||
from .Util.manage_ep import manage_selection, map_episode_title
|
@ -1,6 +0,0 @@
|
||||
# 21.05.24
|
||||
|
||||
from .manage_ep import (
|
||||
manage_selection,
|
||||
map_episode_title
|
||||
)
|
@ -1,74 +0,0 @@
|
||||
# 02.05.24
|
||||
|
||||
import logging
|
||||
|
||||
from typing import List
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from Src.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
# Logic class
|
||||
from ..Class.EpisodeType import Episode
|
||||
|
||||
|
||||
# Config
|
||||
MAP_EPISODE = config_manager.get('DEFAULT', 'map_episode_name')
|
||||
|
||||
|
||||
def manage_selection(cmd_insert: str, max_count: int) -> List[int]:
|
||||
"""
|
||||
Manage user selection for seasons to download.
|
||||
|
||||
Args:
|
||||
- cmd_insert (str): User input for season selection.
|
||||
- max_count (int): Maximum count of seasons available.
|
||||
|
||||
Returns:
|
||||
list_season_select (List[int]): List of selected seasons.
|
||||
"""
|
||||
list_season_select = []
|
||||
logging.info(f"Command insert: {cmd_insert}, end index: {max_count + 1}")
|
||||
|
||||
# For a single number (e.g., '5')
|
||||
if cmd_insert.isnumeric():
|
||||
list_season_select.append(int(cmd_insert))
|
||||
|
||||
# For a range (e.g., '[5-12]')
|
||||
elif "[" in cmd_insert:
|
||||
start, end = map(int, cmd_insert[1:-1].split('-'))
|
||||
list_season_select = list(range(start, end + 1))
|
||||
|
||||
# For all seasons
|
||||
elif cmd_insert == "*":
|
||||
list_season_select = list(range(1, max_count+1))
|
||||
|
||||
# Return list of selected seasons)
|
||||
logging.info(f"List return: {list_season_select}")
|
||||
return list_season_select
|
||||
|
||||
|
||||
def map_episode_title(tv_name: str, episode: Episode, number_season: int):
|
||||
"""
|
||||
Maps the episode title to a specific format.
|
||||
|
||||
Args:
|
||||
- tv_name (str): The name of the TV show.
|
||||
- episode (Episode): The episode object.
|
||||
- number_season (int): The season number.
|
||||
|
||||
Returns:
|
||||
str: The mapped episode title.
|
||||
"""
|
||||
map_episode_temp = MAP_EPISODE
|
||||
map_episode_temp = map_episode_temp.replace("%(tv_name)", tv_name)
|
||||
map_episode_temp = map_episode_temp.replace("%(season)", str(number_season).zfill(2))
|
||||
map_episode_temp = map_episode_temp.replace("%(episode)", str(episode.number).zfill(2))
|
||||
map_episode_temp = map_episode_temp.replace("%(episode_name)", episode.name)
|
||||
|
||||
# Additional fix
|
||||
map_episode_temp = map_episode_temp.replace(".", "_")
|
||||
|
||||
logging.info(f"Map episode string return: {map_episode_temp}")
|
||||
return map_episode_temp
|
@ -8,11 +8,11 @@ import logging
|
||||
from Src.Util.console import console, msg
|
||||
from Src.Lib.Hls.downloader import Downloader
|
||||
from Src.Util.message import start_message
|
||||
from ..Template import manage_selection
|
||||
|
||||
|
||||
# Logic class
|
||||
from .Core.Player.vixcloud import VideoSource
|
||||
from .Core.Util import manage_selection
|
||||
|
||||
|
||||
# Variable
|
||||
|
@ -9,16 +9,16 @@ from urllib.parse import urlparse
|
||||
# Internal utilities
|
||||
from Src.Util.color import Colors
|
||||
from Src.Util.console import console, msg
|
||||
from Src.Util.message import start_message
|
||||
from Src.Util.os import create_folder, can_create_file
|
||||
from Src.Util.table import TVShowManager
|
||||
from Src.Util.message import start_message
|
||||
from Src.Lib.Hls.download_mp4 import MP4_downloader
|
||||
from ..Template import manage_selection, map_episode_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from .Core.Class.SearchType import MediaItem
|
||||
from .Core.Class.ScrapeSerie import GetSerieInfo
|
||||
from .Core.Util.manage_ep import manage_selection, map_episode_title
|
||||
from .Core.Player.ddl import VideoSource
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ table_show_manager = TVShowManager()
|
||||
video_source = VideoSource()
|
||||
|
||||
|
||||
|
||||
def donwload_video(scape_info_serie: GetSerieInfo, index_episode_selected: int) -> None:
|
||||
"""
|
||||
Download a single episode video.
|
||||
|
@ -16,7 +16,7 @@ from ..Template import search_domain, get_select_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from .Core.Class.SearchType import MediaManager, MediaItem
|
||||
from .Core.Class.SearchType import MediaManager
|
||||
|
||||
|
||||
# Variable
|
||||
|
@ -1,71 +0,0 @@
|
||||
# 02.05.24
|
||||
|
||||
import logging
|
||||
|
||||
from typing import List
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from Src.Util._jsonConfig import config_manager
|
||||
from Src.Util.os import remove_special_characters
|
||||
|
||||
|
||||
# Config
|
||||
MAP_EPISODE = config_manager.get('DEFAULT', 'map_episode_name')
|
||||
|
||||
|
||||
def manage_selection(cmd_insert: str, max_count: int) -> List[int]:
|
||||
"""
|
||||
Manage user selection for seasons to download.
|
||||
|
||||
Args:
|
||||
- cmd_insert (str): User input for season selection.
|
||||
- max_count (int): Maximum count of seasons available.
|
||||
|
||||
Returns:
|
||||
list_season_select (List[int]): List of selected seasons.
|
||||
"""
|
||||
list_season_select = []
|
||||
logging.info(f"Command insert: {cmd_insert}, end index: {max_count + 1}")
|
||||
|
||||
# For a single number (e.g., '5')
|
||||
if cmd_insert.isnumeric():
|
||||
list_season_select.append(int(cmd_insert))
|
||||
|
||||
# For a range (e.g., '[5-12]')
|
||||
elif "[" in cmd_insert:
|
||||
start, end = map(int, cmd_insert[1:-1].split('-'))
|
||||
list_season_select = list(range(start, end + 1))
|
||||
|
||||
# For all seasons
|
||||
elif cmd_insert == "*":
|
||||
list_season_select = list(range(1, max_count+1))
|
||||
|
||||
# Return list of selected seasons)
|
||||
logging.info(f"List return: {list_season_select}")
|
||||
return list_season_select
|
||||
|
||||
def map_episode_title(tv_name: str, number_season: int, episode_number: int, episode_name: str) -> str:
|
||||
"""
|
||||
Maps the episode title to a specific format.
|
||||
|
||||
Args:
|
||||
tv_name (str): The name of the TV show.
|
||||
number_season (int): The season number.
|
||||
episode_number (int): The episode number.
|
||||
episode_name (str): The original name of the episode.
|
||||
|
||||
Returns:
|
||||
str: The mapped episode title.
|
||||
"""
|
||||
map_episode_temp = MAP_EPISODE
|
||||
map_episode_temp = map_episode_temp.replace("%(tv_name)", remove_special_characters(tv_name))
|
||||
map_episode_temp = map_episode_temp.replace("%(season)", str(number_season))
|
||||
map_episode_temp = map_episode_temp.replace("%(episode)", str(episode_number))
|
||||
map_episode_temp = map_episode_temp.replace("%(episode_name)", remove_special_characters(episode_name))
|
||||
|
||||
# Additional fix
|
||||
map_episode_temp = map_episode_temp.replace(".", "_")
|
||||
|
||||
logging.info(f"Map episode string return: {map_episode_temp}")
|
||||
return map_episode_temp
|
@ -10,12 +10,12 @@ from Src.Util.console import console, msg
|
||||
from Src.Util.table import TVShowManager
|
||||
from Src.Util.message import start_message
|
||||
from Src.Lib.Hls.downloader import Downloader
|
||||
from ..Template import manage_selection, map_episode_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from .Core.Class.SearchType import MediaItem
|
||||
from .Core.Class.ScrapeSerie import GetSerieInfo
|
||||
from .Core.Util.manage_ep import manage_selection, map_episode_title
|
||||
from .Core.Player.supervideo import VideoSource
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ table_show_manager = TVShowManager()
|
||||
video_source = VideoSource()
|
||||
|
||||
|
||||
|
||||
def donwload_video(scape_info_serie: GetSerieInfo, index_season_selected: int, index_episode_selected: int) -> None:
|
||||
"""
|
||||
Download a single episode video.
|
||||
|
@ -1,6 +0,0 @@
|
||||
# 21.05.24
|
||||
|
||||
from .manage_ep import (
|
||||
manage_selection,
|
||||
map_episode_title
|
||||
)
|
@ -1,75 +0,0 @@
|
||||
# 02.05.24
|
||||
|
||||
import logging
|
||||
|
||||
from typing import List
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from Src.Util._jsonConfig import config_manager
|
||||
from Src.Util.os import remove_special_characters
|
||||
|
||||
|
||||
# Logic class
|
||||
from ..Class.EpisodeType import Episode
|
||||
|
||||
|
||||
# Config
|
||||
MAP_EPISODE = config_manager.get('DEFAULT', 'map_episode_name')
|
||||
|
||||
|
||||
def manage_selection(cmd_insert: str, max_count: int) -> List[int]:
|
||||
"""
|
||||
Manage user selection for seasons to download.
|
||||
|
||||
Args:
|
||||
- cmd_insert (str): User input for season selection.
|
||||
- max_count (int): Maximum count of seasons available.
|
||||
|
||||
Returns:
|
||||
list_season_select (List[int]): List of selected seasons.
|
||||
"""
|
||||
list_season_select = []
|
||||
logging.info(f"Command insert: {cmd_insert}, end index: {max_count + 1}")
|
||||
|
||||
# For a single number (e.g., '5')
|
||||
if cmd_insert.isnumeric():
|
||||
list_season_select.append(int(cmd_insert))
|
||||
|
||||
# For a range (e.g., '[5-12]')
|
||||
elif "[" in cmd_insert:
|
||||
start, end = map(int, cmd_insert[1:-1].split('-'))
|
||||
list_season_select = list(range(start, end + 1))
|
||||
|
||||
# For all seasons
|
||||
elif cmd_insert == "*":
|
||||
list_season_select = list(range(1, max_count+1))
|
||||
|
||||
# Return list of selected seasons)
|
||||
logging.info(f"List return: {list_season_select}")
|
||||
return list_season_select
|
||||
|
||||
|
||||
def map_episode_title(tv_name: str, episode: Episode, number_season: int):
|
||||
"""
|
||||
Maps the episode title to a specific format.
|
||||
|
||||
Args:
|
||||
- tv_name (str): The name of the TV show.
|
||||
- episode (Episode): The episode object.
|
||||
- number_season (int): The season number.
|
||||
|
||||
Returns:
|
||||
str: The mapped episode title.
|
||||
"""
|
||||
map_episode_temp = MAP_EPISODE
|
||||
map_episode_temp = map_episode_temp.replace("%(tv_name)", remove_special_characters(tv_name))
|
||||
map_episode_temp = map_episode_temp.replace("%(season)", str(number_season).zfill(2))
|
||||
map_episode_temp = map_episode_temp.replace("%(episode)", str(episode.number).zfill(2))
|
||||
map_episode_temp = map_episode_temp.replace("%(episode_name)", remove_special_characters(episode.name))
|
||||
|
||||
# Additional fix
|
||||
map_episode_temp = map_episode_temp.replace(".", "_")
|
||||
|
||||
logging.info(f"Map episode string return: {map_episode_temp}")
|
||||
return map_episode_temp
|
@ -5,12 +5,7 @@ from Src.Util.console import console, msg
|
||||
|
||||
|
||||
# Logic class
|
||||
from .site import (
|
||||
get_version_and_domain,
|
||||
title_search,
|
||||
run_get_select_title
|
||||
)
|
||||
|
||||
from .site import get_version_and_domain, title_search, run_get_select_title
|
||||
from .film import download_film
|
||||
from .series import download_series
|
||||
|
||||
|
@ -53,4 +53,4 @@ def download_film(id_film: str, title_name: str, domain: str):
|
||||
Downloader(
|
||||
m3u8_playlist = master_playlist,
|
||||
output_filename = os.path.join(mp4_path, mp4_format)
|
||||
).start()
|
||||
).start()
|
||||
|
@ -7,14 +7,14 @@ import logging
|
||||
|
||||
# Internal utilities
|
||||
from Src.Util.console import console, msg
|
||||
from Src.Util.table import TVShowManager
|
||||
from Src.Util.message import start_message
|
||||
from Src.Util.table import TVShowManager
|
||||
from Src.Lib.Hls.downloader import Downloader
|
||||
from ..Template import manage_selection, map_episode_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from .Core.Player.vixcloud import VideoSource
|
||||
from .Core.Util import manage_selection, map_episode_title
|
||||
|
||||
|
||||
# Variable
|
||||
@ -23,6 +23,7 @@ video_source = VideoSource()
|
||||
table_show_manager = TVShowManager()
|
||||
|
||||
|
||||
|
||||
def donwload_video(tv_name: str, index_season_selected: int, index_episode_selected: int) -> None:
|
||||
"""
|
||||
Download a single episode video.
|
||||
@ -41,7 +42,7 @@ def donwload_video(tv_name: str, index_season_selected: int, index_episode_selec
|
||||
print()
|
||||
|
||||
# Define filename and path for the downloaded video
|
||||
mp4_name = f"{map_episode_title(tv_name, obj_episode, index_season_selected)}.mp4"
|
||||
mp4_name = f"{map_episode_title(tv_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
|
||||
mp4_path = os.path.join(ROOT_PATH, SITE_NAME, SERIES_FOLDER, tv_name, f"S{index_season_selected}")
|
||||
|
||||
# Retrieve scws and if available master playlist
|
||||
|
@ -20,7 +20,6 @@ from Src.Util.table import TVShowManager
|
||||
from ..Template import search_domain, get_select_title
|
||||
|
||||
|
||||
|
||||
# Logic class
|
||||
from .Core.Class.SearchType import MediaManager
|
||||
|
||||
|
@ -76,7 +76,7 @@ class Downloader():
|
||||
|
||||
self.m3u8_playlist = m3u8_playlist
|
||||
self.m3u8_index = m3u8_index
|
||||
self.output_filename = output_filename
|
||||
self.output_filename = output_filename.replace(" ", "_")
|
||||
|
||||
# Auto generate out file name if not present
|
||||
if output_filename == None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user