1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-23 00:54:31 +01:00

Coding convention

This commit is contained in:
Luc Berge 2019-09-02 19:32:06 +02:00
parent fe7d38c793
commit e886898902

View File

@ -17,9 +17,9 @@ class DeezerBaseInfoExtractor(InfoExtractor):
self._downloader.report_warning('For now, this extractor only supports the 30 second previews. Patches welcome!') self._downloader.report_warning('For now, this extractor only supports the 30 second previews. Patches welcome!')
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
id = mobj.group('id') data_id = mobj.group('id')
webpage = self._download_webpage(url, id) webpage = self._download_webpage(url, data_id)
geoblocking_msg = self._html_search_regex( geoblocking_msg = self._html_search_regex(
r'<p class="soon-txt">(.*?)</p>', webpage, 'geoblocking message', r'<p class="soon-txt">(.*?)</p>', webpage, 'geoblocking message',
default=None) default=None)
@ -32,7 +32,7 @@ class DeezerBaseInfoExtractor(InfoExtractor):
r'naboo\.display\(\'[^\']+\',\s*(.*?)\);\n'), r'naboo\.display\(\'[^\']+\',\s*(.*?)\);\n'),
webpage, 'data JSON') webpage, 'data JSON')
data = json.loads(data_json) data = json.loads(data_json)
return id, webpage, data return data_id, webpage, data
class DeezerPlaylistIE(DeezerBaseInfoExtractor): class DeezerPlaylistIE(DeezerBaseInfoExtractor):
@ -51,17 +51,17 @@ class DeezerPlaylistIE(DeezerBaseInfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
playlist_id, webpage, data = self.get_data(url) playlist_id, webpage, data = self.get_data(url)
playlist_title = data.get('DATA').get('TITLE') playlist_title = data.get('DATA', {}).get('TITLE')
playlist_uploader = data.get('DATA').get('PARENT_USERNAME') playlist_uploader = data.get('DATA', {}).get('PARENT_USERNAME')
playlist_thumbnail = self._search_regex( playlist_thumbnail = self._search_regex(
r'<img id="naboo_playlist_image".*?src="([^"]+)"', webpage, r'<img id="naboo_playlist_image".*?src="([^"]+)"', webpage,
'playlist thumbnail') 'playlist thumbnail')
entries = [] entries = []
for s in data.get('SONGS').get('data'): for s in data.get('SONGS', {}).get('data'):
formats = [{ formats = [{
'format_id': 'preview', 'format_id': 'preview',
'url': s.get('MEDIA')[0].get('HREF'), 'url': s.get('MEDIA', [{}])[0].get('HREF'),
'preference': -100, # Only the first 30 seconds 'preference': -100, # Only the first 30 seconds
'ext': 'mp3', 'ext': 'mp3',
}] }]
@ -104,17 +104,17 @@ class DeezerAlbumIE(DeezerBaseInfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
album_id, webpage, data = self.get_data(url) album_id, webpage, data = self.get_data(url)
album_title = data.get('DATA').get('ALB_TITLE') album_title = data.get('DATA', {}).get('ALB_TITLE')
album_uploader = data.get('DATA').get('ART_NAME') album_uploader = data.get('DATA', {}).get('ART_NAME')
album_thumbnail = self._search_regex( album_thumbnail = self._search_regex(
r'<img id="naboo_album_image".*?src="([^"]+)"', webpage, r'<img id="naboo_album_image".*?src="([^"]+)"', webpage,
'album thumbnail') 'album thumbnail')
entries = [] entries = []
for s in data.get('SONGS').get('data'): for s in data.get('SONGS', {}).get('data'):
formats = [{ formats = [{
'format_id': 'preview', 'format_id': 'preview',
'url': s.get('MEDIA')[0].get('HREF'), 'url': s.get('MEDIA', [{}])[0].get('HREF'),
'preference': -100, # Only the first 30 seconds 'preference': -100, # Only the first 30 seconds
'ext': 'mp3', 'ext': 'mp3',
}] }]