mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 14:06:36 +00:00
Merge branch 'main' into patch-1
This commit is contained in:
commit
ed44838aa1
@ -339,7 +339,7 @@ def get_best_video_format(media):
|
|||||||
for fmt in video_formats:
|
for fmt in video_formats:
|
||||||
# Check for a codec, hdr and fps match but drop the resolution
|
# Check for a codec, hdr and fps match but drop the resolution
|
||||||
if (source_vcodec == fmt['vcodec'] and
|
if (source_vcodec == fmt['vcodec'] and
|
||||||
not fmt['is_hdr'] and fmt['is_60fps']):
|
not fmt['is_hdr'] and not fmt['is_60fps']):
|
||||||
# Close match
|
# Close match
|
||||||
exact_match, best_match = False, fmt
|
exact_match, best_match = False, fmt
|
||||||
break
|
break
|
||||||
|
@ -422,7 +422,7 @@ class Source(models.Model):
|
|||||||
help_text=_('List of subtitles langs to download, comma-separated. Example: en,fr or all,-fr,-live_chat'),
|
help_text=_('List of subtitles langs to download, comma-separated. Example: en,fr or all,-fr,-live_chat'),
|
||||||
validators=[
|
validators=[
|
||||||
RegexValidator(
|
RegexValidator(
|
||||||
regex=r"^(\-?[\_\.a-zA-Z]+,)*(\-?[\_\.a-zA-Z]+){1}$",
|
regex=r"^(\-?[\_\.a-zA-Z-]+(,|$))+",
|
||||||
message=_('Subtitle langs must be a comma-separated list of langs. example: en,fr or all,-fr,-live_chat')
|
message=_('Subtitle langs must be a comma-separated list of langs. example: en,fr or all,-fr,-live_chat')
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
@ -144,6 +144,21 @@ def multi_key_sort(sort_dict, specs, use_reversed=False):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_codec(codec_str):
|
||||||
|
result = str(codec_str).upper()
|
||||||
|
parts = result.split('.')
|
||||||
|
if len(parts) > 0:
|
||||||
|
result = parts[0].strip()
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
if 'NONE' == result:
|
||||||
|
return None
|
||||||
|
if str(0) in result:
|
||||||
|
prefix = result.rstrip('0123456789')
|
||||||
|
result = prefix + str(int(result[len(prefix):]))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def parse_media_format(format_dict):
|
def parse_media_format(format_dict):
|
||||||
'''
|
'''
|
||||||
This parser primarily adapts the format dict returned by youtube-dl into a
|
This parser primarily adapts the format dict returned by youtube-dl into a
|
||||||
@ -151,23 +166,9 @@ def parse_media_format(format_dict):
|
|||||||
any internals, update it here.
|
any internals, update it here.
|
||||||
'''
|
'''
|
||||||
vcodec_full = format_dict.get('vcodec', '')
|
vcodec_full = format_dict.get('vcodec', '')
|
||||||
vcodec_parts = vcodec_full.split('.')
|
vcodec = normalize_codec(vcodec_full)
|
||||||
if len(vcodec_parts) > 0:
|
|
||||||
vcodec = vcodec_parts[0].strip().upper()
|
|
||||||
else:
|
|
||||||
vcodec = None
|
|
||||||
if vcodec == 'NONE':
|
|
||||||
vcodec = None
|
|
||||||
if vcodec == 'VP09':
|
|
||||||
vcodec = 'VP9'
|
|
||||||
acodec_full = format_dict.get('acodec', '')
|
acodec_full = format_dict.get('acodec', '')
|
||||||
acodec_parts = acodec_full.split('.')
|
acodec = normalize_codec(acodec_full)
|
||||||
if len(acodec_parts) > 0:
|
|
||||||
acodec = acodec_parts[0].strip().upper()
|
|
||||||
else:
|
|
||||||
acodec = None
|
|
||||||
if acodec == 'NONE':
|
|
||||||
acodec = None
|
|
||||||
try:
|
try:
|
||||||
fps = int(format_dict.get('fps', 0))
|
fps = int(format_dict.get('fps', 0))
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
|
Loading…
Reference in New Issue
Block a user