mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-25 08:41:28 +01:00
Compare commits
No commits in common. "044886c220620a7679109e92352890e18b6079e3" and "6a9c7a2b52655bacfa7ab2da24fd0d14a6fff495" have entirely different histories.
044886c220
...
6a9c7a2b52
|
@ -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. **Arithmetic**: Simple arithmetic can be done on numeric fields using `+`, `-` and `*`. E.g. `%(playlist_index+10)03d`, `%(n_entries+1-playlist_index)d`
|
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. **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`
|
||||||
|
|
||||||
|
|
|
@ -797,7 +797,6 @@ 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')
|
||||||
|
|
|
@ -1179,7 +1179,6 @@ 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, ...}"
|
||||||
|
|
|
@ -6469,9 +6469,6 @@ 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)
|
||||||
|
@ -6537,10 +6534,6 @@ 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')
|
||||||
|
@ -6553,7 +6546,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':
|
||||||
return self._empty_playlist(item_id, data)
|
raise ExtractorError('This channel has no uploads', expected=True)
|
||||||
|
|
||||||
# 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:]}'
|
||||||
|
@ -6561,7 +6554,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:
|
||||||
return self._empty_playlist(item_id, data)
|
raise ExtractorError('This channel has no uploads', expected=True)
|
||||||
else:
|
else:
|
||||||
item_id, url = pl_id, pl_url
|
item_id, url = pl_id, pl_url
|
||||||
self.to_screen(
|
self.to_screen(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user