aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/openload.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/extractor/openload.py')
-rw-r--r--yt_dlp/extractor/openload.py29
1 files changed, 10 insertions, 19 deletions
diff --git a/yt_dlp/extractor/openload.py b/yt_dlp/extractor/openload.py
index fe4740aae..61e3a8b86 100644
--- a/yt_dlp/extractor/openload.py
+++ b/yt_dlp/extractor/openload.py
@@ -1,22 +1,17 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
+import contextlib
import json
import os
import subprocess
import tempfile
-from ..compat import (
- compat_urlparse,
- compat_kwargs,
-)
+from ..compat import compat_urlparse
from ..utils import (
+ ExtractorError,
+ Popen,
check_executable,
encodeArgument,
- ExtractorError,
get_exe_version,
is_outdated_version,
- Popen,
)
@@ -37,13 +32,11 @@ def cookie_to_dict(cookie):
cookie_dict['secure'] = cookie.secure
if cookie.discard is not None:
cookie_dict['discard'] = cookie.discard
- try:
+ with contextlib.suppress(TypeError):
if (cookie.has_nonstandard_attr('httpOnly')
or cookie.has_nonstandard_attr('httponly')
or cookie.has_nonstandard_attr('HttpOnly')):
cookie_dict['httponly'] = True
- except TypeError:
- pass
return cookie_dict
@@ -51,7 +44,7 @@ def cookie_jar_to_list(cookie_jar):
return [cookie_to_dict(cookie) for cookie in cookie_jar]
-class PhantomJSwrapper(object):
+class PhantomJSwrapper:
"""PhantomJS wrapper class
This class is experimental.
@@ -135,10 +128,8 @@ class PhantomJSwrapper(object):
def __del__(self):
for name in self._TMP_FILE_NAMES:
- try:
+ with contextlib.suppress(OSError, KeyError):
os.remove(self._TMP_FILES[name].name)
- except (IOError, OSError, KeyError):
- pass
def _save_cookies(self, url):
cookies = cookie_jar_to_list(self.extractor._downloader.cookiejar)
@@ -158,7 +149,7 @@ class PhantomJSwrapper(object):
cookie['rest'] = {'httpOnly': None}
if 'expiry' in cookie:
cookie['expire_time'] = cookie['expiry']
- self.extractor._set_cookie(**compat_kwargs(cookie))
+ self.extractor._set_cookie(**cookie)
def get(self, url, html=None, video_id=None, note=None, note2='Executing JS on webpage', headers={}, jscode='saveAndExit();'):
"""
@@ -218,9 +209,9 @@ class PhantomJSwrapper(object):
f.write(self._TEMPLATE.format(**replaces).encode('utf-8'))
if video_id is None:
- self.extractor.to_screen('%s' % (note2,))
+ self.extractor.to_screen(f'{note2}')
else:
- self.extractor.to_screen('%s: %s' % (video_id, note2))
+ self.extractor.to_screen(f'{video_id}: {note2}')
p = Popen(
[self.exe, '--ssl-protocol=any', self._TMP_FILES['script'].name],