[cleanup] Misc

This commit is contained in:
pukkandan 2023-07-06 20:09:42 +05:30
parent fa44802809
commit 337734d4a8
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39
10 changed files with 13 additions and 13 deletions

View File

@ -55,6 +55,7 @@ def commit_lookup(cls):
'dependencies', 'dependencies',
'jsinterp', 'jsinterp',
'outtmpl', 'outtmpl',
'formats',
'plugins', 'plugins',
'update', 'update',
'upstream', 'upstream',
@ -68,9 +69,9 @@ def commit_lookup(cls):
'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
} }

View File

@ -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]

View File

@ -3687,7 +3687,7 @@ def render_formats_table(self, info_dict):
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':

View File

@ -255,7 +255,8 @@ def sanitize_open(self, filename, open_mode):
@wrap_file_access('remove') @wrap_file_access('remove')
def try_remove(self, filename): def try_remove(self, filename):
os.remove(filename) if os.path.isfile(filename):
os.remove(filename)
@wrap_file_access('rename') @wrap_file_access('rename')
def try_rename(self, old_filename, new_filename): def try_rename(self, old_filename, new_filename):

View File

@ -300,9 +300,7 @@ def frag_progress_hook(s):
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'] != '-'

View File

@ -1473,7 +1473,7 @@ def extract_redirect_url(html, url=None, fatal=False):
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')

View File

@ -527,7 +527,7 @@ def _extract_vms_player_js(self, webpage, video_id):
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,

View File

@ -22,7 +22,7 @@ def _extract_packed(self, webpage):
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')

View File

@ -3117,7 +3117,7 @@ def _extract_n_function_name(self, jscode):
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):

View File

@ -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