[refactor] Do not specify redundant None as second argument in dict.get()

master
Sergey M․ 8 years ago
parent c78c9cd10d
commit d800609c62

@ -605,12 +605,12 @@ class YoutubeDL(object):
if rejecttitle: if rejecttitle:
if re.search(rejecttitle, title, re.IGNORECASE): if re.search(rejecttitle, title, re.IGNORECASE):
return '"' + title + '" title matched reject pattern "' + rejecttitle + '"' return '"' + title + '" title matched reject pattern "' + rejecttitle + '"'
date = info_dict.get('upload_date', None) date = info_dict.get('upload_date')
if date is not None: if date is not None:
dateRange = self.params.get('daterange', DateRange()) dateRange = self.params.get('daterange', DateRange())
if date not in dateRange: if date not in dateRange:
return '%s upload date is not in range %s' % (date_from_str(date).isoformat(), dateRange) return '%s upload date is not in range %s' % (date_from_str(date).isoformat(), dateRange)
view_count = info_dict.get('view_count', None) view_count = info_dict.get('view_count')
if view_count is not None: if view_count is not None:
min_views = self.params.get('min_views') min_views = self.params.get('min_views')
if min_views is not None and view_count < min_views: if min_views is not None and view_count < min_views:
@ -747,18 +747,18 @@ class YoutubeDL(object):
new_result, download=download, extra_info=extra_info) new_result, download=download, extra_info=extra_info)
elif result_type == 'playlist' or result_type == 'multi_video': elif result_type == 'playlist' or result_type == 'multi_video':
# We process each entry in the playlist # We process each entry in the playlist
playlist = ie_result.get('title', None) or ie_result.get('id', None) playlist = ie_result.get('title') or ie_result.get('id')
self.to_screen('[download] Downloading playlist: %s' % playlist) self.to_screen('[download] Downloading playlist: %s' % playlist)
playlist_results = [] playlist_results = []
playliststart = self.params.get('playliststart', 1) - 1 playliststart = self.params.get('playliststart', 1) - 1
playlistend = self.params.get('playlistend', None) playlistend = self.params.get('playlistend')
# For backwards compatibility, interpret -1 as whole list # For backwards compatibility, interpret -1 as whole list
if playlistend == -1: if playlistend == -1:
playlistend = None playlistend = None
playlistitems_str = self.params.get('playlist_items', None) playlistitems_str = self.params.get('playlist_items')
playlistitems = None playlistitems = None
if playlistitems_str is not None: if playlistitems_str is not None:
def iter_playlistitems(format): def iter_playlistitems(format):

@ -157,7 +157,7 @@ class FileDownloader(object):
def slow_down(self, start_time, now, byte_counter): def slow_down(self, start_time, now, byte_counter):
"""Sleep if the download speed is over the rate limit.""" """Sleep if the download speed is over the rate limit."""
rate_limit = self.params.get('ratelimit', None) rate_limit = self.params.get('ratelimit')
if rate_limit is None or byte_counter == 0: if rate_limit is None or byte_counter == 0:
return return
if now is None: if now is None:

@ -38,7 +38,7 @@ class FragmentFD(FileDownloader):
'continuedl': True, 'continuedl': True,
'quiet': True, 'quiet': True,
'noprogress': True, 'noprogress': True,
'ratelimit': self.params.get('ratelimit', None), 'ratelimit': self.params.get('ratelimit'),
'retries': self.params.get('retries', 0), 'retries': self.params.get('retries', 0),
'test': self.params.get('test', False), 'test': self.params.get('test', False),
} }

@ -140,8 +140,8 @@ class HttpFD(FileDownloader):
if data_len is not None: if data_len is not None:
data_len = int(data_len) + resume_len data_len = int(data_len) + resume_len
min_data_len = self.params.get("min_filesize", None) min_data_len = self.params.get("min_filesize")
max_data_len = self.params.get("max_filesize", None) max_data_len = self.params.get("max_filesize")
if min_data_len is not None and data_len < min_data_len: if min_data_len is not None and data_len < min_data_len:
self.to_screen('\r[download] File is smaller than min-filesize (%s bytes < %s bytes). Aborting.' % (data_len, min_data_len)) self.to_screen('\r[download] File is smaller than min-filesize (%s bytes < %s bytes). Aborting.' % (data_len, min_data_len))
return False return False

@ -94,15 +94,15 @@ class RtmpFD(FileDownloader):
return proc.returncode return proc.returncode
url = info_dict['url'] url = info_dict['url']
player_url = info_dict.get('player_url', None) player_url = info_dict.get('player_url')
page_url = info_dict.get('page_url', None) page_url = info_dict.get('page_url')
app = info_dict.get('app', None) app = info_dict.get('app')
play_path = info_dict.get('play_path', None) play_path = info_dict.get('play_path')
tc_url = info_dict.get('tc_url', None) tc_url = info_dict.get('tc_url')
flash_version = info_dict.get('flash_version', None) flash_version = info_dict.get('flash_version')
live = info_dict.get('rtmp_live', False) live = info_dict.get('rtmp_live', False)
conn = info_dict.get('rtmp_conn', None) conn = info_dict.get('rtmp_conn')
protocol = info_dict.get('rtmp_protocol', None) protocol = info_dict.get('rtmp_protocol')
real_time = info_dict.get('rtmp_real_time', False) real_time = info_dict.get('rtmp_real_time', False)
no_resume = info_dict.get('no_resume', False) no_resume = info_dict.get('no_resume', False)
continue_dl = self.params.get('continuedl', True) continue_dl = self.params.get('continuedl', True)

@ -636,7 +636,7 @@ class InfoExtractor(object):
downloader_params = self._downloader.params downloader_params = self._downloader.params
# Attempt to use provided username and password or .netrc data # Attempt to use provided username and password or .netrc data
if downloader_params.get('username', None) is not None: if downloader_params.get('username') is not None:
username = downloader_params['username'] username = downloader_params['username']
password = downloader_params['password'] password = downloader_params['password']
elif downloader_params.get('usenetrc', False): elif downloader_params.get('usenetrc', False):
@ -663,7 +663,7 @@ class InfoExtractor(object):
return None return None
downloader_params = self._downloader.params downloader_params = self._downloader.params
if downloader_params.get('twofactor', None) is not None: if downloader_params.get('twofactor') is not None:
return downloader_params['twofactor'] return downloader_params['twofactor']
return compat_getpass('Type %s and press [Return]: ' % note) return compat_getpass('Type %s and press [Return]: ' % note)
@ -744,7 +744,7 @@ class InfoExtractor(object):
'mature': 17, 'mature': 17,
'restricted': 19, 'restricted': 19,
} }
return RATING_TABLE.get(rating.lower(), None) return RATING_TABLE.get(rating.lower())
def _family_friendly_search(self, html): def _family_friendly_search(self, html):
# See http://schema.org/VideoObject # See http://schema.org/VideoObject
@ -759,7 +759,7 @@ class InfoExtractor(object):
'0': 18, '0': 18,
'false': 18, 'false': 18,
} }
return RATING_TABLE.get(family_friendly.lower(), None) return RATING_TABLE.get(family_friendly.lower())
def _twitter_search_player(self, html): def _twitter_search_player(self, html):
return self._html_search_meta('twitter:player', html, return self._html_search_meta('twitter:player', html,

@ -170,7 +170,7 @@ class SmotriIE(InfoExtractor):
'getvideoinfo': '1', 'getvideoinfo': '1',
} }
video_password = self._downloader.params.get('videopassword', None) video_password = self._downloader.params.get('videopassword')
if video_password: if video_password:
video_form['pass'] = hashlib.md5(video_password.encode('utf-8')).hexdigest() video_form['pass'] = hashlib.md5(video_password.encode('utf-8')).hexdigest()
@ -356,7 +356,7 @@ class SmotriBroadcastIE(InfoExtractor):
url = 'http://smotri.com/broadcast/view/url/?ticket=%s' % ticket url = 'http://smotri.com/broadcast/view/url/?ticket=%s' % ticket
broadcast_password = self._downloader.params.get('videopassword', None) broadcast_password = self._downloader.params.get('videopassword')
if broadcast_password: if broadcast_password:
url += '&pass=%s' % hashlib.md5(broadcast_password.encode('utf-8')).hexdigest() url += '&pass=%s' % hashlib.md5(broadcast_password.encode('utf-8')).hexdigest()

@ -232,7 +232,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
return mobj.group(1) return mobj.group(1)
def _verify_video_password(self, url, video_id, webpage): def _verify_video_password(self, url, video_id, webpage):
password = self._downloader.params.get('videopassword', None) password = self._downloader.params.get('videopassword')
if password is None: if password is None:
raise ExtractorError('This video is protected by a password, use the --video-password option', expected=True) raise ExtractorError('This video is protected by a password, use the --video-password option', expected=True)
token, vuid = self._extract_xsrft_and_vuid(webpage) token, vuid = self._extract_xsrft_and_vuid(webpage)
@ -252,7 +252,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
'Verifying the password', 'Wrong password') 'Verifying the password', 'Wrong password')
def _verify_player_video_password(self, url, video_id): def _verify_player_video_password(self, url, video_id):
password = self._downloader.params.get('videopassword', None) password = self._downloader.params.get('videopassword')
if password is None: if password is None:
raise ExtractorError('This video is protected by a password, use the --video-password option') raise ExtractorError('This video is protected by a password, use the --video-password option')
data = urlencode_postdata(encode_dict({'password': password})) data = urlencode_postdata(encode_dict({'password': password}))
@ -516,7 +516,7 @@ class VimeoChannelIE(VimeoBaseInfoExtractor):
if not login_form: if not login_form:
return webpage return webpage
password = self._downloader.params.get('videopassword', None) password = self._downloader.params.get('videopassword')
if password is None: if password is None:
raise ExtractorError('This album is protected by a password, use the --video-password option', expected=True) raise ExtractorError('This album is protected by a password, use the --video-password option', expected=True)
fields = self._hidden_inputs(login_form) fields = self._hidden_inputs(login_form)

@ -214,7 +214,7 @@ class YoukuIE(InfoExtractor):
return raw_data['data'] return raw_data['data']
video_password = self._downloader.params.get('videopassword', None) video_password = self._downloader.params.get('videopassword')
# request basic data # request basic data
basic_data_url = "http://play.youku.com/play/get.json?vid=%s&ct=12" % video_id basic_data_url = "http://play.youku.com/play/get.json?vid=%s&ct=12" % video_id

@ -1744,7 +1744,7 @@ def parse_age_limit(s):
if s is None: if s is None:
return None return None
m = re.match(r'^(?P<age>\d{1,2})\+?$', s) m = re.match(r'^(?P<age>\d{1,2})\+?$', s)
return int(m.group('age')) if m else US_RATINGS.get(s, None) return int(m.group('age')) if m else US_RATINGS.get(s)
def strip_jsonp(code): def strip_jsonp(code):

Loading…
Cancel
Save