mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 01:01:25 +01:00
Compare commits
3 Commits
f843d9026a
...
4539c7fb0d
Author | SHA1 | Date | |
---|---|---|---|
|
4539c7fb0d | ||
|
39d79c9b9c | ||
|
ed4d9a40c1 |
|
@ -525,7 +525,7 @@ class TestTraversalHelpers:
|
||||||
def test_unpack(self):
|
def test_unpack(self):
|
||||||
assert unpack(lambda *x: ''.join(map(str, x)))([1, 2, 3]) == '123'
|
assert unpack(lambda *x: ''.join(map(str, x)))([1, 2, 3]) == '123'
|
||||||
assert unpack(join_nonempty)([1, 2, 3]) == '1-2-3'
|
assert unpack(join_nonempty)([1, 2, 3]) == '1-2-3'
|
||||||
assert unpack(join_nonempty(delim=' '))([1, 2, 3]) == '1 2 3'
|
assert unpack(join_nonempty, delim=' ')([1, 2, 3]) == '1 2 3'
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
unpack(join_nonempty)()
|
unpack(join_nonempty)()
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
|
|
|
@ -72,7 +72,6 @@ from yt_dlp.utils import (
|
||||||
intlist_to_bytes,
|
intlist_to_bytes,
|
||||||
iri_to_uri,
|
iri_to_uri,
|
||||||
is_html,
|
is_html,
|
||||||
join_nonempty,
|
|
||||||
js_to_json,
|
js_to_json,
|
||||||
limit_length,
|
limit_length,
|
||||||
locked_file,
|
locked_file,
|
||||||
|
@ -2158,10 +2157,6 @@ Line 1
|
||||||
assert int_or_none(v=10) == 10, 'keyword passed positional should call function'
|
assert int_or_none(v=10) == 10, 'keyword passed positional should call function'
|
||||||
assert int_or_none(scale=0.1)(10) == 100, 'call after partial application should call the function'
|
assert int_or_none(scale=0.1)(10) == 100, 'call after partial application should call the function'
|
||||||
|
|
||||||
assert callable(join_nonempty(delim=', ')), 'varargs positional should apply partially'
|
|
||||||
assert callable(join_nonempty()), 'varargs positional should apply partially'
|
|
||||||
assert join_nonempty(None, delim=', ') == '', 'passed varargs should call the function'
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -5,6 +5,7 @@ import urllib.parse
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
determine_ext,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
mimetype2ext,
|
mimetype2ext,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
|
@ -268,7 +269,29 @@ class MediasiteIE(InfoExtractor):
|
||||||
formats.extend(stream_formats)
|
formats.extend(stream_formats)
|
||||||
|
|
||||||
# XXX: Presentation['Presenters']
|
# XXX: Presentation['Presenters']
|
||||||
# XXX: Presentation['Transcript']
|
transcripts = presentation.get('Transcripts', {})
|
||||||
|
captions, subtitles = {}, {}
|
||||||
|
for transcript in transcripts:
|
||||||
|
lang_code = traverse_obj(
|
||||||
|
transcript, (('DetailedLanguageCode', 'LanguageCode'), {str}), get_all=False)
|
||||||
|
lang_name = transcript.get('Language')
|
||||||
|
t = {
|
||||||
|
'url': transcript.get('CaptionsUrl'),
|
||||||
|
'name': lang_name,
|
||||||
|
}
|
||||||
|
if 'Auto-Generated' in lang_name:
|
||||||
|
captions.setdefault(lang_code, []).append(t)
|
||||||
|
else:
|
||||||
|
subtitles.setdefault(lang_code, []).append(t)
|
||||||
|
if transcript_url := presentation.get('TranscriptUrl'):
|
||||||
|
if determine_ext(transcript_url) != 'txt':
|
||||||
|
if len(transcripts) == 1 and captions:
|
||||||
|
captions.setdefault(lang_code, []).append({
|
||||||
|
'url': transcript_url,
|
||||||
|
'name': lang_name,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
subtitles.setdefault('und', []).append({'url': transcript_url})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': resource_id,
|
'id': resource_id,
|
||||||
|
@ -277,6 +300,8 @@ class MediasiteIE(InfoExtractor):
|
||||||
'duration': float_or_none(presentation.get('Duration'), 1000),
|
'duration': float_or_none(presentation.get('Duration'), 1000),
|
||||||
'timestamp': float_or_none(presentation.get('UnixTime'), 1000),
|
'timestamp': float_or_none(presentation.get('UnixTime'), 1000),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
'automatic_captions': captions,
|
||||||
|
'subtitles': subtitles,
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ def partial_application(func):
|
||||||
sig = inspect.signature(func)
|
sig = inspect.signature(func)
|
||||||
required_args = [
|
required_args = [
|
||||||
param.name for param in sig.parameters.values()
|
param.name for param in sig.parameters.values()
|
||||||
if param.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD, inspect.Parameter.VAR_POSITIONAL)
|
if param.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD)
|
||||||
if param.default is inspect.Parameter.empty
|
if param.default is inspect.Parameter.empty
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4837,7 +4837,6 @@ def number_of_digits(number):
|
||||||
return len('%d' % number)
|
return len('%d' % number)
|
||||||
|
|
||||||
|
|
||||||
@partial_application
|
|
||||||
def join_nonempty(*values, delim='-', from_dict=None):
|
def join_nonempty(*values, delim='-', from_dict=None):
|
||||||
if from_dict is not None:
|
if from_dict is not None:
|
||||||
values = (traversal.traverse_obj(from_dict, variadic(v)) for v in values)
|
values = (traversal.traverse_obj(from_dict, variadic(v)) for v in values)
|
||||||
|
|
|
@ -452,9 +452,9 @@ def trim_str(*, start=None, end=None):
|
||||||
return trim
|
return trim
|
||||||
|
|
||||||
|
|
||||||
def unpack(func):
|
def unpack(func, **kwargs):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def inner(items, **kwargs):
|
def inner(items):
|
||||||
return func(*items, **kwargs)
|
return func(*items, **kwargs)
|
||||||
|
|
||||||
return inner
|
return inner
|
||||||
|
|
Loading…
Reference in New Issue
Block a user