Extract thumbnail url
authorDesweR <egomail@inbox.ru>
Tue, 13 Oct 2015 09:29:16 +0000 (16:29 +0700)
committerSergey M․ <dstftw@gmail.com>
Tue, 13 Oct 2015 16:17:42 +0000 (22:17 +0600)
youtube_dl/extractor/yandexmusic.py

index 4098e4629d671850425025d08bab441a3745f7dd..6842f834f0c80578c5e1944f100d5dd054a4cef6 100644 (file)
@@ -46,6 +46,14 @@ class YandexMusicTrackIE(InfoExtractor):
                 % (data['host'], key, data['ts'] + data['path'], storage[1]))
 
     def _get_track_info(self, track):
+        album = track['albums'][0]
+        a_thumb = None
+
+        if 'coverUri' in album:
+            a_thumb = album['coverUri']
+            if a_thumb:
+                a_thumb = 'http://' + a_thumb.replace('%%', '1000x1000')
+
         return {
             'id': track['id'],
             'ext': 'mp3',
@@ -53,6 +61,7 @@ class YandexMusicTrackIE(InfoExtractor):
             'title': '%s - %s' % (track['artists'][0]['name'], track['title']),
             'filesize': int_or_none(track.get('fileSize')),
             'duration': float_or_none(track.get('durationMs'), 1000),
+            'thumbnail': a_thumb,
         }
 
     def _real_extract(self, url):