A feature-rich command-line audio/video downloader
[cleanup] Fix misc bugs (#8968)
pukkandan93240fc1848d
diff --git a/yt_dlp/extractor/abematv.py b/yt_dlp/extractor/abematv.pyindex 6742f75d5b..fee7375eac 100644--- a/yt_dlp/extractor/abematv.py+++ b/yt_dlp/extractor/abematv.py@@ -53,7 +53,7 @@ class AbemaLicenseHandler(urllib.request.BaseHandler):# the protocol that this should really handle is 'abematv-license://'# abematv_license_open is just a placeholder for development purposes# ref. https://github.com/python/cpython/blob/f4c03484da59049eb62a9bf7777b963e2267d187/Lib/urllib/request.py#L510- setattr(self, 'abematv-license_open', getattr(self, 'abematv_license_open'))+ setattr(self, 'abematv-license_open', getattr(self, 'abematv_license_open', None))self.ie = iedef _get_videokey_from_ticket(self, ticket):diff --git a/yt_dlp/extractor/adultswim.py b/yt_dlp/extractor/adultswim.pyindex daaeddeb6e..d807c41812 100644--- a/yt_dlp/extractor/adultswim.py+++ b/yt_dlp/extractor/adultswim.py@@ -107,7 +107,6 @@ class AdultSwimIE(TurnerBaseIE):titletvRating}''' % episode_path- ['getVideoBySlug']else:query = query % '''metaDescriptiontitlediff --git a/yt_dlp/extractor/antenna.py b/yt_dlp/extractor/antenna.pyindex 17a4b6900d..2929d6550f 100644--- a/yt_dlp/extractor/antenna.py+++ b/yt_dlp/extractor/antenna.py@@ -67,7 +67,7 @@ class AntennaGrWatchIE(AntennaBaseIE):webpage = self._download_webpage(url, video_id)info = self._download_and_extract_api_data(video_id, netloc)info['description'] = self._og_search_description(webpage, default=None)- info['_old_archive_ids'] = [make_archive_id('Ant1NewsGrWatch', video_id)],+ info['_old_archive_ids'] = [make_archive_id('Ant1NewsGrWatch', video_id)]return infodiff --git a/yt_dlp/extractor/bilibili.py b/yt_dlp/extractor/bilibili.pyindex f4e1c91a8f..fee4b29940 100644--- a/yt_dlp/extractor/bilibili.py+++ b/yt_dlp/extractor/bilibili.py@@ -1965,6 +1965,7 @@ class BiliIntlIE(BiliIntlBaseIE):'only_matching': True,}]+ @staticmethoddef _make_url(video_id, series_id=None):if series_id:return f'https://www.bilibili.tv/en/play/{series_id}/{video_id}'diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.pyindex f57963da24..e776ccae92 100644--- a/yt_dlp/extractor/common.py+++ b/yt_dlp/extractor/common.py@@ -747,7 +747,7 @@ class InfoExtractor:raiseexcept ExtractorError as e:e.video_id = e.video_id or self.get_temp_id(url)- e.ie = e.ie or self.IE_NAME,+ e.ie = e.ie or self.IE_NAMEe.traceback = e.traceback or sys.exc_info()[2]raiseexcept IncompleteRead as e:@@ -1339,7 +1339,10 @@ class InfoExtractor:else:return None, Noneif not info:- raise netrc.NetrcParseError(f'No authenticators for {netrc_machine}')+ self.to_screen(f'No authenticators for {netrc_machine}')+ return None, None++ self.write_debug(f'Using netrc for {netrc_machine} authentication')return info[0], info[2]def _get_login_info(self, username_option='username', password_option='password', netrc_machine=None):diff --git a/yt_dlp/extractor/gamejolt.py b/yt_dlp/extractor/gamejolt.pyindex 4d57391ac7..1d3c0b1107 100644--- a/yt_dlp/extractor/gamejolt.py+++ b/yt_dlp/extractor/gamejolt.py@@ -88,7 +88,7 @@ class GameJoltBaseIE(InfoExtractor):'uploader_id': user_data.get('username'),'uploader_url': format_field(user_data, 'url', 'https://gamejolt.com%s'),'categories': [try_get(category, lambda x: '%s - %s' % (x['community']['name'], x['channel'].get('display_title') or x['channel']['title']))- for category in post_data.get('communities' or [])],+ for category in post_data.get('communities') or []],'tags': traverse_obj(lead_content, ('content', ..., 'content', ..., 'marks', ..., 'attrs', 'tag'), expected_type=str_or_none),'like_count': int_or_none(post_data.get('like_count')),diff --git a/yt_dlp/extractor/minoto.py b/yt_dlp/extractor/minoto.pyindex 8d18179c78..032bf3b711 100644--- a/yt_dlp/extractor/minoto.py+++ b/yt_dlp/extractor/minoto.py@@ -21,7 +21,7 @@ class MinotoIE(InfoExtractor):continuecontainer = fmt.get('container')if container == 'hls':- formats.extend(fmt_url, video_id, 'mp4', m3u8_id='hls', fatal=False)+ formats.extend(self._extract_m3u8_formats(fmt_url, video_id, 'mp4', m3u8_id='hls', fatal=False))else:fmt_profile = fmt.get('profile') or {}formats.append({diff --git a/yt_dlp/extractor/myvideoge.py b/yt_dlp/extractor/myvideoge.pyindex 64cee48e7f..3e0bb24995 100644--- a/yt_dlp/extractor/myvideoge.py+++ b/yt_dlp/extractor/myvideoge.py@@ -64,7 +64,7 @@ class MyVideoGeIE(InfoExtractor):# translate any ka month to an en onere.sub('|'.join(self._MONTH_NAMES_KA),lambda m: MONTH_NAMES['en'][self._MONTH_NAMES_KA.index(m.group(0))],- upload_date, re.I))+ upload_date, flags=re.I))if upload_date else None)return {diff --git a/yt_dlp/extractor/myvidster.py b/yt_dlp/extractor/myvidster.pyindex c91f294bf0..e3b700dbbb 100644--- a/yt_dlp/extractor/myvidster.py+++ b/yt_dlp/extractor/myvidster.py@@ -2,7 +2,7 @@ from .common import InfoExtractorclass MyVidsterIE(InfoExtractor):- _VALID_URL = r'https?://(?:www\.)?myvidster\.com/video/(?P<id>\d+)/'+ _VALID_URL = r'https?://(?:www\.)?myvidster\.com/video/(?P<id>\d+)'_TEST = {'url': 'http://www.myvidster.com/video/32059805/Hot_chemistry_with_raw_love_making',diff --git a/yt_dlp/extractor/rockstargames.py b/yt_dlp/extractor/rockstargames.pyindex b0b92e642b..16622430cd 100644--- a/yt_dlp/extractor/rockstargames.py+++ b/yt_dlp/extractor/rockstargames.py@@ -38,14 +38,14 @@ class RockstarGamesIE(InfoExtractor):title = video['title']formats = []- for video in video['files_processed']['video/mp4']:- if not video.get('src'):+ for v in video['files_processed']['video/mp4']:+ if not v.get('src'):continue- resolution = video.get('resolution')+ resolution = v.get('resolution')height = int_or_none(self._search_regex(r'^(\d+)[pP]$', resolution or '', 'height', default=None))formats.append({- 'url': self._proto_relative_url(video['src']),+ 'url': self._proto_relative_url(v['src']),'format_id': resolution,'height': height,})diff --git a/yt_dlp/extractor/slideslive.py b/yt_dlp/extractor/slideslive.pyindex df2af3b35d..c012dee593 100644--- a/yt_dlp/extractor/slideslive.py+++ b/yt_dlp/extractor/slideslive.py@@ -386,7 +386,7 @@ class SlidesLiveIE(InfoExtractor):if not line.startswith('#EXT-SL-'):continuetag, _, value = line.partition(':')- key = lookup.get(tag.lstrip('#EXT-SL-'))+ key = lookup.get(tag[8:])if not key:continuem3u8_dict[key] = valuediff --git a/yt_dlp/networking/_requests.py b/yt_dlp/networking/_requests.pyindex 7b19029bfe..6545028c81 100644--- a/yt_dlp/networking/_requests.py+++ b/yt_dlp/networking/_requests.py@@ -116,7 +116,7 @@ See: https://github.com/urllib3/urllib3/issues/517"""if urllib3_version < (2, 0, 0):- with contextlib.suppress():+ with contextlib.suppress(Exception):urllib3.util.IS_SECURETRANSPORT = urllib3.util.ssl_.IS_SECURETRANSPORT = Truediff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.pyindex d8b74423aa..49944e9d2b 100644--- a/yt_dlp/utils/_utils.py+++ b/yt_dlp/utils/_utils.py@@ -1424,7 +1424,8 @@ def write_string(s, out=None, encoding=None):s = re.sub(r'([\r\n]+)', r' \1', s)enc, buffer = None, out- if 'b' in getattr(out, 'mode', ''):+ # `mode` might be `None` (Ref: https://github.com/yt-dlp/yt-dlp/issues/8816)+ if 'b' in (getattr(out, 'mode', None) or ''):enc = encoding or preferredencoding()elif hasattr(out, 'buffer'):buffer = out.buffer