mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Fix resolution
This commit is contained in:
parent
f98bb29f0a
commit
29fa6ab0d0
@ -149,7 +149,7 @@ class EpisodeDownloader:
|
||||
# Extract the ID of the selected episode
|
||||
episode_id = info_ep_select.get("id")
|
||||
|
||||
start_message()
|
||||
start_message(True)
|
||||
console.print(f"[yellow]Download: [red]{episode_id} \n")
|
||||
|
||||
# Get the embed URL for the episode
|
||||
|
@ -364,10 +364,14 @@ def anime_search(title_search: str) -> int:
|
||||
return media_search_manager.get_length()
|
||||
|
||||
|
||||
def get_select_title() -> MediaItem:
|
||||
def get_select_title(switch = False) -> MediaItem:
|
||||
"""
|
||||
Display a selection of titles and prompt the user to choose one.
|
||||
|
||||
Args:
|
||||
- switch (bool): switch from film to anime
|
||||
|
||||
|
||||
Returns:
|
||||
MediaItem: The selected media item.
|
||||
"""
|
||||
@ -396,7 +400,7 @@ def get_select_title() -> MediaItem:
|
||||
})
|
||||
|
||||
# Run the table and handle user input
|
||||
last_command = table_show_manager.run(force_int_input=True, max_int_input=len(media_search_manager.media_list))
|
||||
last_command = table_show_manager.run(force_int_input=True, max_int_input=len(media_search_manager.media_list), switch=switch)
|
||||
|
||||
# Handle user's quit command
|
||||
if last_command == "q":
|
||||
|
@ -37,6 +37,15 @@ CODEC_MAPPINGS = {
|
||||
}
|
||||
}
|
||||
|
||||
RESOLUTIONS = [
|
||||
(7680, 4320),
|
||||
(3840, 2160),
|
||||
(2560, 1440),
|
||||
(1920, 1080),
|
||||
(1280, 720),
|
||||
(640, 480)
|
||||
]
|
||||
|
||||
|
||||
def extract_resolution(uri: str) -> int:
|
||||
"""
|
||||
@ -49,23 +58,13 @@ def extract_resolution(uri: str) -> int:
|
||||
- int: The video resolution if found, otherwise 0.
|
||||
"""
|
||||
|
||||
# Common video resolutions
|
||||
resolutions = [
|
||||
480,
|
||||
720,
|
||||
1080,
|
||||
2160,
|
||||
3840
|
||||
]
|
||||
|
||||
|
||||
for resolution in resolutions:
|
||||
if str(resolution) in uri:
|
||||
for resolution in RESOLUTIONS:
|
||||
if str(resolution[1]) in uri:
|
||||
return resolution
|
||||
|
||||
# Default resolution return (not best)
|
||||
logging.error("No resolution find")
|
||||
return 0
|
||||
logging.error("No resolution find with custom parsing.")
|
||||
return -1
|
||||
|
||||
|
||||
class M3U8_Codec():
|
||||
@ -233,18 +232,24 @@ class M3U8_Parser:
|
||||
try:
|
||||
for playlist in m3u8_obj.playlists:
|
||||
|
||||
# Try to access the 'resolution' key in playlist.stream_info
|
||||
# Direct access resolutions in m3u8 obj
|
||||
try:
|
||||
resolution = playlist.stream_info.get('resolution')
|
||||
except:
|
||||
# If the key 'resolution' does not exist, use extract_resolution
|
||||
resolution = extract_resolution(playlist.uri)
|
||||
|
||||
self.video_playlist.append({
|
||||
"uri": playlist.uri,
|
||||
"width": resolution
|
||||
"width": playlist.stream_info.get('resolution')
|
||||
})
|
||||
|
||||
# Find resolutions in uri
|
||||
except:
|
||||
self.video_playlist.append({
|
||||
"uri": playlist.uri,
|
||||
"width": extract_resolution(playlist.uri)
|
||||
})
|
||||
|
||||
# Dont stop
|
||||
continue
|
||||
|
||||
|
||||
# Check if all key is present to create codec
|
||||
if all(key in playlist.stream_info for key in ('bandwidth', 'resolution', 'codecs')):
|
||||
self.codec = M3U8_Codec(
|
||||
|
@ -25,7 +25,7 @@ def get_os_system():
|
||||
return os_system
|
||||
|
||||
|
||||
def start_message():
|
||||
def start_message(switch = False):
|
||||
"""
|
||||
Display a start message.
|
||||
|
||||
@ -45,6 +45,18 @@ def start_message():
|
||||
|
||||
"""
|
||||
|
||||
if switch:
|
||||
msg = """
|
||||
|
||||
_ _ _ _
|
||||
/ \ _ __ (_)_ __ ___ ___ _ _ _ __ (_) |_ _ _
|
||||
/ _ \ | '_ \| | '_ ` _ \ / _ \ | | | '_ \| | __| | | |
|
||||
/ ___ \| | | | | | | | | | __/ |_| | | | | | |_| |_| |
|
||||
/_/ \_\_| |_|_|_| |_| |_|\___|\__,_|_| |_|_|\__|\__, |
|
||||
|___/
|
||||
|
||||
"""
|
||||
|
||||
if CLEAN:
|
||||
if get_os_system() == 'Windows':
|
||||
os.system("cls")
|
||||
@ -52,6 +64,7 @@ def start_message():
|
||||
os.system("clear")
|
||||
|
||||
if SHOW:
|
||||
|
||||
console.print(f"[bold yellow]{msg}")
|
||||
console.print(f"[magenta]Created by: Ghost6446\n")
|
||||
|
||||
|
@ -80,13 +80,14 @@ class TVShowManager:
|
||||
|
||||
self.console.print(table) # Use self.console.print instead of print
|
||||
|
||||
def run(self, force_int_input: bool = False, max_int_input: int = 0) -> str:
|
||||
def run(self, force_int_input: bool = False, max_int_input: int = 0, switch: bool = False) -> str:
|
||||
"""
|
||||
Run the TV show manager application.
|
||||
|
||||
Args:
|
||||
- force_int_input(bool): If True, only accept integer inputs from 0 to max_int_input
|
||||
- max_int_input (int):
|
||||
- max_int_input (int): range of row to show
|
||||
- switch (bool): switch from film to anime
|
||||
|
||||
Returns:
|
||||
- str: Last command executed before breaking out of the loop.
|
||||
@ -95,7 +96,7 @@ class TVShowManager:
|
||||
last_command = "" # Variable to store the last command executed
|
||||
|
||||
while True:
|
||||
start_message()
|
||||
start_message(switch)
|
||||
|
||||
# Display table
|
||||
self.display_data(self.tv_shows[self.slice_start:self.slice_end])
|
||||
|
8
run.py
8
run.py
@ -36,7 +36,7 @@ SWITCH_TO = config_manager.get_bool('DEFAULT', 'swith_anime')
|
||||
CLOSE_CONSOLE = config_manager.get_bool('DEFAULT', 'not_close')
|
||||
|
||||
|
||||
def initialize():
|
||||
def initialize(switch = False):
|
||||
"""
|
||||
Initialize the application.
|
||||
Checks Python version, removes temporary folder, and displays start message.
|
||||
@ -63,7 +63,7 @@ def initialize():
|
||||
# Removing temporary folder
|
||||
remove_folder("tmp")
|
||||
remove_file("debug.log")
|
||||
start_message()
|
||||
start_message(switch)
|
||||
|
||||
|
||||
# Attempting GitHub update
|
||||
@ -141,7 +141,7 @@ def main_anime():
|
||||
"""
|
||||
|
||||
# Get site domain and version
|
||||
initialize()
|
||||
initialize(True)
|
||||
|
||||
# Make request to site to get content that corrsisponde to that string
|
||||
film_search = msg.ask("\n[cyan]Insert word to search in all site: ").strip()
|
||||
@ -150,7 +150,7 @@ def main_anime():
|
||||
if len_database != 0:
|
||||
|
||||
# Select title from list
|
||||
select_title = get_select_title()
|
||||
select_title = get_select_title(True)
|
||||
|
||||
# For series
|
||||
if select_title.type == 'TV':
|
||||
|
Loading…
x
Reference in New Issue
Block a user