Compare commits

..

No commits in common. "6eb981bb60aa7dd676c0bf61e1cf471f0df36f8e" and "091084958786d871b1dc2c36d3a56aed5415bccd" have entirely different histories.

8 changed files with 14 additions and 28 deletions

View File

@ -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`

View File

@ -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')

View File

@ -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, ...}"

View File

@ -73,16 +73,14 @@ 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(None if verbose == -1 else 'URLs') if batchfile == '-' read_stdin('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 == 1: if verbose:
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')
@ -723,7 +721,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, -1 if opts.quiet and not opts.verbose else opts.verbose) urls = get_urls(urls, opts.batchfile, opts.verbose)
set_compat_opts(opts) set_compat_opts(opts)
try: try:

View File

@ -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):
urlh = self._request_webpage( webpage, urlh = self._download_webpage_handle(
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 = urlh.headers.get('X-CLTFT-Token') cltft_token = self._hidden_inputs(webpage).get('Token.Default')
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', cltft_token) self._set_cookie('live.eplus.jp', 'X-CLTFT-Token', f'Token.Default={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': cltft_token, 'X-Cltft-Token': f'Token.Default={cltft_token}',
'Accept': '*/*', 'Accept': '*/*',
}, data=json.dumps({ }, data=json.dumps({
'loginId': id, 'loginId': id,

View File

@ -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|cf)\.)?piped\.video', r'(?:www\.)?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,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(

View File

@ -4789,7 +4789,6 @@ 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

View File

@ -95,7 +95,6 @@ _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):
@ -286,7 +285,6 @@ 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