mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Fix anime cant find eng title
This commit is contained in:
parent
e90588b302
commit
f98bb29f0a
@ -50,7 +50,7 @@ def get_token(site_name: str, domain: str) -> dict:
|
|||||||
find_csrf_token = None
|
find_csrf_token = None
|
||||||
|
|
||||||
# Parse the HTML response using BeautifulSoup
|
# Parse the HTML response using BeautifulSoup
|
||||||
soup = BeautifulSoup(response.text, "lxml")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
|
|
||||||
# Loop through all meta tags in the HTML response
|
# Loop through all meta tags in the HTML response
|
||||||
for html_meta in soup.find_all("meta"):
|
for html_meta in soup.find_all("meta"):
|
||||||
@ -282,6 +282,34 @@ def update_domain_anime():
|
|||||||
config_manager.set_key('SITE', 'anime_domain', new_site_url.split(".")[-1])
|
config_manager.set_key('SITE', 'anime_domain', new_site_url.split(".")[-1])
|
||||||
|
|
||||||
|
|
||||||
|
def get_real_title(record):
|
||||||
|
"""
|
||||||
|
Get the real title from a record.
|
||||||
|
|
||||||
|
This function takes a record, which is assumed to be a dictionary representing a row of JSON data.
|
||||||
|
It looks for a title in the record, prioritizing English over Italian titles if available.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
- record (dict): A dictionary representing a row of JSON data.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
- str: The title found in the record. If no title is found, returns None.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
If `record` is {'title': 'Example Title', 'title_eng': 'English Title', 'title_it': 'Titolo Italiano'},
|
||||||
|
the function will return 'Example Title' since it's the first available title.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if record['title'] is not None:
|
||||||
|
return record['title']
|
||||||
|
|
||||||
|
elif record['title_eng'] is not None:
|
||||||
|
return record['title_eng']
|
||||||
|
|
||||||
|
else:
|
||||||
|
return record['title_it']
|
||||||
|
|
||||||
|
|
||||||
def anime_search(title_search: str) -> int:
|
def anime_search(title_search: str) -> int:
|
||||||
"""
|
"""
|
||||||
Function to perform an anime search using a provided title.
|
Function to perform an anime search using a provided title.
|
||||||
@ -326,11 +354,10 @@ def anime_search(title_search: str) -> int:
|
|||||||
for record in response.json()['records']:
|
for record in response.json()['records']:
|
||||||
|
|
||||||
# Rename keys for consistency
|
# Rename keys for consistency
|
||||||
record['name'] = record.pop('title')
|
record['name'] = get_real_title(record)
|
||||||
record['last_air_date'] = record.pop('date')
|
record['last_air_date'] = record.pop('date')
|
||||||
|
|
||||||
# Add the record to media search manager if the name is not None
|
# Add the record to media search manager if the name is not None
|
||||||
if record['name'] is not None:
|
|
||||||
media_search_manager.add_media(record)
|
media_search_manager.add_media(record)
|
||||||
|
|
||||||
# Return the length of media search manager
|
# Return the length of media search manager
|
||||||
|
@ -4,6 +4,7 @@ from .helper import (
|
|||||||
has_audio_stream,
|
has_audio_stream,
|
||||||
get_video_duration,
|
get_video_duration,
|
||||||
format_duration,
|
format_duration,
|
||||||
|
get_ts_resolution,
|
||||||
print_duration_table,
|
print_duration_table,
|
||||||
add_subtitle,
|
add_subtitle,
|
||||||
concatenate_and_save,
|
concatenate_and_save,
|
||||||
|
@ -128,6 +128,52 @@ def print_duration_table(file_path: str) -> None:
|
|||||||
console.log(f"[cyan]Info [green]'{file_path}': [purple]{int(hours)}[red]h [purple]{int(minutes)}[red]m [purple]{int(seconds)}[red]s")
|
console.log(f"[cyan]Info [green]'{file_path}': [purple]{int(hours)}[red]h [purple]{int(minutes)}[red]m [purple]{int(seconds)}[red]s")
|
||||||
|
|
||||||
|
|
||||||
|
def get_ts_resolution(ts_file_path):
|
||||||
|
"""
|
||||||
|
Get the resolution of a TS (MPEG Transport Stream) file using ffprobe.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
- ts_file_path (str): The file path to the TS file.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
- tuple: A tuple containing the width and height of the video stream in the TS file.
|
||||||
|
If resolution information is not available, returns (None, None).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
If `ts_file_path` points to a TS file with video resolution 1920x1080,
|
||||||
|
the function will return (1920, 1080).
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Run ffprobe command to get video stream information
|
||||||
|
ffprobe_cmd = ['ffprobe', '-v', 'error', '-show_entries', 'stream=width,height', '-of', 'json', ts_file_path]
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
# Execute ffprobe command and capture output
|
||||||
|
output = subprocess.check_output(ffprobe_cmd, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
# Decode JSON output
|
||||||
|
info = json.loads(output)
|
||||||
|
|
||||||
|
# Check if there are streams
|
||||||
|
if 'streams' in info:
|
||||||
|
for stream in info['streams']:
|
||||||
|
|
||||||
|
# Check if stream is video
|
||||||
|
if stream.get('codec_type') == 'video':
|
||||||
|
|
||||||
|
# Extract width and height
|
||||||
|
width = stream.get('width')
|
||||||
|
height = stream.get('height')
|
||||||
|
return width, height
|
||||||
|
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
logging.error("Error running ffprobe:", e)
|
||||||
|
|
||||||
|
# If no resolution information found, return None
|
||||||
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
def add_subtitle(input_video_path: str, input_subtitle_path: str, output_video_path: str, subtitle_language: str = 'ita', prefix: str = "single_sub") -> str:
|
def add_subtitle(input_video_path: str, input_subtitle_path: str, output_video_path: str, subtitle_language: str = 'ita', prefix: str = "single_sub") -> str:
|
||||||
"""
|
"""
|
||||||
Convert a video with a single subtitle.
|
Convert a video with a single subtitle.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user