[cleanup] Misc

pull/7516/head
pukkandan 1 year ago
parent fa44802809
commit 337734d4a8
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39

@ -55,6 +55,7 @@ class CommitGroup(enum.Enum):
'dependencies', 'dependencies',
'jsinterp', 'jsinterp',
'outtmpl', 'outtmpl',
'formats',
'plugins', 'plugins',
'update', 'update',
'upstream', 'upstream',
@ -68,9 +69,9 @@ class CommitGroup(enum.Enum):
'misc', 'misc',
'test', 'test',
}, },
cls.EXTRACTOR: {'extractor'}, cls.EXTRACTOR: {'extractor', 'ie'},
cls.DOWNLOADER: {'downloader'}, cls.DOWNLOADER: {'downloader', 'fd'},
cls.POSTPROCESSOR: {'postprocessor'}, cls.POSTPROCESSOR: {'postprocessor', 'pp'},
}.items() }.items()
for name in names for name in names
} }

@ -8,7 +8,6 @@ ignore = E402,E501,E731,E741,W503
max_line_length = 120 max_line_length = 120
per_file_ignores = per_file_ignores =
devscripts/lazy_load_template.py: F401 devscripts/lazy_load_template.py: F401
yt_dlp/utils/__init__.py: F401, F403
[autoflake] [autoflake]

@ -3687,7 +3687,7 @@ class YoutubeDL:
def simplified_codec(f, field): def simplified_codec(f, field):
assert field in ('acodec', 'vcodec') assert field in ('acodec', 'vcodec')
codec = f.get(field, 'unknown') codec = f.get(field)
if not codec: if not codec:
return 'unknown' return 'unknown'
elif codec != 'none': elif codec != 'none':

@ -255,6 +255,7 @@ class FileDownloader:
@wrap_file_access('remove') @wrap_file_access('remove')
def try_remove(self, filename): def try_remove(self, filename):
if os.path.isfile(filename):
os.remove(filename) os.remove(filename)
@wrap_file_access('rename') @wrap_file_access('rename')

@ -300,9 +300,7 @@ class FragmentFD(FileDownloader):
def _finish_frag_download(self, ctx, info_dict): def _finish_frag_download(self, ctx, info_dict):
ctx['dest_stream'].close() ctx['dest_stream'].close()
if self.__do_ytdl_file(ctx): if self.__do_ytdl_file(ctx):
ytdl_filename = encodeFilename(self.ytdl_filename(ctx['filename'])) self.try_remove(self.ytdl_filename(ctx['filename']))
if os.path.isfile(ytdl_filename):
self.try_remove(ytdl_filename)
elapsed = time.time() - ctx['started'] elapsed = time.time() - ctx['started']
to_file = ctx['tmpfilename'] != '-' to_file = ctx['tmpfilename'] != '-'

@ -1473,7 +1473,7 @@ class AdobePassIE(InfoExtractor): # XXX: Conventionally, base classes should en
elif 'automatically signed in with' in provider_redirect_page: elif 'automatically signed in with' in provider_redirect_page:
# Seems like comcast is rolling up new way of automatically signing customers # Seems like comcast is rolling up new way of automatically signing customers
oauth_redirect_url = self._html_search_regex( oauth_redirect_url = self._html_search_regex(
r'continue:\s*"(https://oauth.xfinity.com/oauth/authorize\?.+)"', provider_redirect_page, r'continue:\s*"(https://oauth\.xfinity\.com/oauth/authorize\?.+)"', provider_redirect_page,
'oauth redirect (signed)') 'oauth redirect (signed)')
# Just need to process the request. No useful data comes back # Just need to process the request. No useful data comes back
self._download_webpage(oauth_redirect_url, video_id, 'Confirming auto login') self._download_webpage(oauth_redirect_url, video_id, 'Confirming auto login')

@ -527,7 +527,7 @@ class IqIE(InfoExtractor):
if player_js_cache: if player_js_cache:
return player_js_cache return player_js_cache
webpack_js_url = self._proto_relative_url(self._search_regex( webpack_js_url = self._proto_relative_url(self._search_regex(
r'<script src="((?:https?)?//stc.iqiyipic.com/_next/static/chunks/webpack-\w+\.js)"', webpage, 'webpack URL')) r'<script src="((?:https?:)?//stc\.iqiyipic\.com/_next/static/chunks/webpack-\w+\.js)"', webpage, 'webpack URL'))
webpack_js = self._download_webpage(webpack_js_url, video_id, note='Downloading webpack JS', errnote='Unable to download webpack JS') webpack_js = self._download_webpage(webpack_js_url, video_id, note='Downloading webpack JS', errnote='Unable to download webpack JS')
webpack_map = self._search_json( webpack_map = self._search_json(
r'["\']\s*\+\s*', webpack_js, 'JS locations', video_id, r'["\']\s*\+\s*', webpack_js, 'JS locations', video_id,

@ -22,7 +22,7 @@ class VShareIE(InfoExtractor):
packed = self._search_regex( packed = self._search_regex(
r'(eval\(function.+)', webpage, 'packed code') r'(eval\(function.+)', webpage, 'packed code')
unpacked = decode_packed_codes(packed) unpacked = decode_packed_codes(packed)
digits = self._search_regex(r'\[((?:\d+,?)+)\]', unpacked, 'digits') digits = self._search_regex(r'\[([\d,]+)\]', unpacked, 'digits')
digits = [int(digit) for digit in digits.split(',')] digits = [int(digit) for digit in digits.split(',')]
key_digit = self._search_regex( key_digit = self._search_regex(
r'fromCharCode\(.+?(\d+)\)}', unpacked, 'key digit') r'fromCharCode\(.+?(\d+)\)}', unpacked, 'key digit')

@ -3117,7 +3117,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
return funcname return funcname
return json.loads(js_to_json(self._search_regex( return json.loads(js_to_json(self._search_regex(
rf'var {re.escape(funcname)}\s*=\s*(\[.+?\])[,;]', jscode, rf'var {re.escape(funcname)}\s*=\s*(\[.+?\])\s*[,;]', jscode,
f'Initial JS player n function list ({funcname}.{idx})')))[int(idx)] f'Initial JS player n function list ({funcname}.{idx})')))[int(idx)]
def _extract_n_function_code(self, video_id, player_url): def _extract_n_function_code(self, video_id, player_url):

@ -1,3 +1,4 @@
# flake8: noqa: F401, F403
import warnings import warnings
from ..compat.compat_utils import passthrough_module from ..compat.compat_utils import passthrough_module

Loading…
Cancel
Save