Skip to content

Commit

Permalink
Merge pull request #156 from Senpos/iss-129
Browse files Browse the repository at this point in the history
fix Pandora.com support
  • Loading branch information
senpos authored Jun 23, 2017
2 parents 11590fd + 7948959 commit 522e629
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions data/common/websites-support/websites/pandora.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,33 @@ const PandoraTrackListener = function() {};
PandoraTrackListener.prototype = new window.UNPCommon.WebsiteTrackListener();

PandoraTrackListener.prototype.isPlaying = function() {
return $('.pauseButton').is(':visible');
return $('button[data-qa=pause_button]').length ? true : false;
};

PandoraTrackListener.prototype.findSelector = function() {
this.selector = undefined;
this.selector = $('div.NowPlaying__aboveFold');
};

PandoraTrackListener.prototype.scrapPlayData = function() {
this.artistName = $('.playerBarArtist').text();
this.trackName = $('.playerBarSong').text();
this.artistName = this.selector.find('a[data-qa=playing_artist_name]').text();

// since track name and url are in the same selector, doing all stuff here
this.trackSelector = this.selector.find('a[data-qa=playing_track_title]');
this.trackName = this.trackSelector.text();
this.url = 'https://pandora.com' + this.trackSelector.attr('href');
return true;
};

PandoraTrackListener.prototype.scrapAlbumName = function() {
return $('.playerBarAlbum').text();
return this.selector.find('a[data-qa=playing_album_name]').text();
};

PandoraTrackListener.prototype.scrapAlbumArt = function() {
return $('.playerBarArt').attr('src');
};

PandoraTrackListener.prototype.scrapUrl = function() {
return $('.playerBarSong').attr('href');
return this.selector.find('div[data-qa=album_active_image]').css('background-image').replace('url("', '').replace('")', '');
};

PandoraTrackListener.prototype.scrapDuration = function() {
let remainingTime = $('.remainingTime').text();
remainingTime = remainingTime.substr(1, remainingTime.length);
return window.UNPCommon.secToHms(window.UNPCommon.hmsToSec(remainingTime) + window.UNPCommon.hmsToSec($('.elapsedTime').text()));
return $('span[data-qa=remaining_time]').text();
};

window.UNPCommon.runTrackListenerInterval(new PandoraTrackListener());
window.UNPCommon.runTrackListenerInterval(new PandoraTrackListener());

0 comments on commit 522e629

Please sign in to comment.