Skip to content

Commit

Permalink
[cleanup] Fix misc bugs (yt-dlp#8968)
Browse files Browse the repository at this point in the history
Closes yt-dlp#8816

Authored by: bashonly, seproDev, pukkandan, Grub4k
  • Loading branch information
pukkandan committed Mar 10, 2024
1 parent 47ab66d commit 93240fc
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion yt_dlp/extractor/abematv.py
Expand Up @@ -53,7 +53,7 @@ def __init__(self, ie: 'AbemaTVIE'):
# 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 = ie

def _get_videokey_from_ticket(self, ticket):
Expand Down
1 change: 0 additions & 1 deletion yt_dlp/extractor/adultswim.py
Expand Up @@ -107,7 +107,6 @@ def _real_extract(self, url):
title
tvRating
}''' % episode_path
['getVideoBySlug']
else:
query = query % '''metaDescription
title
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/extractor/antenna.py
Expand Up @@ -67,7 +67,7 @@ def _real_extract(self, url):
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 info


Expand Down
1 change: 1 addition & 0 deletions yt_dlp/extractor/bilibili.py
Expand Up @@ -1965,6 +1965,7 @@ class BiliIntlIE(BiliIntlBaseIE):
'only_matching': True,
}]

@staticmethod
def _make_url(video_id, series_id=None):
if series_id:
return f'https://www.bilibili.tv/en/play/{series_id}/{video_id}'
Expand Down
7 changes: 5 additions & 2 deletions yt_dlp/extractor/common.py
Expand Up @@ -747,7 +747,7 @@ def extract(self, url):
raise
except 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_NAME
e.traceback = e.traceback or sys.exc_info()[2]
raise
except IncompleteRead as e:
Expand Down Expand Up @@ -1339,7 +1339,10 @@ def _get_netrc_login_info(self, netrc_machine=None):
else:
return None, None
if 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):
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/extractor/gamejolt.py
Expand Up @@ -88,7 +88,7 @@ def _parse_post(self, post_data):
'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')),
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/extractor/minoto.py
Expand Up @@ -21,7 +21,7 @@ def _real_extract(self, url):
continue
container = 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({
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/extractor/myvideoge.py
Expand Up @@ -64,7 +64,7 @@ def _real_extract(self, url):
# translate any ka month to an en one
re.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 {
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/extractor/myvidster.py
Expand Up @@ -2,7 +2,7 @@


class 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',
Expand Down
8 changes: 4 additions & 4 deletions yt_dlp/extractor/rockstargames.py
Expand Up @@ -38,14 +38,14 @@ def _real_extract(self, url):
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,
})
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/extractor/slideslive.py
Expand Up @@ -386,7 +386,7 @@ def _extract_custom_m3u8_info(self, m3u8_data):
if not line.startswith('#EXT-SL-'):
continue
tag, _, value = line.partition(':')
key = lookup.get(tag.lstrip('#EXT-SL-'))
key = lookup.get(tag[8:])
if not key:
continue
m3u8_dict[key] = value
Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/networking/_requests.py
Expand Up @@ -116,7 +116,7 @@ def subn(self, repl, string, *args, **kwargs):
"""

if urllib3_version < (2, 0, 0):
with contextlib.suppress():
with contextlib.suppress(Exception):
urllib3.util.IS_SECURETRANSPORT = urllib3.util.ssl_.IS_SECURETRANSPORT = True


Expand Down
3 changes: 2 additions & 1 deletion yt_dlp/utils/_utils.py
Expand Up @@ -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
Expand Down

0 comments on commit 93240fc

Please sign in to comment.