Skip to content

Commit e3575d2

Browse files
committed
[script.module.youtube.dl@matrix] 25.11.30+matrix.1
1 parent c8fcb7c commit e3575d2

File tree

11 files changed

+900
-318
lines changed

11 files changed

+900
-318
lines changed

script.module.youtube.dl/addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.module.youtube.dl" name="youtube-dl Control" version="25.05.18+matrix.1" provider-name="ytdl-org,ruuk,sy6sy2,wwark">
2+
<addon id="script.module.youtube.dl" name="youtube-dl Control" version="25.11.30+matrix.1" provider-name="ytdl-org,ruuk,sy6sy2,wwark">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0"/>
55
<import addon="script.module.addon.signals" version="0.0.5+matrix.1"/>

script.module.youtube.dl/lib/YDStreamExtractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _getYoutubeDLVideo(url, quality=None, resolve_redirects=False):
189189
try:
190190
url = resolve_http_redirect(url)
191191
except Exception:
192-
util.ERROR('_getYoutubeDLVideo(): Failed to resolve URL')
192+
util.ERROR('_getYoutubeDLVideo(): Failed to resolve URL'+' '+url)
193193
return None
194194
ytdl = YoutubeDLWrapper._getYTDL()
195195
ytdl.clearDownloadParams()

script.module.youtube.dl/lib/youtube_dl/YoutubeDL.py

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class YoutubeDL(object):
357357

358358
_NUMERIC_FIELDS = set((
359359
'width', 'height', 'tbr', 'abr', 'asr', 'vbr', 'fps', 'filesize', 'filesize_approx',
360-
'timestamp', 'upload_year', 'upload_month', 'upload_day',
360+
'timestamp', 'upload_year', 'upload_month', 'upload_day', 'available_at',
361361
'duration', 'view_count', 'like_count', 'dislike_count', 'repost_count',
362362
'average_rating', 'comment_count', 'age_limit',
363363
'start_time', 'end_time',
@@ -681,8 +681,7 @@ def write_debug(self, message, only_once=False):
681681
message = '[debug] {0}'.format(message)
682682
if self.params.get('logger'):
683683
self.params['logger'].debug(message)
684-
else:
685-
self.to_stderr(message, only_once)
684+
686685

687686
def report_unscoped_cookies(self, *args, **kwargs):
688687
# message=None, tb=False, is_error=False
@@ -2404,60 +2403,52 @@ def format_resolution(format, default='unknown'):
24042403
return res
24052404

24062405
def _format_note(self, fdict):
2407-
res = ''
2408-
if fdict.get('ext') in ['f4f', 'f4m']:
2409-
res += '(unsupported) '
2410-
if fdict.get('language'):
2411-
if res:
2412-
res += ' '
2413-
res += '[%s] ' % fdict['language']
2414-
if fdict.get('format_note') is not None:
2415-
res += fdict['format_note'] + ' '
2416-
if fdict.get('tbr') is not None:
2417-
res += '%4dk ' % fdict['tbr']
2406+
2407+
def simplified_codec(f, field):
2408+
assert field in ('acodec', 'vcodec')
2409+
codec = f.get(field)
2410+
return (
2411+
'unknown' if not codec
2412+
else '.'.join(codec.split('.')[:4]) if codec != 'none'
2413+
else 'images' if field == 'vcodec' and f.get('acodec') == 'none'
2414+
else None if field == 'acodec' and f.get('vcodec') == 'none'
2415+
else 'audio only' if field == 'vcodec'
2416+
else 'video only')
2417+
2418+
res = join_nonempty(
2419+
fdict.get('ext') in ('f4f', 'f4m') and '(unsupported)',
2420+
fdict.get('language') and ('[%s]' % (fdict['language'],)),
2421+
fdict.get('format_note') is not None and fdict['format_note'],
2422+
fdict.get('tbr') is not None and ('%4dk' % fdict['tbr']),
2423+
delim=' ')
2424+
res = [res] if res else []
24182425
if fdict.get('container') is not None:
2419-
if res:
2420-
res += ', '
2421-
res += '%s container' % fdict['container']
2422-
if (fdict.get('vcodec') is not None
2423-
and fdict.get('vcodec') != 'none'):
2424-
if res:
2425-
res += ', '
2426-
res += fdict['vcodec']
2427-
if fdict.get('vbr') is not None:
2428-
res += '@'
2426+
res.append('%s container' % (fdict['container'],))
2427+
if fdict.get('vcodec') not in (None, 'none'):
2428+
codec = simplified_codec(fdict, 'vcodec')
2429+
if codec and fdict.get('vbr') is not None:
2430+
codec += '@'
24292431
elif fdict.get('vbr') is not None and fdict.get('abr') is not None:
2430-
res += 'video@'
2431-
if fdict.get('vbr') is not None:
2432-
res += '%4dk' % fdict['vbr']
2432+
codec = 'video@'
2433+
else:
2434+
codec = None
2435+
codec = join_nonempty(codec, fdict.get('vbr') is not None and ('%4dk' % fdict['vbr']))
2436+
if codec:
2437+
res.append(codec)
24332438
if fdict.get('fps') is not None:
2434-
if res:
2435-
res += ', '
2436-
res += '%sfps' % fdict['fps']
2437-
if fdict.get('acodec') is not None:
2438-
if res:
2439-
res += ', '
2440-
if fdict['acodec'] == 'none':
2441-
res += 'video only'
2442-
else:
2443-
res += '%-5s' % fdict['acodec']
2444-
elif fdict.get('abr') is not None:
2445-
if res:
2446-
res += ', '
2447-
res += 'audio'
2448-
if fdict.get('abr') is not None:
2449-
res += '@%3dk' % fdict['abr']
2450-
if fdict.get('asr') is not None:
2451-
res += ' (%5dHz)' % fdict['asr']
2439+
res.append('%sfps' % (fdict['fps'],))
2440+
codec = (
2441+
simplified_codec(fdict, 'acodec') if fdict.get('acodec') is not None
2442+
else 'audio' if fdict.get('abr') is not None else None)
2443+
if codec:
2444+
res.append(join_nonempty(
2445+
'%-4s' % (codec + (('@%3dk' % fdict['abr']) if fdict.get('abr') else ''),),
2446+
fdict.get('asr') and '(%5dHz)' % fdict['asr'], delim=' '))
24522447
if fdict.get('filesize') is not None:
2453-
if res:
2454-
res += ', '
2455-
res += format_bytes(fdict['filesize'])
2448+
res.append(format_bytes(fdict['filesize']))
24562449
elif fdict.get('filesize_approx') is not None:
2457-
if res:
2458-
res += ', '
2459-
res += '~' + format_bytes(fdict['filesize_approx'])
2460-
return res
2450+
res.append('~' + format_bytes(fdict['filesize_approx']))
2451+
return ', '.join(res)
24612452

24622453
def list_formats(self, info_dict):
24632454
formats = info_dict.get('formats', [info_dict])

script.module.youtube.dl/lib/youtube_dl/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ def parse_retries(retries):
409409
'include_ads': opts.include_ads,
410410
'default_search': opts.default_search,
411411
'youtube_include_dash_manifest': opts.youtube_include_dash_manifest,
412+
'youtube_player_js_version': opts.youtube_player_js_version,
413+
'youtube_player_js_variant': opts.youtube_player_js_variant,
412414
'encoding': opts.encoding,
413415
'extract_flat': opts.extract_flat,
414416
'mark_watched': opts.mark_watched,

script.module.youtube.dl/lib/youtube_dl/compat.py

Lines changed: 169 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
try:
5656
import collections.abc as compat_collections_abc
5757
except ImportError:
58-
import collections as compat_collections_abc
58+
compat_collections_abc = collections
5959

6060

6161
# compat_urllib_request
@@ -3452,13 +3452,18 @@ def unpack(self, string):
34523452
except ImportError:
34533453
compat_map = map
34543454

3455+
3456+
# compat_filter, compat_filter_fns
34553457
try:
34563458
from future_builtins import filter as compat_filter
34573459
except ImportError:
34583460
try:
34593461
from itertools import ifilter as compat_filter
34603462
except ImportError:
34613463
compat_filter = filter
3464+
# "Is this function one or maybe the other filter()?"
3465+
compat_filter_fns = tuple(set((filter, compat_filter)))
3466+
34623467

34633468
# compat_zip
34643469
try:
@@ -3478,6 +3483,40 @@ def unpack(self, string):
34783483
from itertools import izip_longest as compat_itertools_zip_longest
34793484

34803485

3486+
# compat_abc_ABC
3487+
try:
3488+
from abc import ABC as compat_abc_ABC
3489+
except ImportError:
3490+
# Py < 3.4
3491+
from abc import ABCMeta as _ABCMeta
3492+
compat_abc_ABC = _ABCMeta(str('ABC'), (object,), {})
3493+
3494+
3495+
# dict mixin used here
3496+
# like UserDict.DictMixin, without methods created by MutableMapping
3497+
class _DictMixin(compat_abc_ABC):
3498+
def has_key(self, key):
3499+
return key in self
3500+
3501+
# get(), clear(), setdefault() in MM
3502+
3503+
def iterkeys(self):
3504+
return (k for k in self)
3505+
3506+
def itervalues(self):
3507+
return (self[k] for k in self)
3508+
3509+
def iteritems(self):
3510+
return ((k, self[k]) for k in self)
3511+
3512+
# pop(), popitem() in MM
3513+
3514+
def copy(self):
3515+
return type(self)(self)
3516+
3517+
# update() in MM
3518+
3519+
34813520
# compat_collections_chain_map
34823521
# collections.ChainMap: new class
34833522
try:
@@ -3632,6 +3671,129 @@ def compat_datetime_timedelta_total_seconds(td):
36323671
compat_zstandard = None
36333672

36343673

3674+
# compat_thread
3675+
try:
3676+
import _thread as compat_thread
3677+
except ImportError:
3678+
try:
3679+
import thread as compat_thread
3680+
except ImportError:
3681+
import dummy_thread as compat_thread
3682+
3683+
3684+
# compat_dict
3685+
# compat_builtins_dict
3686+
# compat_dict_items
3687+
if sys.version_info >= (3, 6):
3688+
compat_dict = compat_builtins_dict = dict
3689+
compat_dict_items = dict.items
3690+
else:
3691+
_get_ident = compat_thread.get_ident
3692+
3693+
class compat_dict(compat_collections_abc.MutableMapping, _DictMixin, dict):
3694+
"""`dict` that preserves insertion order with interface like Py3.7+"""
3695+
3696+
_order = [] # default that should never be used
3697+
3698+
def __init__(self, *mappings_or_iterables, **kwargs):
3699+
# order an unordered dict using a list of keys: actual Py 2.7+
3700+
# OrderedDict uses a doubly linked list for better performance
3701+
self._order = []
3702+
for arg in mappings_or_iterables:
3703+
self.__update(arg)
3704+
if kwargs:
3705+
self.__update(kwargs)
3706+
3707+
def __getitem__(self, key):
3708+
return dict.__getitem__(self, key)
3709+
3710+
def __setitem__(self, key, value):
3711+
try:
3712+
if key not in self._order:
3713+
self._order.append(key)
3714+
dict.__setitem__(self, key, value)
3715+
except Exception:
3716+
if key in self._order[-1:] and key not in self:
3717+
del self._order[-1]
3718+
raise
3719+
3720+
def __len__(self):
3721+
return dict.__len__(self)
3722+
3723+
def __delitem__(self, key):
3724+
dict.__delitem__(self, key)
3725+
try:
3726+
# expected case, O(len(self)), but who dels anyway?
3727+
self._order.remove(key)
3728+
except ValueError:
3729+
pass
3730+
3731+
def __iter__(self):
3732+
for from_ in self._order:
3733+
if from_ in self:
3734+
yield from_
3735+
3736+
def __del__(self):
3737+
for attr in ('_order',):
3738+
try:
3739+
delattr(self, attr)
3740+
except Exception:
3741+
pass
3742+
3743+
def __repr__(self, _repr_running={}):
3744+
# skip recursive items ...
3745+
call_key = id(self), _get_ident()
3746+
if _repr_running.get(call_key):
3747+
return '...'
3748+
_repr_running[call_key] = True
3749+
try:
3750+
return '%s({%s})' % (
3751+
type(self).__name__,
3752+
','.join('%r: %r' % k_v for k_v in self.items()))
3753+
finally:
3754+
del _repr_running[call_key]
3755+
3756+
# merge/update (PEP 584)
3757+
3758+
def __or__(self, other):
3759+
if not isinstance(other, compat_collections_abc.Mapping):
3760+
return NotImplemented
3761+
new = type(self)(self)
3762+
new.update(other)
3763+
return new
3764+
3765+
def __ror__(self, other):
3766+
if not isinstance(other, compat_collections_abc.Mapping):
3767+
return NotImplemented
3768+
new = type(other)(other)
3769+
new.update(self)
3770+
return new
3771+
3772+
def __ior__(self, other):
3773+
self.update(other)
3774+
return self
3775+
3776+
# optimisations
3777+
3778+
def __reversed__(self):
3779+
for from_ in reversed(self._order):
3780+
if from_ in self:
3781+
yield from_
3782+
3783+
def __contains__(self, item):
3784+
return dict.__contains__(self, item)
3785+
3786+
# allow overriding update without breaking __init__
3787+
def __update(self, *args, **kwargs):
3788+
super(compat_dict, self).update(*args, **kwargs)
3789+
3790+
compat_builtins_dict = dict
3791+
# Using the object's method, not dict's:
3792+
# an ordered dict's items can be returned unstably by unordered
3793+
# dict.items as if the method was not ((k, self[k]) for k in self)
3794+
compat_dict_items = lambda d: d.items()
3795+
3796+
36353797
legacy = [
36363798
'compat_HTMLParseError',
36373799
'compat_HTMLParser',
@@ -3662,19 +3824,24 @@ def compat_datetime_timedelta_total_seconds(td):
36623824

36633825
__all__ = [
36643826
'compat_Struct',
3827+
'compat_abc_ABC',
36653828
'compat_base64_b64decode',
36663829
'compat_basestring',
36673830
'compat_brotli',
3831+
'compat_builtins_dict',
36683832
'compat_casefold',
36693833
'compat_chr',
36703834
'compat_collections_abc',
36713835
'compat_collections_chain_map',
36723836
'compat_contextlib_suppress',
36733837
'compat_ctypes_WINFUNCTYPE',
36743838
'compat_datetime_timedelta_total_seconds',
3839+
'compat_dict',
3840+
'compat_dict_items',
36753841
'compat_etree_fromstring',
36763842
'compat_etree_iterfind',
36773843
'compat_filter',
3844+
'compat_filter_fns',
36783845
'compat_get_terminal_size',
36793846
'compat_getenv',
36803847
'compat_getpass_getpass',
@@ -3716,6 +3883,7 @@ def compat_datetime_timedelta_total_seconds(td):
37163883
'compat_struct_unpack',
37173884
'compat_subprocess_get_DEVNULL',
37183885
'compat_subprocess_Popen',
3886+
'compat_thread',
37193887
'compat_tokenize_tokenize',
37203888
'compat_urllib_error',
37213889
'compat_urllib_parse',

0 commit comments

Comments
 (0)