mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 02:55:17 +00:00
Bugfix for 7b2c3f47c6
This commit is contained in:
parent
6d1b34896e
commit
612f2be5d3
2 changed files with 8 additions and 8 deletions
|
@ -2817,7 +2817,7 @@ def extract_Initialization(source):
|
||||||
base_url = ''
|
base_url = ''
|
||||||
for element in (representation, adaptation_set, period, mpd_doc):
|
for element in (representation, adaptation_set, period, mpd_doc):
|
||||||
base_url_e = element.find(_add_ns('BaseURL'))
|
base_url_e = element.find(_add_ns('BaseURL'))
|
||||||
if base_url_e and base_url_e.text:
|
if base_url_e is not None:
|
||||||
base_url = base_url_e.text + base_url
|
base_url = base_url_e.text + base_url
|
||||||
if re.match(r'^https?://', base_url):
|
if re.match(r'^https?://', base_url):
|
||||||
break
|
break
|
||||||
|
|
|
@ -4748,23 +4748,23 @@ def pkcs1pad(data, length):
|
||||||
def _base_n_table(n, table):
|
def _base_n_table(n, table):
|
||||||
if not table and not n:
|
if not table and not n:
|
||||||
raise ValueError('Either table or n must be specified')
|
raise ValueError('Either table or n must be specified')
|
||||||
elif not table:
|
table = (table or '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')[:n]
|
||||||
table = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'[:n]
|
|
||||||
elif not n or n == len(table):
|
if n != len(table):
|
||||||
return table
|
raise ValueError(f'base {n} exceeds table length {len(table)}')
|
||||||
raise ValueError(f'base {n} exceeds table length {len(table)}')
|
return table
|
||||||
|
|
||||||
|
|
||||||
def encode_base_n(num, n=None, table=None):
|
def encode_base_n(num, n=None, table=None):
|
||||||
"""Convert given int to a base-n string"""
|
"""Convert given int to a base-n string"""
|
||||||
table = _base_n_table(n)
|
table = _base_n_table(n, table)
|
||||||
if not num:
|
if not num:
|
||||||
return table[0]
|
return table[0]
|
||||||
|
|
||||||
result, base = '', len(table)
|
result, base = '', len(table)
|
||||||
while num:
|
while num:
|
||||||
result = table[num % base] + result
|
result = table[num % base] + result
|
||||||
num = num // result
|
num = num // base
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue