mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-25 08:41:28 +01:00
Compare commits
7 Commits
0910849587
...
6eb981bb60
Author | SHA1 | Date | |
---|---|---|---|
|
6eb981bb60 | ||
|
2cd0d8617a | ||
|
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`
|
||||||
|
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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, ...}"
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -78,23 +78,23 @@ class EplusIbIE(InfoExtractor):
|
||||||
_TEST_EVENT_URL = 'https://live.eplus.jp/2053935'
|
_TEST_EVENT_URL = 'https://live.eplus.jp/2053935'
|
||||||
|
|
||||||
def _perform_login(self, id, password):
|
def _perform_login(self, id, password):
|
||||||
webpage, urlh = self._download_webpage_handle(
|
urlh = self._request_webpage(
|
||||||
self._TEST_EVENT_URL, None, note='Getting auth status', errnote='Unable to get auth status')
|
self._TEST_EVENT_URL, None, note='Getting auth status', errnote='Unable to get auth status')
|
||||||
if urlh.url.startswith(self._TEST_EVENT_URL):
|
if urlh.url.startswith(self._TEST_EVENT_URL):
|
||||||
# already logged in
|
# already logged in
|
||||||
return
|
return
|
||||||
|
|
||||||
cltft_token = self._hidden_inputs(webpage).get('Token.Default')
|
cltft_token = urlh.headers.get('X-CLTFT-Token')
|
||||||
if not cltft_token:
|
if not cltft_token:
|
||||||
raise ExtractorError('Unable to get X-CLTFT-Token', expected=False)
|
raise ExtractorError('Unable to get X-CLTFT-Token', expected=False)
|
||||||
self._set_cookie('live.eplus.jp', 'X-CLTFT-Token', f'Token.Default={cltft_token}')
|
self._set_cookie('live.eplus.jp', 'X-CLTFT-Token', cltft_token)
|
||||||
|
|
||||||
login_json = self._download_json(
|
login_json = self._download_json(
|
||||||
'https://live.eplus.jp/member/api/v1/FTAuth/idpw', None,
|
'https://live.eplus.jp/member/api/v1/FTAuth/idpw', None,
|
||||||
note='Sending pre-login info', errnote='Unable to send pre-login info', headers={
|
note='Sending pre-login info', errnote='Unable to send pre-login info', headers={
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'Referer': urlh.url,
|
'Referer': urlh.url,
|
||||||
'X-Cltft-Token': f'Token.Default={cltft_token}',
|
'X-Cltft-Token': cltft_token,
|
||||||
'Accept': '*/*',
|
'Accept': '*/*',
|
||||||
}, data=json.dumps({
|
}, data=json.dumps({
|
||||||
'loginId': id,
|
'loginId': 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,6 +4789,7 @@ def parse_http_range(range):
|
||||||
|
|
||||||
|
|
||||||
def read_stdin(what):
|
def read_stdin(what):
|
||||||
|
if what:
|
||||||
eof = 'Ctrl+Z' if compat_os_name == 'nt' else 'Ctrl+D'
|
eof = 'Ctrl+Z' if compat_os_name == 'nt' else 'Ctrl+D'
|
||||||
write_string(f'Reading {what} from STDIN - EOF ({eof}) to end:\n')
|
write_string(f'Reading {what} from STDIN - EOF ({eof}) to end:\n')
|
||||||
return sys.stdin
|
return sys.stdin
|
||||||
|
|
|
@ -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