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
|
# Extract the ID of the selected episode
|
||||||
episode_id = info_ep_select.get("id")
|
episode_id = info_ep_select.get("id")
|
||||||
|
|
||||||
start_message()
|
start_message(True)
|
||||||
console.print(f"[yellow]Download: [red]{episode_id} \n")
|
console.print(f"[yellow]Download: [red]{episode_id} \n")
|
||||||
|
|
||||||
# Get the embed URL for the episode
|
# Get the embed URL for the episode
|
||||||
|
@ -364,10 +364,14 @@ def anime_search(title_search: str) -> int:
|
|||||||
return media_search_manager.get_length()
|
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.
|
Display a selection of titles and prompt the user to choose one.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
- switch (bool): switch from film to anime
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
MediaItem: The selected media item.
|
MediaItem: The selected media item.
|
||||||
"""
|
"""
|
||||||
@ -396,7 +400,7 @@ def get_select_title() -> MediaItem:
|
|||||||
})
|
})
|
||||||
|
|
||||||
# Run the table and handle user input
|
# 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
|
# Handle user's quit command
|
||||||
if last_command == "q":
|
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:
|
def extract_resolution(uri: str) -> int:
|
||||||
"""
|
"""
|
||||||
@ -49,23 +58,13 @@ def extract_resolution(uri: str) -> int:
|
|||||||
- int: The video resolution if found, otherwise 0.
|
- int: The video resolution if found, otherwise 0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Common video resolutions
|
for resolution in RESOLUTIONS:
|
||||||
resolutions = [
|
if str(resolution[1]) in uri:
|
||||||
480,
|
|
||||||
720,
|
|
||||||
1080,
|
|
||||||
2160,
|
|
||||||
3840
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
for resolution in resolutions:
|
|
||||||
if str(resolution) in uri:
|
|
||||||
return resolution
|
return resolution
|
||||||
|
|
||||||
# Default resolution return (not best)
|
# Default resolution return (not best)
|
||||||
logging.error("No resolution find")
|
logging.error("No resolution find with custom parsing.")
|
||||||
return 0
|
return -1
|
||||||
|
|
||||||
|
|
||||||
class M3U8_Codec():
|
class M3U8_Codec():
|
||||||
@ -233,17 +232,23 @@ class M3U8_Parser:
|
|||||||
try:
|
try:
|
||||||
for playlist in m3u8_obj.playlists:
|
for playlist in m3u8_obj.playlists:
|
||||||
|
|
||||||
# Try to access the 'resolution' key in playlist.stream_info
|
# Direct access resolutions in m3u8 obj
|
||||||
try:
|
try:
|
||||||
resolution = playlist.stream_info.get('resolution')
|
self.video_playlist.append({
|
||||||
except:
|
"uri": playlist.uri,
|
||||||
# If the key 'resolution' does not exist, use extract_resolution
|
"width": playlist.stream_info.get('resolution')
|
||||||
resolution = extract_resolution(playlist.uri)
|
})
|
||||||
|
|
||||||
|
# Find resolutions in uri
|
||||||
|
except:
|
||||||
|
self.video_playlist.append({
|
||||||
|
"uri": playlist.uri,
|
||||||
|
"width": extract_resolution(playlist.uri)
|
||||||
|
})
|
||||||
|
|
||||||
|
# Dont stop
|
||||||
|
continue
|
||||||
|
|
||||||
self.video_playlist.append({
|
|
||||||
"uri": playlist.uri,
|
|
||||||
"width": resolution
|
|
||||||
})
|
|
||||||
|
|
||||||
# Check if all key is present to create codec
|
# Check if all key is present to create codec
|
||||||
if all(key in playlist.stream_info for key in ('bandwidth', 'resolution', 'codecs')):
|
if all(key in playlist.stream_info for key in ('bandwidth', 'resolution', 'codecs')):
|
||||||
|
@ -25,7 +25,7 @@ def get_os_system():
|
|||||||
return os_system
|
return os_system
|
||||||
|
|
||||||
|
|
||||||
def start_message():
|
def start_message(switch = False):
|
||||||
"""
|
"""
|
||||||
Display a start message.
|
Display a start message.
|
||||||
|
|
||||||
@ -45,6 +45,18 @@ def start_message():
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if switch:
|
||||||
|
msg = """
|
||||||
|
|
||||||
|
_ _ _ _
|
||||||
|
/ \ _ __ (_)_ __ ___ ___ _ _ _ __ (_) |_ _ _
|
||||||
|
/ _ \ | '_ \| | '_ ` _ \ / _ \ | | | '_ \| | __| | | |
|
||||||
|
/ ___ \| | | | | | | | | | __/ |_| | | | | | |_| |_| |
|
||||||
|
/_/ \_\_| |_|_|_| |_| |_|\___|\__,_|_| |_|_|\__|\__, |
|
||||||
|
|___/
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
if CLEAN:
|
if CLEAN:
|
||||||
if get_os_system() == 'Windows':
|
if get_os_system() == 'Windows':
|
||||||
os.system("cls")
|
os.system("cls")
|
||||||
@ -52,6 +64,7 @@ def start_message():
|
|||||||
os.system("clear")
|
os.system("clear")
|
||||||
|
|
||||||
if SHOW:
|
if SHOW:
|
||||||
|
|
||||||
console.print(f"[bold yellow]{msg}")
|
console.print(f"[bold yellow]{msg}")
|
||||||
console.print(f"[magenta]Created by: Ghost6446\n")
|
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
|
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.
|
Run the TV show manager application.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
- force_int_input(bool): If True, only accept integer inputs from 0 to max_int_input
|
- 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:
|
Returns:
|
||||||
- str: Last command executed before breaking out of the loop.
|
- 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
|
last_command = "" # Variable to store the last command executed
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
start_message()
|
start_message(switch)
|
||||||
|
|
||||||
# Display table
|
# Display table
|
||||||
self.display_data(self.tv_shows[self.slice_start:self.slice_end])
|
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')
|
CLOSE_CONSOLE = config_manager.get_bool('DEFAULT', 'not_close')
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
def initialize(switch = False):
|
||||||
"""
|
"""
|
||||||
Initialize the application.
|
Initialize the application.
|
||||||
Checks Python version, removes temporary folder, and displays start message.
|
Checks Python version, removes temporary folder, and displays start message.
|
||||||
@ -63,7 +63,7 @@ def initialize():
|
|||||||
# Removing temporary folder
|
# Removing temporary folder
|
||||||
remove_folder("tmp")
|
remove_folder("tmp")
|
||||||
remove_file("debug.log")
|
remove_file("debug.log")
|
||||||
start_message()
|
start_message(switch)
|
||||||
|
|
||||||
|
|
||||||
# Attempting GitHub update
|
# Attempting GitHub update
|
||||||
@ -141,7 +141,7 @@ def main_anime():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Get site domain and version
|
# Get site domain and version
|
||||||
initialize()
|
initialize(True)
|
||||||
|
|
||||||
# Make request to site to get content that corrsisponde to that string
|
# 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()
|
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:
|
if len_database != 0:
|
||||||
|
|
||||||
# Select title from list
|
# Select title from list
|
||||||
select_title = get_select_title()
|
select_title = get_select_title(True)
|
||||||
|
|
||||||
# For series
|
# For series
|
||||||
if select_title.type == 'TV':
|
if select_title.type == 'TV':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user