mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-14 06:27:19 +08:00
Removed redundant parentheses and replaced expressions of the form x = x + n with x += n
This commit is contained in:
parent
c9b32da1ec
commit
c370ced80e
@ -261,7 +261,7 @@ def xor(data1, data2):
|
||||
return [x^y for x, y in zip(data1, data2)]
|
||||
|
||||
def rijndael_mul(a, b):
|
||||
if(a==0 or b==0):
|
||||
if a==0 or b==0:
|
||||
return 0
|
||||
return RIJNDAEL_EXP_TABLE[(RIJNDAEL_LOG_TABLE[a] + RIJNDAEL_LOG_TABLE[b]) % 0xFF]
|
||||
|
||||
@ -301,10 +301,10 @@ def shift_rows_inv(data):
|
||||
|
||||
def inc(data):
|
||||
data = data[:] # copy
|
||||
for i in range(len(data)-1,-1,-1):
|
||||
for i in range(len(data)-1, -1, -1):
|
||||
if data[i] == 255:
|
||||
data[i] = 0
|
||||
else:
|
||||
data[i] = data[i] + 1
|
||||
data[i] += 1
|
||||
break
|
||||
return data
|
||||
|
@ -269,7 +269,7 @@ class InfoExtractor(object):
|
||||
msg += u' Visit %s for more details' % blocked_iframe
|
||||
raise ExtractorError(msg, expected=True)
|
||||
|
||||
return (content, urlh)
|
||||
return content, urlh
|
||||
|
||||
def _download_webpage(self, url_or_request, video_id, note=None, errnote=None, fatal=True):
|
||||
""" Returns the data of the page as a string """
|
||||
@ -399,7 +399,7 @@ class InfoExtractor(object):
|
||||
If there's no info available, return (None, None)
|
||||
"""
|
||||
if self._downloader is None:
|
||||
return (None, None)
|
||||
return None, None
|
||||
|
||||
username = None
|
||||
password = None
|
||||
@ -420,7 +420,7 @@ class InfoExtractor(object):
|
||||
except (IOError, netrc.NetrcParseError) as err:
|
||||
self._downloader.report_warning(u'parsing .netrc: %s' % compat_str(err))
|
||||
|
||||
return (username, password)
|
||||
return username, password
|
||||
|
||||
# Helper functions for extracting OpenGraph info
|
||||
@staticmethod
|
||||
|
@ -168,7 +168,7 @@ class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
|
||||
self._downloader.report_warning(u'unable to download video subtitles: %s' % compat_str(err))
|
||||
return {}
|
||||
info = json.loads(sub_list)
|
||||
if (info['total'] > 0):
|
||||
if info['total'] > 0:
|
||||
sub_lang_list = dict((l['language'], l['url']) for l in info['list'])
|
||||
return sub_lang_list
|
||||
self._downloader.report_warning(u'video doesn\'t have subtitles')
|
||||
|
@ -173,7 +173,7 @@ class FranceTVIE(FranceTVBaseInfoExtractor):
|
||||
class="francetv-video-player">'''),
|
||||
(r'<a id="player_direct" href="http://info\.francetelevisions'
|
||||
'\.fr/\?id-video=([^"/&]+)'),
|
||||
(r'<a class="video" id="ftv_player_(.+?)"'),
|
||||
r'<a class="video" id="ftv_player_(.+?)"',
|
||||
]
|
||||
video_id = self._html_search_regex(id_res, webpage, 'video ID')
|
||||
else:
|
||||
|
@ -22,7 +22,7 @@ class HarkIE(InfoExtractor):
|
||||
def _real_extract(self, url):
|
||||
mobj = re.match(self._VALID_URL, url)
|
||||
video_id = mobj.group(1)
|
||||
json_url = "http://www.hark.com/clips/%s.json" %(video_id)
|
||||
json_url = "http://www.hark.com/clips/%s.json" % video_id
|
||||
info_json = self._download_webpage(json_url, video_id)
|
||||
info = json.loads(info_json)
|
||||
final_url = info['url']
|
||||
|
@ -70,7 +70,7 @@ class JustinTVIE(InfoExtractor):
|
||||
'upload_date': video_date,
|
||||
'ext': video_extension,
|
||||
})
|
||||
return (len(response), info)
|
||||
return len(response), info
|
||||
|
||||
def _real_extract(self, url):
|
||||
mobj = re.match(self._VALID_URL, url)
|
||||
|
@ -1303,7 +1303,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
||||
raise ExtractorError(u'no conn, hlsvp or url_encoded_fmt_stream_map information found in video info')
|
||||
|
||||
# Look for the DASH manifest
|
||||
if (self._downloader.params.get('youtube_include_dash_manifest', False)):
|
||||
if self._downloader.params.get('youtube_include_dash_manifest'):
|
||||
try:
|
||||
# The DASH manifest used needs to be the one from the original video_webpage.
|
||||
# The one found in get_video_info seems to be using different signatures.
|
||||
|
@ -282,7 +282,7 @@ def htmlentity_transform(matchobj):
|
||||
return compat_chr(int(numstr, base))
|
||||
|
||||
# Unknown entity in name, return its literal representation
|
||||
return (u'&%s;' % entity)
|
||||
return u'&%s;' % entity
|
||||
|
||||
compat_html_parser.locatestarttagend = re.compile(r"""<[a-zA-Z][-.a-zA-Z0-9:_]*(?:\s+(?:(?<=['"\s])[^\s/>][^\s/=>]*(?:\s*=+\s*(?:'[^']*'|"[^"]*"|(?!['"])[^>\s]*))?\s*)*)?\s*""", re.VERBOSE) # backport bugfix
|
||||
class BaseHTMLParser(compat_html_parser.HTMLParser):
|
||||
@ -435,9 +435,9 @@ def sanitize_open(filename, open_mode):
|
||||
if sys.platform == 'win32':
|
||||
import msvcrt
|
||||
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
|
||||
return (sys.stdout.buffer if hasattr(sys.stdout, 'buffer') else sys.stdout, filename)
|
||||
return sys.stdout.buffer if hasattr(sys.stdout, 'buffer') else sys.stdout, filename
|
||||
stream = open(encodeFilename(filename), open_mode)
|
||||
return (stream, filename)
|
||||
return stream, filename
|
||||
except (IOError, OSError) as err:
|
||||
if err.errno in (errno.EACCES,):
|
||||
raise
|
||||
@ -452,7 +452,7 @@ def sanitize_open(filename, open_mode):
|
||||
else:
|
||||
# An exception here should be caught in the caller
|
||||
stream = open(encodeFilename(filename), open_mode)
|
||||
return (stream, alt_filename)
|
||||
return stream, alt_filename
|
||||
|
||||
|
||||
def timeconvert(timestr):
|
||||
@ -614,7 +614,7 @@ class ExtractorError(Exception):
|
||||
if video_id is not None:
|
||||
msg = video_id + ': ' + msg
|
||||
if not expected:
|
||||
msg = msg + u'; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type youtube-dl -U to update.'
|
||||
msg += u'; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type youtube-dl -U to update.'
|
||||
super(ExtractorError, self).__init__(msg)
|
||||
|
||||
self.traceback = tb
|
||||
|
Loading…
x
Reference in New Issue
Block a user