Wykks / Untamed-Now-Playing-Next

Untamed-Now-Playing
74 stars 28 forks source link

Is plex support possible? #96

Closed furgoose closed 8 years ago

furgoose commented 8 years ago

https://app.plex.tv

Wykks commented 8 years ago

Hum not sure about this one, seems a bit too long to setup for me. PR accepted of course, it's quite easy to add a website support most of the time ! :)

furgoose commented 8 years ago

Not too proficient in JS, but here's what I came up with if you need it:

const PlexTrackListener = function() {};
PlexTrackListener.prototype = new window.UNPCommon.WebsiteTrackListener();

PlexTrackListener.prototype.isPlaying = function() {
    return $('.play-btn').hasClass('hidden');
};

PlexTrackListener.prototype.scrapPlayData = function() {
    this.artistName = $('.grandparent-title').text();
    this.trackName = $('.item-title').text();
    return true;
};

PlexTrackListener.prototype.scrapAlbumArt = function() {
    return $('.media-poster-container > .media-poster').attr('data-image-url').concat('.jpeg').replace('&width=80&height=80','&width=250&height=250');
};

PlexTrackListener.prototype.scrapUrl = function() {
    return 'https://app.plex.tv/web/app';
};

PlexTrackListener.prototype.scrapDuration = function() {
    return $('.player-duration').text();
};

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

Is it possible to add a current duration variable? Where should I look to add something like that?

Wykks commented 8 years ago

Sounds good to me, thanks :+1:

There's currently no way to add the current time currently since nobody really asked for this.

papasmurftv commented 8 years ago

I'm not sure if this was tested, but the plugin is not working with plex. I would be interested to see what version of Plex Media Server exofudge is running. Let me know how I can help you debug this issue.

Edit: It seems like the plugin won't correctly read data correctly unless you are at the plex home screen. If you have selected an album page and start playing music the text file will not update. If you start playing music then go to the home page, it will correctly update the text file. This is a suitable workaround for now.

furgoose commented 8 years ago

It works for me, although it can break sometimes. I think it needs a better trigger for detecting media changing, or the website filter needs altering (Not sure how to add either of these). My plex version is 0.9.16.6 (Latest)