Skip to content

Commit

Permalink
search for thumbnails with highest resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
KoljaWindeler committed Jul 27, 2021
1 parent 0e065a1 commit 7d60a63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/ytube_music_player/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"@KoljaWindeler"
],
"iot_class": "cloud_polling",
"version": "20210727.01"
"version": "20210727.02"
}
16 changes: 10 additions & 6 deletions custom_components/ytube_music_player/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,17 +762,21 @@ def extract_info(self, _track):
pass

try:
_album_art_ref = None
if 'thumbnail' in _track:
_album_art_ref = _track['thumbnail'] ## returns a list,
if 'thumbnails' in _album_art_ref:
_album_art_ref = _album_art_ref['thumbnails']
# thumbnail [0] is super tiny 32x32? / thumbnail [1] is ok-ish / thumbnail [2] is quite nice quality
if isinstance(_album_art_ref,list):
info['track_album_cover'] = _album_art_ref[len(_album_art_ref)-1]['url']
elif 'thumbnails' in _track:
_album_art_ref = _track['thumbnails'] ## returns a list
if isinstance(_album_art_ref,list):
info['track_album_cover'] = _album_art_ref[len(_album_art_ref)-1]['url']

if isinstance(_album_art_ref,list):
th_width = 0
for th in _album_art_ref:
if('width' in th and 'url' in th):
if(th['width']>th_width):
th_width = th['width']
info['track_album_cover'] = th['url']
except:
pass

Expand Down Expand Up @@ -1240,7 +1244,7 @@ async def async_get_url(self, videoId=None, retry=True):
#self.log_me('debug','found stream')
#self.log_me('debug',streamingData[i])
if('audioQuality' in streamingData[i]):
self.log_me('debug','- found stream with audioQuality '+streamingData[i]['audioQuality']+' ('+str(i)+')')
# self.log_me('debug','- found stream with audioQuality '+streamingData[i]['audioQuality']+' ('+str(i)+')')
# store only stream with better quality, accept 0 once
if(quality_mapper.get(streamingData[i]['audioQuality'],0) > found_quality):
found_quality = quality_mapper.get(streamingData[i]['audioQuality'],0)
Expand Down

0 comments on commit 7d60a63

Please sign in to comment.