mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-25 16:51:26 +01:00
Compare commits
16 Commits
9361343a4c
...
c839381435
Author | SHA1 | Date | |
---|---|---|---|
|
c839381435 | ||
|
a330815af2 | ||
|
d5d1517e7d | ||
|
7e09c147fd | ||
|
e370f9ec36 | ||
|
b1a1ec1540 | ||
|
0b6f829b1d | ||
|
f98a3305eb | ||
|
04a5e06350 | ||
|
b03c89309e | ||
|
71f28097fe | ||
|
044886c220 | ||
|
993edd3f6e | ||
|
6a9c7a2b52 | ||
|
a174c453ee | ||
|
15f22b4880 |
|
@ -1268,7 +1268,7 @@ The field names themselves (the part inside the parenthesis) can also have some
|
||||||
|
|
||||||
1. **Object traversal**: The dictionaries and lists available in metadata can be traversed by using a dot `.` separator; e.g. `%(tags.0)s`, `%(subtitles.en.-1.ext)s`. You can do Python slicing with colon `:`; E.g. `%(id.3:7:-1)s`, `%(formats.:.format_id)s`. Curly braces `{}` can be used to build dictionaries with only specific keys; e.g. `%(formats.:.{format_id,height})#j`. An empty field name `%()s` refers to the entire infodict; e.g. `%(.{id,title})s`. Note that all the fields that become available using this method are not listed below. Use `-j` to see such fields
|
1. **Object traversal**: The dictionaries and lists available in metadata can be traversed by using a dot `.` separator; e.g. `%(tags.0)s`, `%(subtitles.en.-1.ext)s`. You can do Python slicing with colon `:`; E.g. `%(id.3:7:-1)s`, `%(formats.:.format_id)s`. Curly braces `{}` can be used to build dictionaries with only specific keys; e.g. `%(formats.:.{format_id,height})#j`. An empty field name `%()s` refers to the entire infodict; e.g. `%(.{id,title})s`. Note that all the fields that become available using this method are not listed below. Use `-j` to see such fields
|
||||||
|
|
||||||
1. **Addition**: Addition and subtraction of numeric fields can be done using `+` and `-` respectively. E.g. `%(playlist_index+10)03d`, `%(n_entries+1-playlist_index)d`
|
1. **Arithmetic**: Simple arithmetic can be done on numeric fields using `+`, `-` and `*`. E.g. `%(playlist_index+10)03d`, `%(n_entries+1-playlist_index)d`
|
||||||
|
|
||||||
1. **Date/time Formatting**: Date/time fields can be formatted according to [strftime formatting](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) by specifying it separated from the field name using a `>`. E.g. `%(duration>%H-%M-%S)s`, `%(upload_date>%Y-%m-%d)s`, `%(epoch-3600>%H-%M-%S)s`
|
1. **Date/time Formatting**: Date/time fields can be formatted according to [strftime formatting](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) by specifying it separated from the field name using a `>`. E.g. `%(duration>%H-%M-%S)s`, `%(upload_date>%Y-%m-%d)s`, `%(epoch-3600>%H-%M-%S)s`
|
||||||
|
|
||||||
|
@ -1333,6 +1333,7 @@ The available fields are:
|
||||||
- `was_live` (boolean): Whether this video was originally a live stream
|
- `was_live` (boolean): Whether this video was originally a live stream
|
||||||
- `playable_in_embed` (string): Whether this video is allowed to play in embedded players on other sites
|
- `playable_in_embed` (string): Whether this video is allowed to play in embedded players on other sites
|
||||||
- `availability` (string): Whether the video is "private", "premium_only", "subscriber_only", "needs_auth", "unlisted" or "public"
|
- `availability` (string): Whether the video is "private", "premium_only", "subscriber_only", "needs_auth", "unlisted" or "public"
|
||||||
|
- `media_type` (string): The type of media as classified by the site, e.g. "episode", "clip", "trailer"
|
||||||
- `start_time` (numeric): Time in seconds where the reproduction should start, as specified in the URL
|
- `start_time` (numeric): Time in seconds where the reproduction should start, as specified in the URL
|
||||||
- `end_time` (numeric): Time in seconds where the reproduction should end, as specified in the URL
|
- `end_time` (numeric): Time in seconds where the reproduction should end, as specified in the URL
|
||||||
- `extractor` (string): Name of the extractor
|
- `extractor` (string): Name of the extractor
|
||||||
|
|
|
@ -797,6 +797,7 @@ class TestYoutubeDL(unittest.TestCase):
|
||||||
test('%(title|%)s %(title|%%)s', '% %%')
|
test('%(title|%)s %(title|%%)s', '% %%')
|
||||||
test('%(id+1-height+3)05d', '00158')
|
test('%(id+1-height+3)05d', '00158')
|
||||||
test('%(width+100)05d', 'NA')
|
test('%(width+100)05d', 'NA')
|
||||||
|
test('%(filesize*8)d', '8192')
|
||||||
test('%(formats.0) 15s', ('% 15s' % FORMATS[0], None))
|
test('%(formats.0) 15s', ('% 15s' % FORMATS[0], None))
|
||||||
test('%(formats.0)r', (repr(FORMATS[0]), None))
|
test('%(formats.0)r', (repr(FORMATS[0]), None))
|
||||||
test('%(height.0)03d', '001')
|
test('%(height.0)03d', '001')
|
||||||
|
|
|
@ -2317,23 +2317,6 @@ Line 1
|
||||||
self.assertEqual(traverse_obj({}, (0, slice(1)), traverse_string=True), [],
|
self.assertEqual(traverse_obj({}, (0, slice(1)), traverse_string=True), [],
|
||||||
msg='branching should result in list if `traverse_string`')
|
msg='branching should result in list if `traverse_string`')
|
||||||
|
|
||||||
# Test is_user_input behavior
|
|
||||||
_IS_USER_INPUT_DATA = {'range8': list(range(8))}
|
|
||||||
self.assertEqual(traverse_obj(_IS_USER_INPUT_DATA, ('range8', '3'),
|
|
||||||
is_user_input=True), 3,
|
|
||||||
msg='allow for string indexing if `is_user_input`')
|
|
||||||
self.assertCountEqual(traverse_obj(_IS_USER_INPUT_DATA, ('range8', '3:'),
|
|
||||||
is_user_input=True), tuple(range(8))[3:],
|
|
||||||
msg='allow for string slice if `is_user_input`')
|
|
||||||
self.assertCountEqual(traverse_obj(_IS_USER_INPUT_DATA, ('range8', ':4:2'),
|
|
||||||
is_user_input=True), tuple(range(8))[:4:2],
|
|
||||||
msg='allow step in string slice if `is_user_input`')
|
|
||||||
self.assertCountEqual(traverse_obj(_IS_USER_INPUT_DATA, ('range8', ':'),
|
|
||||||
is_user_input=True), range(8),
|
|
||||||
msg='`:` should be treated as `...` if `is_user_input`')
|
|
||||||
with self.assertRaises(TypeError, msg='too many params should result in error'):
|
|
||||||
traverse_obj(_IS_USER_INPUT_DATA, ('range8', ':::'), is_user_input=True)
|
|
||||||
|
|
||||||
# Test re.Match as input obj
|
# Test re.Match as input obj
|
||||||
mobj = re.fullmatch(r'0(12)(?P<group>3)(4)?', '0123')
|
mobj = re.fullmatch(r'0(12)(?P<group>3)(4)?', '0123')
|
||||||
self.assertEqual(traverse_obj(mobj, ...), [x for x in mobj.groups() if x is not None],
|
self.assertEqual(traverse_obj(mobj, ...), [x for x in mobj.groups() if x is not None],
|
||||||
|
|
|
@ -1179,6 +1179,7 @@ class YoutubeDL:
|
||||||
MATH_FUNCTIONS = {
|
MATH_FUNCTIONS = {
|
||||||
'+': float.__add__,
|
'+': float.__add__,
|
||||||
'-': float.__sub__,
|
'-': float.__sub__,
|
||||||
|
'*': float.__mul__,
|
||||||
}
|
}
|
||||||
# Field is of the form key1.key2...
|
# Field is of the form key1.key2...
|
||||||
# where keys (except first) can be string, int, slice or "{field, ...}"
|
# where keys (except first) can be string, int, slice or "{field, ...}"
|
||||||
|
@ -1200,6 +1201,15 @@ class YoutubeDL:
|
||||||
(?:\|(?P<default>.*?))?
|
(?:\|(?P<default>.*?))?
|
||||||
)$''')
|
)$''')
|
||||||
|
|
||||||
|
def _from_user_input(field):
|
||||||
|
if field == ':':
|
||||||
|
return ...
|
||||||
|
elif ':' in field:
|
||||||
|
return slice(*map(int_or_none, field.split(':')))
|
||||||
|
elif int_or_none(field) is not None:
|
||||||
|
return int(field)
|
||||||
|
return field
|
||||||
|
|
||||||
def _traverse_infodict(fields):
|
def _traverse_infodict(fields):
|
||||||
fields = [f for x in re.split(r'\.({.+?})\.?', fields)
|
fields = [f for x in re.split(r'\.({.+?})\.?', fields)
|
||||||
for f in ([x] if x.startswith('{') else x.split('.'))]
|
for f in ([x] if x.startswith('{') else x.split('.'))]
|
||||||
|
@ -1209,11 +1219,12 @@ class YoutubeDL:
|
||||||
|
|
||||||
for i, f in enumerate(fields):
|
for i, f in enumerate(fields):
|
||||||
if not f.startswith('{'):
|
if not f.startswith('{'):
|
||||||
|
fields[i] = _from_user_input(f)
|
||||||
continue
|
continue
|
||||||
assert f.endswith('}'), f'No closing brace for {f} in {fields}'
|
assert f.endswith('}'), f'No closing brace for {f} in {fields}'
|
||||||
fields[i] = {k: k.split('.') for k in f[1:-1].split(',')}
|
fields[i] = {k: list(map(_from_user_input, k.split('.'))) for k in f[1:-1].split(',')}
|
||||||
|
|
||||||
return traverse_obj(info_dict, fields, is_user_input=True, traverse_string=True)
|
return traverse_obj(info_dict, fields, traverse_string=True)
|
||||||
|
|
||||||
def get_value(mdict):
|
def get_value(mdict):
|
||||||
# Object traversal
|
# Object traversal
|
||||||
|
|
|
@ -73,14 +73,16 @@ def _exit(status=0, *args):
|
||||||
|
|
||||||
|
|
||||||
def get_urls(urls, batchfile, verbose):
|
def get_urls(urls, batchfile, verbose):
|
||||||
# Batch file verification
|
"""
|
||||||
|
@param verbose -1: quiet, 0: normal, 1: verbose
|
||||||
|
"""
|
||||||
batch_urls = []
|
batch_urls = []
|
||||||
if batchfile is not None:
|
if batchfile is not None:
|
||||||
try:
|
try:
|
||||||
batch_urls = read_batch_urls(
|
batch_urls = read_batch_urls(
|
||||||
read_stdin('URLs') if batchfile == '-'
|
read_stdin(None if verbose == -1 else 'URLs') if batchfile == '-'
|
||||||
else open(expand_path(batchfile), encoding='utf-8', errors='ignore'))
|
else open(expand_path(batchfile), encoding='utf-8', errors='ignore'))
|
||||||
if verbose:
|
if verbose == 1:
|
||||||
write_string('[debug] Batch file urls: ' + repr(batch_urls) + '\n')
|
write_string('[debug] Batch file urls: ' + repr(batch_urls) + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
_exit(f'ERROR: batch file {batchfile} could not be read')
|
_exit(f'ERROR: batch file {batchfile} could not be read')
|
||||||
|
@ -721,7 +723,7 @@ ParsedOptions = collections.namedtuple('ParsedOptions', ('parser', 'options', 'u
|
||||||
def parse_options(argv=None):
|
def parse_options(argv=None):
|
||||||
"""@returns ParsedOptions(parser, opts, urls, ydl_opts)"""
|
"""@returns ParsedOptions(parser, opts, urls, ydl_opts)"""
|
||||||
parser, opts, urls = parseOpts(argv)
|
parser, opts, urls = parseOpts(argv)
|
||||||
urls = get_urls(urls, opts.batchfile, opts.verbose)
|
urls = get_urls(urls, opts.batchfile, -1 if opts.quiet and not opts.verbose else opts.verbose)
|
||||||
|
|
||||||
set_compat_opts(opts)
|
set_compat_opts(opts)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -121,11 +121,21 @@ class AENetworksIE(AENetworksBaseIE):
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '22253814',
|
'id': '22253814',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Winter is Coming',
|
'title': 'Winter Is Coming',
|
||||||
'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
|
'description': 'md5:a40e370925074260b1c8a633c632c63a',
|
||||||
'timestamp': 1338306241,
|
'timestamp': 1338306241,
|
||||||
'upload_date': '20120529',
|
'upload_date': '20120529',
|
||||||
'uploader': 'AENE-NEW',
|
'uploader': 'AENE-NEW',
|
||||||
|
'duration': 2592.0,
|
||||||
|
'thumbnail': r're:^https?://.*\.jpe?g$',
|
||||||
|
'chapters': 'count:5',
|
||||||
|
'tags': 'count:14',
|
||||||
|
'categories': ['Mountain Men'],
|
||||||
|
'episode_number': 1,
|
||||||
|
'episode': 'Episode 1',
|
||||||
|
'season': 'Season 1',
|
||||||
|
'season_number': 1,
|
||||||
|
'series': 'Mountain Men',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
# m3u8 download
|
# m3u8 download
|
||||||
|
@ -143,6 +153,15 @@ class AENetworksIE(AENetworksBaseIE):
|
||||||
'timestamp': 1452634428,
|
'timestamp': 1452634428,
|
||||||
'upload_date': '20160112',
|
'upload_date': '20160112',
|
||||||
'uploader': 'AENE-NEW',
|
'uploader': 'AENE-NEW',
|
||||||
|
'duration': 1277.695,
|
||||||
|
'thumbnail': r're:^https?://.*\.jpe?g$',
|
||||||
|
'chapters': 'count:4',
|
||||||
|
'tags': 'count:23',
|
||||||
|
'episode': 'Episode 1',
|
||||||
|
'episode_number': 1,
|
||||||
|
'season': 'Season 9',
|
||||||
|
'season_number': 9,
|
||||||
|
'series': 'Duck Dynasty',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
# m3u8 download
|
# m3u8 download
|
||||||
|
|
|
@ -7,8 +7,10 @@ from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
OnDemandPagedList,
|
OnDemandPagedList,
|
||||||
clean_html,
|
clean_html,
|
||||||
|
extract_attributes,
|
||||||
get_element_by_class,
|
get_element_by_class,
|
||||||
get_element_by_id,
|
get_element_by_id,
|
||||||
|
get_element_html_by_class,
|
||||||
get_elements_html_by_class,
|
get_elements_html_by_class,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
|
@ -17,6 +19,7 @@ from ..utils import (
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
|
urljoin,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +37,25 @@ class BitChuteIE(InfoExtractor):
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'uploader': 'BitChute',
|
'uploader': 'BitChute',
|
||||||
'upload_date': '20170103',
|
'upload_date': '20170103',
|
||||||
|
'uploader_url': 'https://www.bitchute.com/profile/I5NgtHZn9vPj/',
|
||||||
|
'channel': 'BitChute',
|
||||||
|
'channel_url': 'https://www.bitchute.com/channel/bitchute/'
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
# test case: video with different channel and uploader
|
||||||
|
'url': 'https://www.bitchute.com/video/Yti_j9A-UZ4/',
|
||||||
|
'md5': 'f10e6a8e787766235946d0868703f1d0',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'Yti_j9A-UZ4',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Israel at War | Full Measure',
|
||||||
|
'description': 'md5:38cf7bc6f42da1a877835539111c69ef',
|
||||||
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
|
'uploader': 'sharylattkisson',
|
||||||
|
'upload_date': '20231106',
|
||||||
|
'uploader_url': 'https://www.bitchute.com/profile/9K0kUWA9zmd9/',
|
||||||
|
'channel': 'Full Measure with Sharyl Attkisson',
|
||||||
|
'channel_url': 'https://www.bitchute.com/channel/sharylattkisson/'
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# video not downloadable in browser, but we can recover it
|
# video not downloadable in browser, but we can recover it
|
||||||
|
@ -48,6 +70,9 @@ class BitChuteIE(InfoExtractor):
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'uploader': 'BitChute',
|
'uploader': 'BitChute',
|
||||||
'upload_date': '20181113',
|
'upload_date': '20181113',
|
||||||
|
'uploader_url': 'https://www.bitchute.com/profile/I5NgtHZn9vPj/',
|
||||||
|
'channel': 'BitChute',
|
||||||
|
'channel_url': 'https://www.bitchute.com/channel/bitchute/'
|
||||||
},
|
},
|
||||||
'params': {'check_formats': None},
|
'params': {'check_formats': None},
|
||||||
}, {
|
}, {
|
||||||
|
@ -99,6 +124,11 @@ class BitChuteIE(InfoExtractor):
|
||||||
reason = clean_html(get_element_by_id('page-detail', webpage)) or page_title
|
reason = clean_html(get_element_by_id('page-detail', webpage)) or page_title
|
||||||
self.raise_geo_restricted(reason)
|
self.raise_geo_restricted(reason)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _make_url(html):
|
||||||
|
path = extract_attributes(get_element_html_by_class('spa', html) or '').get('href')
|
||||||
|
return urljoin('https://www.bitchute.com', path)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(
|
webpage = self._download_webpage(
|
||||||
|
@ -121,12 +151,19 @@ class BitChuteIE(InfoExtractor):
|
||||||
'Video is unavailable. Please make sure this video is playable in the browser '
|
'Video is unavailable. Please make sure this video is playable in the browser '
|
||||||
'before reporting this issue.', expected=True, video_id=video_id)
|
'before reporting this issue.', expected=True, video_id=video_id)
|
||||||
|
|
||||||
|
details = get_element_by_class('details', webpage) or ''
|
||||||
|
uploader_html = get_element_html_by_class('creator', details) or ''
|
||||||
|
channel_html = get_element_html_by_class('name', details) or ''
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': self._html_extract_title(webpage) or self._og_search_title(webpage),
|
'title': self._html_extract_title(webpage) or self._og_search_title(webpage),
|
||||||
'description': self._og_search_description(webpage, default=None),
|
'description': self._og_search_description(webpage, default=None),
|
||||||
'thumbnail': self._og_search_thumbnail(webpage),
|
'thumbnail': self._og_search_thumbnail(webpage),
|
||||||
'uploader': clean_html(get_element_by_class('owner', webpage)),
|
'uploader': clean_html(uploader_html),
|
||||||
|
'uploader_url': self._make_url(uploader_html),
|
||||||
|
'channel': clean_html(channel_html),
|
||||||
|
'channel_url': self._make_url(channel_html),
|
||||||
'upload_date': unified_strdate(self._search_regex(
|
'upload_date': unified_strdate(self._search_regex(
|
||||||
r'at \d+:\d+ UTC on (.+?)\.', publish_date, 'upload date', fatal=False)),
|
r'at \d+:\d+ UTC on (.+?)\.', publish_date, 'upload date', fatal=False)),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
@ -154,6 +191,9 @@ class BitChuteChannelIE(InfoExtractor):
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'uploader': 'BitChute',
|
'uploader': 'BitChute',
|
||||||
'upload_date': '20170103',
|
'upload_date': '20170103',
|
||||||
|
'uploader_url': 'https://www.bitchute.com/profile/I5NgtHZn9vPj/',
|
||||||
|
'channel': 'BitChute',
|
||||||
|
'channel_url': 'https://www.bitchute.com/channel/bitchute/',
|
||||||
'duration': 16,
|
'duration': 16,
|
||||||
'view_count': int,
|
'view_count': int,
|
||||||
},
|
},
|
||||||
|
@ -169,7 +209,7 @@ class BitChuteChannelIE(InfoExtractor):
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'wV9Imujxasw9',
|
'id': 'wV9Imujxasw9',
|
||||||
'title': 'Bruce MacDonald and "The Light of Darkness"',
|
'title': 'Bruce MacDonald and "The Light of Darkness"',
|
||||||
'description': 'md5:04913227d2714af1d36d804aa2ab6b1e',
|
'description': 'md5:747724ef404eebdfc04277714f81863e',
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,13 @@ class CBCPlayerIE(InfoExtractor):
|
||||||
'thumbnail': 'http://thumbnails.cbc.ca/maven_legacy/thumbnails/sonali-karnick-220.jpg',
|
'thumbnail': 'http://thumbnails.cbc.ca/maven_legacy/thumbnails/sonali-karnick-220.jpg',
|
||||||
'chapters': [],
|
'chapters': [],
|
||||||
'duration': 494.811,
|
'duration': 494.811,
|
||||||
|
'categories': ['AudioMobile/All in a Weekend Montreal'],
|
||||||
|
'tags': 'count:8',
|
||||||
|
'location': 'Quebec',
|
||||||
|
'series': 'All in a Weekend Montreal',
|
||||||
|
'season': 'Season 2015',
|
||||||
|
'season_number': 2015,
|
||||||
|
'media_type': 'Excerpt',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.cbc.ca/player/play/2164402062',
|
'url': 'http://www.cbc.ca/player/play/2164402062',
|
||||||
|
@ -195,25 +202,37 @@ class CBCPlayerIE(InfoExtractor):
|
||||||
'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/277/67/cancer_852x480_2164412612.jpg',
|
'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/277/67/cancer_852x480_2164412612.jpg',
|
||||||
'chapters': [],
|
'chapters': [],
|
||||||
'duration': 186.867,
|
'duration': 186.867,
|
||||||
|
'series': 'CBC News: Windsor at 6:00',
|
||||||
|
'categories': ['News/Canada/Windsor'],
|
||||||
|
'location': 'Windsor',
|
||||||
|
'tags': ['cancer'],
|
||||||
|
'creator': 'Allison Johnson',
|
||||||
|
'media_type': 'Excerpt',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# Has subtitles
|
# Has subtitles
|
||||||
# These broadcasts expire after ~1 month, can find new test URL here:
|
# These broadcasts expire after ~1 month, can find new test URL here:
|
||||||
# https://www.cbc.ca/player/news/TV%20Shows/The%20National/Latest%20Broadcast
|
# https://www.cbc.ca/player/news/TV%20Shows/The%20National/Latest%20Broadcast
|
||||||
'url': 'http://www.cbc.ca/player/play/2249992771553',
|
'url': 'http://www.cbc.ca/player/play/2284799043667',
|
||||||
'md5': '2f2fb675dd4f0f8a5bb7588d1b13bacd',
|
'md5': '9b49f0839e88b6ec0b01d840cf3d42b5',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '2249992771553',
|
'id': '2284799043667',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'The National | Women’s soccer pay, Florida seawater, Swift quake',
|
'title': 'The National | Hockey coach charged, Green grants, Safer drugs',
|
||||||
'description': 'md5:adba28011a56cfa47a080ff198dad27a',
|
'description': 'md5:84ef46321c94bcf7d0159bb565d26bfa',
|
||||||
'timestamp': 1690596000,
|
'timestamp': 1700272800,
|
||||||
'duration': 2716.333,
|
'duration': 2718.833,
|
||||||
'subtitles': {'eng': [{'ext': 'vtt', 'protocol': 'm3u8_native'}]},
|
'subtitles': {'eng': [{'ext': 'vtt', 'protocol': 'm3u8_native'}]},
|
||||||
'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/481/326/thumbnail.jpeg',
|
'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/907/171/thumbnail.jpeg',
|
||||||
'uploader': 'CBCC-NEW',
|
'uploader': 'CBCC-NEW',
|
||||||
'chapters': 'count:5',
|
'chapters': 'count:5',
|
||||||
'upload_date': '20230729',
|
'upload_date': '20231118',
|
||||||
|
'categories': 'count:4',
|
||||||
|
'series': 'The National - Full Show',
|
||||||
|
'tags': 'count:1',
|
||||||
|
'creator': 'News',
|
||||||
|
'location': 'Canada',
|
||||||
|
'media_type': 'Full Program',
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
|
@ -382,6 +382,7 @@ class InfoExtractor:
|
||||||
'private', 'premium_only', 'subscriber_only', 'needs_auth',
|
'private', 'premium_only', 'subscriber_only', 'needs_auth',
|
||||||
'unlisted' or 'public'. Use 'InfoExtractor._availability'
|
'unlisted' or 'public'. Use 'InfoExtractor._availability'
|
||||||
to set it
|
to set it
|
||||||
|
media_type: The type of media as classified by the site, e.g. "episode", "clip", "trailer"
|
||||||
_old_archive_ids: A list of old archive ids needed for backward compatibility
|
_old_archive_ids: A list of old archive ids needed for backward compatibility
|
||||||
_format_sort_fields: A list of fields to use for sorting formats
|
_format_sort_fields: A list of fields to use for sorting formats
|
||||||
__post_extractor: A function to be called just before the metadata is
|
__post_extractor: A function to be called just before the metadata is
|
||||||
|
|
|
@ -46,6 +46,10 @@ class CWTVIE(InfoExtractor):
|
||||||
'timestamp': 1444107300,
|
'timestamp': 1444107300,
|
||||||
'age_limit': 14,
|
'age_limit': 14,
|
||||||
'uploader': 'CWTV',
|
'uploader': 'CWTV',
|
||||||
|
'thumbnail': r're:^https?://.*\.jpe?g$',
|
||||||
|
'chapters': 'count:4',
|
||||||
|
'episode': 'Episode 20',
|
||||||
|
'season': 'Season 11',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
# m3u8 download
|
# m3u8 download
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
try_call,
|
try_call,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class EplusIbIE(InfoExtractor):
|
class EplusIbIE(InfoExtractor):
|
||||||
IE_NAME = 'eplus:inbound'
|
_NETRC_MACHINE = 'eplus'
|
||||||
IE_DESC = 'e+ (イープラス) overseas'
|
IE_NAME = 'eplus'
|
||||||
_VALID_URL = r'https?://live\.eplus\.jp/ex/player\?ib=(?P<id>(?:\w|%2B|%2F){86}%3D%3D)'
|
IE_DESC = 'e+ (イープラス)'
|
||||||
|
_VALID_URL = [r'https?://live\.eplus\.jp/ex/player\?ib=(?P<id>(?:\w|%2B|%2F){86}%3D%3D)',
|
||||||
|
r'https?://live\.eplus\.jp/(?P<id>sample|\d+)']
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://live.eplus.jp/ex/player?ib=YEFxb3Vyc2Dombnjg7blkrLlrablnJLjgrnjgq%2Fjg7zjg6vjgqLjgqTjg4njg6vlkIzlpb3kvJpgTGllbGxhIQ%3D%3D',
|
'url': 'https://live.eplus.jp/ex/player?ib=YEFxb3Vyc2Dombnjg7blkrLlrablnJLjgrnjgq%2Fjg7zjg6vjgqLjgqTjg4njg6vlkIzlpb3kvJpgTGllbGxhIQ%3D%3D',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -29,14 +34,97 @@ class EplusIbIE(InfoExtractor):
|
||||||
'No video formats found!',
|
'No video formats found!',
|
||||||
'Requested format is not available',
|
'Requested format is not available',
|
||||||
],
|
],
|
||||||
|
}, {
|
||||||
|
'url': 'https://live.eplus.jp/sample',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'stream1ng20210719-test-005',
|
||||||
|
'title': 'Online streaming test for DRM',
|
||||||
|
'live_status': 'was_live',
|
||||||
|
'release_date': '20210719',
|
||||||
|
'release_timestamp': 1626703200,
|
||||||
|
'description': None,
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
'ignore_no_formats_error': True,
|
||||||
|
},
|
||||||
|
'expected_warnings': [
|
||||||
|
'Could not find the playlist URL. This event may not be accessible',
|
||||||
|
'No video formats found!',
|
||||||
|
'Requested format is not available',
|
||||||
|
'This video is DRM protected',
|
||||||
|
],
|
||||||
|
}, {
|
||||||
|
'url': 'https://live.eplus.jp/2053935',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '331320-0001-001',
|
||||||
|
'title': '丘みどり2020配信LIVE Vol.2 ~秋麗~ 【Streaming+(配信チケット)】',
|
||||||
|
'live_status': 'was_live',
|
||||||
|
'release_date': '20200920',
|
||||||
|
'release_timestamp': 1600596000,
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
'ignore_no_formats_error': True,
|
||||||
|
},
|
||||||
|
'expected_warnings': [
|
||||||
|
'Could not find the playlist URL. This event may not be accessible',
|
||||||
|
'No video formats found!',
|
||||||
|
'Requested format is not available',
|
||||||
|
],
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0'
|
||||||
|
|
||||||
|
def _login(self, username, password, urlh):
|
||||||
|
if not self._get_cookies('https://live.eplus.jp/').get('ci_session'):
|
||||||
|
raise ExtractorError('Unable to get ci_session cookie')
|
||||||
|
|
||||||
|
cltft_token = urlh.headers.get('X-CLTFT-Token')
|
||||||
|
if not cltft_token:
|
||||||
|
raise ExtractorError('Unable to get X-CLTFT-Token')
|
||||||
|
self._set_cookie('live.eplus.jp', 'X-CLTFT-Token', cltft_token)
|
||||||
|
|
||||||
|
login_json = self._download_json(
|
||||||
|
'https://live.eplus.jp/member/api/v1/FTAuth/idpw', None,
|
||||||
|
note='Sending pre-login info', errnote='Unable to send pre-login info', headers={
|
||||||
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
|
'Referer': urlh.url,
|
||||||
|
'X-Cltft-Token': cltft_token,
|
||||||
|
'Accept': '*/*',
|
||||||
|
}, data=json.dumps({
|
||||||
|
'loginId': username,
|
||||||
|
'loginPassword': password,
|
||||||
|
}).encode())
|
||||||
|
if not login_json.get('isSuccess'):
|
||||||
|
raise ExtractorError('Login failed: Invalid id or password', expected=True)
|
||||||
|
|
||||||
|
self._request_webpage(
|
||||||
|
urlh.url, None, note='Logging in', errnote='Unable to log in',
|
||||||
|
data=urlencode_postdata({
|
||||||
|
'loginId': username,
|
||||||
|
'loginPassword': password,
|
||||||
|
'Token.Default': cltft_token,
|
||||||
|
'op': 'nextPage',
|
||||||
|
}), headers={'Referer': urlh.url})
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage, urlh = self._download_webpage_handle(
|
||||||
|
url, video_id, headers={'User-Agent': self._USER_AGENT})
|
||||||
|
if urlh.url.startswith('https://live.eplus.jp/member/auth'):
|
||||||
|
username, password = self._get_login_info()
|
||||||
|
if not username:
|
||||||
|
self.raise_login_required()
|
||||||
|
self._login(username, password, urlh)
|
||||||
|
webpage = self._download_webpage(
|
||||||
|
url, video_id, headers={'User-Agent': self._USER_AGENT})
|
||||||
|
|
||||||
data_json = self._search_json(r'<script>\s*var app\s*=', webpage, 'data json', video_id)
|
data_json = self._search_json(r'<script>\s*var app\s*=', webpage, 'data json', video_id)
|
||||||
|
|
||||||
|
if data_json.get('drm_mode') == 'ON':
|
||||||
|
self.report_drm(video_id)
|
||||||
|
|
||||||
delivery_status = data_json.get('delivery_status')
|
delivery_status = data_json.get('delivery_status')
|
||||||
archive_mode = data_json.get('archive_mode')
|
archive_mode = data_json.get('archive_mode')
|
||||||
release_timestamp = try_call(lambda: unified_timestamp(data_json['event_datetime']) - 32400)
|
release_timestamp = try_call(lambda: unified_timestamp(data_json['event_datetime']) - 32400)
|
||||||
|
@ -64,7 +152,7 @@ class EplusIbIE(InfoExtractor):
|
||||||
formats = []
|
formats = []
|
||||||
|
|
||||||
m3u8_playlist_urls = self._search_json(
|
m3u8_playlist_urls = self._search_json(
|
||||||
r'var listChannels\s*=', webpage, 'hls URLs', video_id, contains_pattern=r'\[.+\]', default=[])
|
r'var\s+listChannels\s*=', webpage, 'hls URLs', video_id, contains_pattern=r'\[.+\]', default=[])
|
||||||
if not m3u8_playlist_urls:
|
if not m3u8_playlist_urls:
|
||||||
if live_status == 'is_upcoming':
|
if live_status == 'is_upcoming':
|
||||||
self.raise_no_formats(
|
self.raise_no_formats(
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from .dailymotion import DailymotionIE
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_ext,
|
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
determine_ext,
|
||||||
format_field,
|
format_field,
|
||||||
|
int_or_none,
|
||||||
|
join_nonempty,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
parse_qs,
|
parse_qs,
|
||||||
)
|
)
|
||||||
from .dailymotion import DailymotionIE
|
|
||||||
|
|
||||||
|
|
||||||
class FranceTVBaseInfoExtractor(InfoExtractor):
|
class FranceTVBaseInfoExtractor(InfoExtractor):
|
||||||
|
@ -82,6 +84,8 @@ class FranceTVIE(InfoExtractor):
|
||||||
videos = []
|
videos = []
|
||||||
title = None
|
title = None
|
||||||
subtitle = None
|
subtitle = None
|
||||||
|
episode_number = None
|
||||||
|
season_number = None
|
||||||
image = None
|
image = None
|
||||||
duration = None
|
duration = None
|
||||||
timestamp = None
|
timestamp = None
|
||||||
|
@ -112,7 +116,9 @@ class FranceTVIE(InfoExtractor):
|
||||||
if meta:
|
if meta:
|
||||||
if title is None:
|
if title is None:
|
||||||
title = meta.get('title')
|
title = meta.get('title')
|
||||||
# XXX: what is meta['pre_title']?
|
# meta['pre_title'] contains season and episode number for series in format "S<ID> E<ID>"
|
||||||
|
season_number, episode_number = self._search_regex(
|
||||||
|
r'S(\d+)\s*E(\d+)', meta.get('pre_title'), 'episode info', group=(1, 2), default=(None, None))
|
||||||
if subtitle is None:
|
if subtitle is None:
|
||||||
subtitle = meta.get('additional_title')
|
subtitle = meta.get('additional_title')
|
||||||
if image is None:
|
if image is None:
|
||||||
|
@ -191,19 +197,19 @@ class FranceTVIE(InfoExtractor):
|
||||||
} for sheet in spritesheets]
|
} for sheet in spritesheets]
|
||||||
})
|
})
|
||||||
|
|
||||||
if subtitle:
|
|
||||||
title += ' - %s' % subtitle
|
|
||||||
title = title.strip()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': join_nonempty(title, subtitle, delim=' - ').strip(),
|
||||||
'thumbnail': image,
|
'thumbnail': image,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
'is_live': is_live,
|
'is_live': is_live,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
|
'episode': subtitle if episode_number else None,
|
||||||
|
'series': title if episode_number else None,
|
||||||
|
'episode_number': int_or_none(episode_number),
|
||||||
|
'season_number': int_or_none(season_number),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
@ -230,14 +236,31 @@ class FranceTVSiteIE(FranceTVBaseInfoExtractor):
|
||||||
'id': 'ec217ecc-0733-48cf-ac06-af1347b849d1',
|
'id': 'ec217ecc-0733-48cf-ac06-af1347b849d1',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': '13h15, le dimanche... - Les mystères de Jésus',
|
'title': '13h15, le dimanche... - Les mystères de Jésus',
|
||||||
'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42',
|
|
||||||
'timestamp': 1502623500,
|
'timestamp': 1502623500,
|
||||||
|
'duration': 2580,
|
||||||
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'upload_date': '20170813',
|
'upload_date': '20170813',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
'add_ie': [FranceTVIE.ie_key()],
|
'add_ie': [FranceTVIE.ie_key()],
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.france.tv/enfants/six-huit-ans/foot2rue/saison-1/3066387-duel-au-vieux-port.html',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'a9050959-eedd-4b4a-9b0d-de6eeaa73e44',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Foot2Rue - Duel au vieux port',
|
||||||
|
'episode': 'Duel au vieux port',
|
||||||
|
'series': 'Foot2Rue',
|
||||||
|
'episode_number': 1,
|
||||||
|
'season_number': 1,
|
||||||
|
'timestamp': 1642761360,
|
||||||
|
'upload_date': '20220121',
|
||||||
|
'season': 'Season 1',
|
||||||
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
|
'duration': 1441,
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
# france3
|
# france3
|
||||||
'url': 'https://www.france.tv/france-3/des-chiffres-et-des-lettres/139063-emission-du-mardi-9-mai-2017.html',
|
'url': 'https://www.france.tv/france-3/des-chiffres-et-des-lettres/139063-emission-du-mardi-9-mai-2017.html',
|
||||||
|
|
|
@ -12,8 +12,7 @@ from ..utils import (
|
||||||
|
|
||||||
class JoqrAgIE(InfoExtractor):
|
class JoqrAgIE(InfoExtractor):
|
||||||
IE_DESC = '超!A&G+ 文化放送 Nippon Cultural Broadcasting, Inc. (JOQR, AGQR)'
|
IE_DESC = '超!A&G+ 文化放送 Nippon Cultural Broadcasting, Inc. (JOQR, AGQR)'
|
||||||
_VALID_URL = [r'https?://www\.uniqueradio\.jp/agplayer5/player\.php',
|
_VALID_URL = [r'https?://www\.uniqueradio\.jp/agplayer5/(?:player|inc-player-hls)\.php',
|
||||||
r'https?://www\.uniqueradio\.jp/agplayer5/inc-player-hls\.php',
|
|
||||||
r'https?://(?:www\.)?joqr\.co\.jp/ag/',
|
r'https?://(?:www\.)?joqr\.co\.jp/ag/',
|
||||||
r'https?://(?:www\.)?joqr\.co\.jp/qr/ag(?:daily|regular)program/?(?:$|[#?])']
|
r'https?://(?:www\.)?joqr\.co\.jp/qr/ag(?:daily|regular)program/?(?:$|[#?])']
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
@ -44,22 +43,22 @@ class JoqrAgIE(InfoExtractor):
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _extract_metadata(self, variable, html, name):
|
def _extract_metadata(self, variable, html):
|
||||||
return clean_html(urllib.parse.unquote_plus(self._search_regex(
|
return clean_html(urllib.parse.unquote_plus(self._search_regex(
|
||||||
rf'var\s+{variable}\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
|
rf'var\s+{variable}\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
|
||||||
html, name, group='value', default=''))) or None
|
html, 'metadata', group='value', default=''))) or None
|
||||||
|
|
||||||
def _extract_start_timestamp(self, video_id, is_live):
|
def _extract_start_timestamp(self, video_id, is_live):
|
||||||
def extract_start_time_from(date_str):
|
def extract_start_time_from(date_str):
|
||||||
dt = datetime_from_str(date_str) + datetime.timedelta(hours=9)
|
dt = datetime_from_str(date_str) + datetime.timedelta(hours=9)
|
||||||
date = dt.strftime('%Y%m%d')
|
date = dt.strftime('%Y%m%d')
|
||||||
start_time = self._search_regex(
|
start_time = self._search_regex(
|
||||||
r'<h3[^>]+\bclass="dailyProgram-itemHeaderTime"[^>]*>[\s\d:]+–\s*(?P<time>\d{1,2}:\d{1,2})',
|
r'<h3[^>]+\bclass="dailyProgram-itemHeaderTime"[^>]*>[\s\d:]+–\s*(\d{1,2}:\d{1,2})',
|
||||||
self._download_webpage(
|
self._download_webpage(
|
||||||
f'https://www.joqr.co.jp/qr/agdailyprogram/?date={date}', video_id,
|
f'https://www.joqr.co.jp/qr/agdailyprogram/?date={date}', video_id,
|
||||||
note=f'Downloading program list of {date}', fatal=False,
|
note=f'Downloading program list of {date}', fatal=False,
|
||||||
errnote=f'Failed to download program list of {date}') or '',
|
errnote=f'Failed to download program list of {date}') or '',
|
||||||
'start time of the first program', default=None, group='time')
|
'start time', default=None)
|
||||||
if start_time:
|
if start_time:
|
||||||
return unified_timestamp(f'{dt.strftime("%Y/%m/%d")} {start_time} +09:00')
|
return unified_timestamp(f'{dt.strftime("%Y/%m/%d")} {start_time} +09:00')
|
||||||
return None
|
return None
|
||||||
|
@ -79,7 +78,7 @@ class JoqrAgIE(InfoExtractor):
|
||||||
metadata = self._download_webpage(
|
metadata = self._download_webpage(
|
||||||
'https://www.uniqueradio.jp/aandg', video_id,
|
'https://www.uniqueradio.jp/aandg', video_id,
|
||||||
note='Downloading metadata', errnote='Failed to download metadata')
|
note='Downloading metadata', errnote='Failed to download metadata')
|
||||||
title = self._extract_metadata('Program_name', metadata, 'program title')
|
title = self._extract_metadata('Program_name', metadata)
|
||||||
|
|
||||||
if title == '放送休止':
|
if title == '放送休止':
|
||||||
formats = []
|
formats = []
|
||||||
|
@ -106,7 +105,7 @@ class JoqrAgIE(InfoExtractor):
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'channel': '超!A&G+',
|
'channel': '超!A&G+',
|
||||||
'description': self._extract_metadata('Program_text', metadata, 'program description'),
|
'description': self._extract_metadata('Program_text', metadata),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'live_status': live_status,
|
'live_status': live_status,
|
||||||
'release_timestamp': release_timestamp,
|
'release_timestamp': release_timestamp,
|
||||||
|
|
|
@ -73,6 +73,7 @@ class MediasetIE(ThePlatformBaseIE):
|
||||||
'season_number': 5,
|
'season_number': 5,
|
||||||
'episode_number': 5,
|
'episode_number': 5,
|
||||||
'chapters': [{'start_time': 0.0, 'end_time': 3409.08}, {'start_time': 3409.08, 'end_time': 6565.008}],
|
'chapters': [{'start_time': 0.0, 'end_time': 3409.08}, {'start_time': 3409.08, 'end_time': 6565.008}],
|
||||||
|
'categories': ['Informazione'],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# DRM
|
# DRM
|
||||||
|
@ -149,6 +150,7 @@ class MediasetIE(ThePlatformBaseIE):
|
||||||
'season_number': 12,
|
'season_number': 12,
|
||||||
'episode': 'Episode 8',
|
'episode': 'Episode 8',
|
||||||
'episode_number': 8,
|
'episode_number': 8,
|
||||||
|
'categories': ['Intrattenimento'],
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
|
|
|
@ -3,8 +3,11 @@ import re
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
|
filter_dict,
|
||||||
|
parse_qs,
|
||||||
remove_end,
|
remove_end,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
|
update_url_query,
|
||||||
urljoin,
|
urljoin,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -108,7 +111,9 @@ class MediaStreamIE(MediaStreamBaseIE):
|
||||||
|
|
||||||
for message in [
|
for message in [
|
||||||
'Debido a tu ubicación no puedes ver el contenido',
|
'Debido a tu ubicación no puedes ver el contenido',
|
||||||
'You are not allowed to watch this video: Geo Fencing Restriction'
|
'You are not allowed to watch this video: Geo Fencing Restriction',
|
||||||
|
'Este contenido no está disponible en tu zona geográfica.',
|
||||||
|
'El contenido sólo está disponible dentro de',
|
||||||
]:
|
]:
|
||||||
if message in webpage:
|
if message in webpage:
|
||||||
self.raise_geo_restricted()
|
self.raise_geo_restricted()
|
||||||
|
@ -118,7 +123,16 @@ class MediaStreamIE(MediaStreamBaseIE):
|
||||||
formats, subtitles = [], {}
|
formats, subtitles = [], {}
|
||||||
for video_format in player_config['src']:
|
for video_format in player_config['src']:
|
||||||
if video_format == 'hls':
|
if video_format == 'hls':
|
||||||
fmts, subs = self._extract_m3u8_formats_and_subtitles(player_config['src'][video_format], video_id)
|
params = {
|
||||||
|
'at': 'web-app',
|
||||||
|
'access_token': traverse_obj(parse_qs(url), ('access_token', 0)),
|
||||||
|
}
|
||||||
|
for name, key in (('MDSTRMUID', 'uid'), ('MDSTRMSID', 'sid'), ('MDSTRMPID', 'pid'), ('VERSION', 'av')):
|
||||||
|
params[key] = self._search_regex(
|
||||||
|
rf'window\.{name}\s*=\s*["\']([^"\']+)["\'];', webpage, key, default=None)
|
||||||
|
|
||||||
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||||
|
update_url_query(player_config['src'][video_format], filter_dict(params)), video_id)
|
||||||
formats.extend(fmts)
|
formats.extend(fmts)
|
||||||
self._merge_subtitles(subs, target=subtitles)
|
self._merge_subtitles(subs, target=subtitles)
|
||||||
elif video_format == 'mpd':
|
elif video_format == 'mpd':
|
||||||
|
|
|
@ -53,6 +53,8 @@ class NBCIE(ThePlatformIE): # XXX: Do not subclass from concrete IE
|
||||||
'chapters': 'count:1',
|
'chapters': 'count:1',
|
||||||
'tags': 'count:4',
|
'tags': 'count:4',
|
||||||
'thumbnail': r're:https?://.+\.jpg',
|
'thumbnail': r're:https?://.+\.jpg',
|
||||||
|
'categories': ['Series/The Tonight Show Starring Jimmy Fallon'],
|
||||||
|
'media_type': 'Full Episode',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': 'm3u8',
|
'skip_download': 'm3u8',
|
||||||
|
@ -131,6 +133,8 @@ class NBCIE(ThePlatformIE): # XXX: Do not subclass from concrete IE
|
||||||
'tags': 'count:10',
|
'tags': 'count:10',
|
||||||
'age_limit': 0,
|
'age_limit': 0,
|
||||||
'thumbnail': r're:https?://.+\.jpg',
|
'thumbnail': r're:https?://.+\.jpg',
|
||||||
|
'categories': ['Series/Quantum Leap 2022'],
|
||||||
|
'media_type': 'Highlight',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': 'm3u8',
|
'skip_download': 'm3u8',
|
||||||
|
|
|
@ -3,7 +3,6 @@ import re
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..networking import HEADRequest
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
OnDemandPagedList,
|
OnDemandPagedList,
|
||||||
|
@ -84,15 +83,17 @@ class OnDemandKoreaIE(InfoExtractor):
|
||||||
def try_geo_bypass(url):
|
def try_geo_bypass(url):
|
||||||
return traverse_obj(url, ({parse_qs}, 'stream_url', 0, {url_or_none})) or url
|
return traverse_obj(url, ({parse_qs}, 'stream_url', 0, {url_or_none})) or url
|
||||||
|
|
||||||
def try_upgrade_quality(url):
|
|
||||||
mod_url = re.sub(r'_720(p?)\.m3u8', r'_1080\1.m3u8', url)
|
|
||||||
return mod_url if mod_url != url and self._request_webpage(
|
|
||||||
HEADRequest(mod_url), video_id, note='Checking for higher quality format',
|
|
||||||
errnote='No higher quality format found', fatal=False) else url
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for m3u8_url in traverse_obj(data, (('sources', 'manifest'), ..., 'url', {url_or_none}, {try_geo_bypass})):
|
for m3u8_url in traverse_obj(data, (('sources', 'manifest'), ..., 'url', {url_or_none}, {try_geo_bypass})):
|
||||||
formats.extend(self._extract_m3u8_formats(try_upgrade_quality(m3u8_url), video_id, fatal=False))
|
mod_url = re.sub(r'_720(p?)\.m3u8', r'_1080\1.m3u8', m3u8_url)
|
||||||
|
if mod_url != m3u8_url:
|
||||||
|
mod_format = self._extract_m3u8_formats(
|
||||||
|
mod_url, video_id, note='Checking for higher quality format',
|
||||||
|
errnote='No higher quality format found', fatal=False)
|
||||||
|
if mod_format:
|
||||||
|
formats.extend(mod_format)
|
||||||
|
continue
|
||||||
|
formats.extend(self._extract_m3u8_formats(m3u8_url, video_id, fatal=False))
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
for track in traverse_obj(data, ('text_tracks', lambda _, v: url_or_none(v['url']))):
|
for track in traverse_obj(data, ('text_tracks', lambda _, v: url_or_none(v['url']))):
|
||||||
|
|
|
@ -4,7 +4,14 @@ from urllib.parse import unquote
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import functools
|
from ..compat import functools
|
||||||
from ..utils import ExtractorError, make_archive_id, urljoin
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
|
float_or_none,
|
||||||
|
int_or_none,
|
||||||
|
make_archive_id,
|
||||||
|
mimetype2ext,
|
||||||
|
urljoin,
|
||||||
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +33,7 @@ class Pr0grammIE(InfoExtractor):
|
||||||
'dislike_count': int,
|
'dislike_count': int,
|
||||||
'age_limit': 0,
|
'age_limit': 0,
|
||||||
'thumbnail': r're:^https://thumb\.pr0gramm\.com/.*\.jpg',
|
'thumbnail': r're:^https://thumb\.pr0gramm\.com/.*\.jpg',
|
||||||
|
'_old_archive_ids': ['pr0grammstatic 5466437'],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# Tags require account
|
# Tags require account
|
||||||
|
@ -43,6 +51,7 @@ class Pr0grammIE(InfoExtractor):
|
||||||
'dislike_count': int,
|
'dislike_count': int,
|
||||||
'age_limit': 0,
|
'age_limit': 0,
|
||||||
'thumbnail': r're:^https://thumb\.pr0gramm\.com/.*\.jpg',
|
'thumbnail': r're:^https://thumb\.pr0gramm\.com/.*\.jpg',
|
||||||
|
'_old_archive_ids': ['pr0grammstatic 3052805'],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# Requires verified account
|
# Requires verified account
|
||||||
|
@ -60,6 +69,7 @@ class Pr0grammIE(InfoExtractor):
|
||||||
'dislike_count': int,
|
'dislike_count': int,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
'thumbnail': r're:^https://thumb\.pr0gramm\.com/.*\.jpg',
|
'thumbnail': r're:^https://thumb\.pr0gramm\.com/.*\.jpg',
|
||||||
|
'_old_archive_ids': ['pr0grammstatic 5848332'],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://pr0gramm.com/static/5466437',
|
'url': 'https://pr0gramm.com/static/5466437',
|
||||||
|
@ -110,37 +120,61 @@ class Pr0grammIE(InfoExtractor):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _create_source_url(path):
|
||||||
|
return urljoin('https://img.pr0gramm.com', path)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
video_info = traverse_obj(
|
video_info = traverse_obj(
|
||||||
self._call_api('get', video_id, {'id': video_id, 'flags': self._maximum_flags}),
|
self._call_api('get', video_id, {'id': video_id, 'flags': self._maximum_flags}),
|
||||||
('items', 0, {dict}))
|
('items', 0, {dict}))
|
||||||
|
|
||||||
source = urljoin('https://img.pr0gramm.com', video_info.get('image'))
|
source = video_info.get('image')
|
||||||
if not source or not source.endswith('mp4'):
|
if not source or not source.endswith('mp4'):
|
||||||
self.raise_no_formats('Could not extract a video', expected=bool(source), video_id=video_id)
|
self.raise_no_formats('Could not extract a video', expected=bool(source), video_id=video_id)
|
||||||
|
|
||||||
tags = None
|
tags = None
|
||||||
if self._is_logged_in:
|
if self._is_logged_in:
|
||||||
metadata = self._call_api('info', video_id, {'itemId': video_id})
|
metadata = self._call_api('info', video_id, {'itemId': video_id}, note='Downloading tags')
|
||||||
tags = traverse_obj(metadata, ('tags', ..., 'tag', {str}))
|
tags = traverse_obj(metadata, ('tags', ..., 'tag', {str}))
|
||||||
# Sorted by "confidence", higher confidence = earlier in list
|
# Sorted by "confidence", higher confidence = earlier in list
|
||||||
confidences = traverse_obj(metadata, ('tags', ..., 'confidence', ({int}, {float})))
|
confidences = traverse_obj(metadata, ('tags', ..., 'confidence', ({int}, {float})))
|
||||||
if confidences:
|
if confidences:
|
||||||
tags = [tag for _, tag in sorted(zip(confidences, tags), reverse=True)]
|
tags = [tag for _, tag in sorted(zip(confidences, tags), reverse=True)]
|
||||||
|
|
||||||
|
formats = traverse_obj(video_info, ('variants', ..., {
|
||||||
|
'format_id': ('name', {str}),
|
||||||
|
'url': ('path', {self._create_source_url}),
|
||||||
|
'ext': ('mimeType', {mimetype2ext}),
|
||||||
|
'vcodec': ('codec', {str}),
|
||||||
|
'width': ('width', {int_or_none}),
|
||||||
|
'height': ('height', {int_or_none}),
|
||||||
|
'bitrate': ('bitRate', {float_or_none}),
|
||||||
|
'filesize': ('fileSize', {int_or_none}),
|
||||||
|
})) if video_info.get('variants') else [{
|
||||||
|
'ext': 'mp4',
|
||||||
|
'format_id': 'source',
|
||||||
|
**traverse_obj(video_info, {
|
||||||
|
'url': ('image', {self._create_source_url}),
|
||||||
|
'width': ('width', {int_or_none}),
|
||||||
|
'height': ('height', {int_or_none}),
|
||||||
|
}),
|
||||||
|
}]
|
||||||
|
|
||||||
|
subtitles = {}
|
||||||
|
for subtitle in traverse_obj(video_info, ('subtitles', lambda _, v: v['language'])):
|
||||||
|
subtitles.setdefault(subtitle['language'], []).append(traverse_obj(subtitle, {
|
||||||
|
'url': ('path', {self._create_source_url}),
|
||||||
|
'note': ('label', {str}),
|
||||||
|
}))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': f'pr0gramm-{video_id} by {video_info.get("user")}',
|
'title': f'pr0gramm-{video_id} by {video_info.get("user")}',
|
||||||
'formats': [{
|
|
||||||
'url': source,
|
|
||||||
'ext': 'mp4',
|
|
||||||
**traverse_obj(video_info, {
|
|
||||||
'width': ('width', {int}),
|
|
||||||
'height': ('height', {int}),
|
|
||||||
}),
|
|
||||||
}],
|
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
'age_limit': 18 if traverse_obj(video_info, ('flags', {0b110.__and__})) else 0,
|
'age_limit': 18 if traverse_obj(video_info, ('flags', {0b110.__and__})) else 0,
|
||||||
'_old_archive_ids': [make_archive_id('Pr0grammStatic', video_id)],
|
'_old_archive_ids': [make_archive_id('Pr0grammStatic', video_id)],
|
||||||
**traverse_obj(video_info, {
|
**traverse_obj(video_info, {
|
||||||
|
|
|
@ -114,6 +114,8 @@ class ScrippsNetworksIE(InfoExtractor):
|
||||||
'timestamp': 1475678834,
|
'timestamp': 1475678834,
|
||||||
'upload_date': '20161005',
|
'upload_date': '20161005',
|
||||||
'uploader': 'SCNI-SCND',
|
'uploader': 'SCNI-SCND',
|
||||||
|
'tags': 'count:10',
|
||||||
|
'creator': 'Cooking Channel',
|
||||||
'duration': 29.995,
|
'duration': 29.995,
|
||||||
'chapters': [{'start_time': 0.0, 'end_time': 29.995, 'title': '<Untitled Chapter 1>'}],
|
'chapters': [{'start_time': 0.0, 'end_time': 29.995, 'title': '<Untitled Chapter 1>'}],
|
||||||
'thumbnail': 'https://images.dds.discovery.com/up/tp/Scripps_-_Food_Category_Prod/122/987/0260338_630x355.jpg',
|
'thumbnail': 'https://images.dds.discovery.com/up/tp/Scripps_-_Food_Category_Prod/122/987/0260338_630x355.jpg',
|
||||||
|
|
|
@ -104,6 +104,10 @@ class ThePlatformBaseIE(OnceIE):
|
||||||
_add_chapter(chapter.get('startTime'), chapter.get('endTime'))
|
_add_chapter(chapter.get('startTime'), chapter.get('endTime'))
|
||||||
_add_chapter(tp_chapters[-1].get('startTime'), tp_chapters[-1].get('endTime') or duration)
|
_add_chapter(tp_chapters[-1].get('startTime'), tp_chapters[-1].get('endTime') or duration)
|
||||||
|
|
||||||
|
def extract_site_specific_field(field):
|
||||||
|
# A number of sites have custom-prefixed keys, e.g. 'cbc$seasonNumber'
|
||||||
|
return traverse_obj(info, lambda k, v: v and k.endswith(f'${field}'), get_all=False)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'title': info['title'],
|
'title': info['title'],
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
|
@ -113,6 +117,14 @@ class ThePlatformBaseIE(OnceIE):
|
||||||
'timestamp': int_or_none(info.get('pubDate'), 1000) or None,
|
'timestamp': int_or_none(info.get('pubDate'), 1000) or None,
|
||||||
'uploader': info.get('billingCode'),
|
'uploader': info.get('billingCode'),
|
||||||
'chapters': chapters,
|
'chapters': chapters,
|
||||||
|
'creator': traverse_obj(info, ('author', {str})) or None,
|
||||||
|
'categories': traverse_obj(info, (
|
||||||
|
'categories', lambda _, v: v.get('label') in ('category', None), 'name', {str})) or None,
|
||||||
|
'tags': traverse_obj(info, ('keywords', {lambda x: re.split(r'[;,]\s?', x) if x else None})),
|
||||||
|
'location': extract_site_specific_field('region'),
|
||||||
|
'series': extract_site_specific_field('show'),
|
||||||
|
'season_number': int_or_none(extract_site_specific_field('seasonNumber')),
|
||||||
|
'media_type': extract_site_specific_field('programmingType') or extract_site_specific_field('type'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _extract_theplatform_metadata(self, path, video_id):
|
def _extract_theplatform_metadata(self, path, video_id):
|
||||||
|
|
|
@ -428,7 +428,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||||
r'(?:www\.)?piped\.adminforge\.de',
|
r'(?:www\.)?piped\.adminforge\.de',
|
||||||
r'(?:www\.)?watch\.whatevertinfoil\.de',
|
r'(?:www\.)?watch\.whatevertinfoil\.de',
|
||||||
r'(?:www\.)?piped\.qdi\.fi',
|
r'(?:www\.)?piped\.qdi\.fi',
|
||||||
r'(?:www\.)?piped\.video',
|
r'(?:(?:www|cf)\.)?piped\.video',
|
||||||
r'(?:www\.)?piped\.aeong\.one',
|
r'(?:www\.)?piped\.aeong\.one',
|
||||||
r'(?:www\.)?piped\.moomoo\.me',
|
r'(?:www\.)?piped\.moomoo\.me',
|
||||||
r'(?:www\.)?piped\.chauvet\.pro',
|
r'(?:www\.)?piped\.chauvet\.pro',
|
||||||
|
@ -6469,6 +6469,9 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||||
def _has_tab(self, tabs, tab_id):
|
def _has_tab(self, tabs, tab_id):
|
||||||
return any(self._extract_tab_id_and_name(tab)[0] == tab_id for tab in tabs)
|
return any(self._extract_tab_id_and_name(tab)[0] == tab_id for tab in tabs)
|
||||||
|
|
||||||
|
def _empty_playlist(self, item_id, data):
|
||||||
|
return self.playlist_result([], item_id, **self._extract_metadata_from_tabs(item_id, data))
|
||||||
|
|
||||||
@YoutubeTabBaseInfoExtractor.passthrough_smuggled_data
|
@YoutubeTabBaseInfoExtractor.passthrough_smuggled_data
|
||||||
def _real_extract(self, url, smuggled_data):
|
def _real_extract(self, url, smuggled_data):
|
||||||
item_id = self._match_id(url)
|
item_id = self._match_id(url)
|
||||||
|
@ -6534,6 +6537,10 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||||
selected_tab_id, selected_tab_name = self._extract_tab_id_and_name(selected_tab, url) # NB: Name may be translated
|
selected_tab_id, selected_tab_name = self._extract_tab_id_and_name(selected_tab, url) # NB: Name may be translated
|
||||||
self.write_debug(f'Selected tab: {selected_tab_id!r} ({selected_tab_name}), Requested tab: {original_tab_id!r}')
|
self.write_debug(f'Selected tab: {selected_tab_id!r} ({selected_tab_name}), Requested tab: {original_tab_id!r}')
|
||||||
|
|
||||||
|
# /about is no longer a tab
|
||||||
|
if original_tab_id == 'about':
|
||||||
|
return self._empty_playlist(item_id, data)
|
||||||
|
|
||||||
if not original_tab_id and selected_tab_name:
|
if not original_tab_id and selected_tab_name:
|
||||||
self.to_screen('Downloading all uploads of the channel. '
|
self.to_screen('Downloading all uploads of the channel. '
|
||||||
'To download only the videos in a specific tab, pass the tab\'s URL')
|
'To download only the videos in a specific tab, pass the tab\'s URL')
|
||||||
|
@ -6546,7 +6553,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||||
if not extra_tabs and selected_tab_id != 'videos':
|
if not extra_tabs and selected_tab_id != 'videos':
|
||||||
# Channel does not have streams, shorts or videos tabs
|
# Channel does not have streams, shorts or videos tabs
|
||||||
if item_id[:2] != 'UC':
|
if item_id[:2] != 'UC':
|
||||||
raise ExtractorError('This channel has no uploads', expected=True)
|
return self._empty_playlist(item_id, data)
|
||||||
|
|
||||||
# Topic channels don't have /videos. Use the equivalent playlist instead
|
# Topic channels don't have /videos. Use the equivalent playlist instead
|
||||||
pl_id = f'UU{item_id[2:]}'
|
pl_id = f'UU{item_id[2:]}'
|
||||||
|
@ -6554,7 +6561,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||||
try:
|
try:
|
||||||
data, ytcfg = self._extract_data(pl_url, pl_id, ytcfg=ytcfg, fatal=True, webpage_fatal=True)
|
data, ytcfg = self._extract_data(pl_url, pl_id, ytcfg=ytcfg, fatal=True, webpage_fatal=True)
|
||||||
except ExtractorError:
|
except ExtractorError:
|
||||||
raise ExtractorError('This channel has no uploads', expected=True)
|
return self._empty_playlist(item_id, data)
|
||||||
else:
|
else:
|
||||||
item_id, url = pl_id, pl_url
|
item_id, url = pl_id, pl_url
|
||||||
self.to_screen(
|
self.to_screen(
|
||||||
|
|
|
@ -4789,8 +4789,9 @@ def parse_http_range(range):
|
||||||
|
|
||||||
|
|
||||||
def read_stdin(what):
|
def read_stdin(what):
|
||||||
eof = 'Ctrl+Z' if compat_os_name == 'nt' else 'Ctrl+D'
|
if what:
|
||||||
write_string(f'Reading {what} from STDIN - EOF ({eof}) to end:\n')
|
eof = 'Ctrl+Z' if compat_os_name == 'nt' else 'Ctrl+D'
|
||||||
|
write_string(f'Reading {what} from STDIN - EOF ({eof}) to end:\n')
|
||||||
return sys.stdin
|
return sys.stdin
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from ._utils import (
|
||||||
IDENTITY,
|
IDENTITY,
|
||||||
NO_DEFAULT,
|
NO_DEFAULT,
|
||||||
LazyList,
|
LazyList,
|
||||||
int_or_none,
|
deprecation_warning,
|
||||||
is_iterable_like,
|
is_iterable_like,
|
||||||
try_call,
|
try_call,
|
||||||
variadic,
|
variadic,
|
||||||
|
@ -17,7 +17,7 @@ from ._utils import (
|
||||||
|
|
||||||
def traverse_obj(
|
def traverse_obj(
|
||||||
obj, *paths, default=NO_DEFAULT, expected_type=None, get_all=True,
|
obj, *paths, default=NO_DEFAULT, expected_type=None, get_all=True,
|
||||||
casesense=True, is_user_input=False, traverse_string=False):
|
casesense=True, is_user_input=NO_DEFAULT, traverse_string=False):
|
||||||
"""
|
"""
|
||||||
Safely traverse nested `dict`s and `Iterable`s
|
Safely traverse nested `dict`s and `Iterable`s
|
||||||
|
|
||||||
|
@ -63,10 +63,8 @@ def traverse_obj(
|
||||||
@param get_all If `False`, return the first matching result, otherwise all matching ones.
|
@param get_all If `False`, return the first matching result, otherwise all matching ones.
|
||||||
@param casesense If `False`, consider string dictionary keys as case insensitive.
|
@param casesense If `False`, consider string dictionary keys as case insensitive.
|
||||||
|
|
||||||
The following are only meant to be used by YoutubeDL.prepare_outtmpl and are not part of the API
|
`traverse_string` is only meant to be used by YoutubeDL.prepare_outtmpl and is not part of the API
|
||||||
|
|
||||||
@param is_user_input Whether the keys are generated from user input.
|
|
||||||
If `True` strings get converted to `int`/`slice` if needed.
|
|
||||||
@param traverse_string Whether to traverse into objects as strings.
|
@param traverse_string Whether to traverse into objects as strings.
|
||||||
If `True`, any non-compatible object will first be
|
If `True`, any non-compatible object will first be
|
||||||
converted into a string and then traversed into.
|
converted into a string and then traversed into.
|
||||||
|
@ -80,6 +78,9 @@ def traverse_obj(
|
||||||
If no `default` is given and the last path branches, a `list` of results
|
If no `default` is given and the last path branches, a `list` of results
|
||||||
is always returned. If a path ends on a `dict` that result will always be a `dict`.
|
is always returned. If a path ends on a `dict` that result will always be a `dict`.
|
||||||
"""
|
"""
|
||||||
|
if is_user_input is not NO_DEFAULT:
|
||||||
|
deprecation_warning('The is_user_input parameter is deprecated and no longer works')
|
||||||
|
|
||||||
casefold = lambda k: k.casefold() if isinstance(k, str) else k
|
casefold = lambda k: k.casefold() if isinstance(k, str) else k
|
||||||
|
|
||||||
if isinstance(expected_type, type):
|
if isinstance(expected_type, type):
|
||||||
|
@ -195,14 +196,6 @@ def traverse_obj(
|
||||||
|
|
||||||
key = None
|
key = None
|
||||||
for last, key in lazy_last(variadic(path, (str, bytes, dict, set))):
|
for last, key in lazy_last(variadic(path, (str, bytes, dict, set))):
|
||||||
if is_user_input and isinstance(key, str):
|
|
||||||
if key == ':':
|
|
||||||
key = ...
|
|
||||||
elif ':' in key:
|
|
||||||
key = slice(*map(int_or_none, key.split(':')))
|
|
||||||
elif int_or_none(key) is not None:
|
|
||||||
key = int(key)
|
|
||||||
|
|
||||||
if not casesense and isinstance(key, str):
|
if not casesense and isinstance(key, str):
|
||||||
key = key.casefold()
|
key = key.casefold()
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ _REGEX_TS = re.compile(r'''(?x)
|
||||||
_REGEX_EOF = re.compile(r'\Z')
|
_REGEX_EOF = re.compile(r'\Z')
|
||||||
_REGEX_NL = re.compile(r'(?:\r\n|[\r\n]|$)')
|
_REGEX_NL = re.compile(r'(?:\r\n|[\r\n]|$)')
|
||||||
_REGEX_BLANK = re.compile(r'(?:\r\n|[\r\n])+')
|
_REGEX_BLANK = re.compile(r'(?:\r\n|[\r\n])+')
|
||||||
|
_REGEX_OPTIONAL_WHITESPACE = re.compile(r'[ \t]*')
|
||||||
|
|
||||||
|
|
||||||
def _parse_ts(ts):
|
def _parse_ts(ts):
|
||||||
|
@ -285,6 +286,7 @@ class CueBlock(Block):
|
||||||
m1 = parser.consume(_REGEX_TS)
|
m1 = parser.consume(_REGEX_TS)
|
||||||
if not m1:
|
if not m1:
|
||||||
return None
|
return None
|
||||||
|
parser.consume(_REGEX_OPTIONAL_WHITESPACE)
|
||||||
m2 = parser.consume(cls._REGEX_SETTINGS)
|
m2 = parser.consume(cls._REGEX_SETTINGS)
|
||||||
if not parser.consume(_REGEX_NL):
|
if not parser.consume(_REGEX_NL):
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user