[cleanup] Misc cleanup

This commit is contained in:
pukkandan
2022-05-16 19:36:36 +05:30
parent 5d5c0f7e99
commit 2414649192
22 changed files with 79 additions and 103 deletions

View File

@@ -53,11 +53,6 @@ class AnimeLabBaseIE(InfoExtractor):
class AnimeLabIE(AnimeLabBaseIE):
_VALID_URL = r'https?://(?:www\.)?animelab\.com/player/(?P<id>[^/]+)'
# the following tests require authentication, but a free account will suffice
# just set 'usenetrc' to true in test/local_parameters.json if you use a .netrc file
# or you can set 'username' and 'password' there
# the tests also select a specific format so that the same video is downloaded
# regardless of whether the user is premium or not (needs testing on a premium account)
_TEST = {
'url': 'https://www.animelab.com/player/fullmetal-alchemist-brotherhood-episode-42',
'md5': '05bde4b91a5d1ff46ef5b94df05b0f7f',
@@ -76,9 +71,9 @@ class AnimeLabIE(AnimeLabBaseIE):
'season_id': '38',
},
'params': {
# Ensure the same video is downloaded whether the user is premium or not
'format': '[format_id=21711_yeshardsubbed_ja-JP][height=480]',
},
'skip': 'All AnimeLab content requires authentication',
}
def _real_extract(self, url):

View File

@@ -3639,20 +3639,17 @@ class InfoExtractor:
t['name'] = cls.ie_key()
yield t
@classproperty
def age_limit(cls):
"""Get age limit from the testcases"""
return max(traverse_obj(
tuple(cls.get_testcases(include_onlymatching=False)),
(..., (('playlist', 0), None), 'info_dict', 'age_limit')) or [0])
@classmethod
def is_suitable(cls, age_limit):
""" Test whether the extractor is generally suitable for the given
age limit (i.e. pornographic sites are not, all others usually are) """
any_restricted = False
for tc in cls.get_testcases(include_onlymatching=False):
if tc.get('playlist', []):
tc = tc['playlist'][0]
is_restricted = age_restricted(tc.get('info_dict', {}).get('age_limit'), age_limit)
if not is_restricted:
return True
any_restricted = any_restricted or is_restricted
return not any_restricted
"""Test whether the extractor is generally suitable for the given age limit"""
return not age_restricted(cls.age_limit, age_limit)
@classmethod
def description(cls, *, markdown=True, search_examples=None):
@@ -3745,11 +3742,15 @@ class InfoExtractor:
def _get_automatic_captions(self, *args, **kwargs):
raise NotImplementedError('This method must be implemented by subclasses')
@property
def _cookies_passed(self):
"""Whether cookies have been passed to YoutubeDL"""
return self.get_param('cookiefile') is not None or self.get_param('cookiesfrombrowser') is not None
def mark_watched(self, *args, **kwargs):
if not self.get_param('mark_watched', False):
return
if (self.supports_login() and self._get_login_info()[0] is not None
or self.get_param('cookiefile') or self.get_param('cookiesfrombrowser')):
if self.supports_login() and self._get_login_info()[0] is not None or self._cookies_passed:
self._mark_watched(*args, **kwargs)
def _mark_watched(self, *args, **kwargs):

View File

@@ -4106,7 +4106,7 @@ class GenericIE(InfoExtractor):
entries.append(entry_info_dict)
if len(entries) == 1:
return entries[0]
return merge_dicts(entries[0], info_dict)
else:
for num, e in enumerate(entries, start=1):
# 'url' results don't have a title

View File

@@ -119,7 +119,7 @@ class VimeoBaseInfoExtractor(InfoExtractor):
def _parse_config(self, config, video_id):
video_data = config['video']
video_title = video_data['title']
video_title = video_data.get('title')
live_event = video_data.get('live_event') or {}
is_live = live_event.get('status') == 'started'
request = config.get('request') or {}

View File

@@ -590,7 +590,6 @@ class VKWallPostIE(VKBaseIE):
}],
'params': {
'skip_download': True,
'usenetrc': True,
},
'skip': 'Requires vk account credentials',
}, {
@@ -601,9 +600,6 @@ class VKWallPostIE(VKBaseIE):
'title': 'Сергей Горбунов - Wall post 85155021_6319',
},
'playlist_count': 1,
'params': {
'usenetrc': True,
},
'skip': 'Requires vk account credentials',
}, {
# wall page URL

View File

@@ -394,9 +394,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
self._check_login_required()
def _check_login_required(self):
if (self._LOGIN_REQUIRED
and self.get_param('cookiefile') is None
and self.get_param('cookiesfrombrowser') is None):
if self._LOGIN_REQUIRED and not self._cookies_passed:
self.raise_login_required('Login details are needed to download this content', method='cookies')
_YT_INITIAL_DATA_RE = r'(?:window\s*\[\s*["\']ytInitialData["\']\s*\]|ytInitialData)\s*=\s*({.+?})\s*;'
@@ -4282,8 +4280,7 @@ class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor):
start = next((i for i, v in enumerate(videos) if v['id'] == last_id), -1) + 1
if start >= len(videos):
return
for video in videos[start:]:
yield video
yield from videos[start:]
first_id = first_id or videos[0]['id']
last_id = videos[-1]['id']
watch_endpoint = try_get(

View File

@@ -59,7 +59,7 @@ class ZingMp3BaseIE(InfoExtractor):
return (resp or {}).get('data') or {}
def _real_initialize(self):
if not self.get_param('cookiefile') and not self.get_param('cookiesfrombrowser'):
if not self._cookies_passed:
self._request_webpage(
self._api_url('bai-hat', {'id': ''}), None, note='Updating cookies')