Skip to content

Commit

Permalink
Temporary fix for the favorite issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
metoule committed Jan 27, 2023
1 parent 65d6ce5 commit 228b36b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scripts/deezer/player_observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
}

like() {
// TODO handle show and live_stream
$('.track-actions button.svg-icon-group-btn.option-btn').click();
}

Expand Down Expand Up @@ -71,6 +72,11 @@
return GetCover('talk', podcastId);
}

function isFavorite(type, id) {
// TODO handle show and live_stream
return $('.track-actions button.svg-icon-group-btn.option-btn > svg').data('testid') === 'HeartFillIcon';
}

function getSongMetadata() {
dzCurrentSong = dzPlayer.getCurrentSong() || {};
dzPrevSong = dzPlayer.getPrevSong() || {};
Expand All @@ -80,7 +86,7 @@
artist: dzCurrentSong.ART_NAME,
track: dzCurrentSong.SNG_TITLE,
albumPic: GetCoverFromAlbumId(dzCurrentSong.ALB_PICTURE),
isFavorite: userData.isFavorite('song', dzCurrentSong.SNG_ID),
isFavorite: isFavorite('song', dzCurrentSong.SNG_ID),
artistLink: '/artist/' + dzCurrentSong.ART_ID,
albumLink: '/album/' + dzCurrentSong.ALB_ID,
prevCover: GetCoverFromAlbumId(dzPrevSong.ALB_PICTURE),
Expand All @@ -97,7 +103,7 @@
artist: '',
track: dzCurrentSong.LIVESTREAM_TITLE,
albumPic: GetCoverFromStreamId(dzCurrentSong.LIVESTREAM_IMAGE_MD5),
isFavorite: userData.isFavorite('live_stream', dzCurrentSong.LIVE_ID),
isFavorite: isFavorite('live_stream', dzCurrentSong.LIVE_ID),
artistLink: '',
albumLink: '/radio',
prevCover: GetCoverFromStreamId(dzPrevSong.LIVESTREAM_IMAGE_MD5),
Expand All @@ -114,7 +120,7 @@
artist: dzCurrentSong.SHOW_NAME,
track: dzCurrentSong.EPISODE_TITLE,
albumPic: GetCoverFromPodcastId(dzCurrentSong.EPISODE_IMAGE_MD5 || dzCurrentSong.SHOW_ART_MD5),
isFavorite: userData.isFavorite('show', dzCurrentSong.SHOW_ID),
isFavorite: isFavorite('show', dzCurrentSong.SHOW_ID),
artistLink: '/show/' + dzCurrentSong.SHOW_ID,
albumLink: '/episode/' + dzCurrentSong.EPISODE_ID,
prevCover: GetCoverFromPodcastId(dzPrevSong.EPISODE_IMAGE_MD5 || dzPrevSong.SHOW_ART_MD5),
Expand Down Expand Up @@ -218,8 +224,8 @@

Events.subscribe(Events.player.paused, updateDeezerControlData);
Events.subscribe(Events.player.trackChange, updateDeezerControlData);
Events.subscribe(Events.user.addFavorite, updateDeezerControlData);
Events.subscribe(Events.user.deleteFavorite, updateDeezerControlData);
Events.subscribe(Events.user.addFavorite, updateDeezerControlData);
Events.subscribe(Events.user.deleteFavorite, updateDeezerControlData);

registerMediaSession();
updateDeezerControlData();
Expand Down

0 comments on commit 228b36b

Please sign in to comment.