Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Plex Watchlist #2041

Merged
merged 3 commits into from
Mar 26, 2024
Merged

Conversation

Spacetech
Copy link

Addresses: #1828. Explanation below for how this works:

You can check your Plex Watchlist by going to https://metadata.provider.plex.tv/library/sections/watchlist/all?X-Plex-Token={token} (fill out the token param). Here's an example result:

<?xml version="1.0"?>
<MediaContainer librarySectionID="watchlist" librarySectionTitle="Watchlist" offset="0"
    totalSize="32" identifier="tv.plex.provider.metadata" size="20">
    <Video art="https://metadata-static.plex.tv/5/gracenote/5d3ffdbcdf1e8c07cffff3aad36ac0ce.jpg"
        banner="http://assets.fanart.tv/fanart/movies/46838/moviebanner/tucker--dale-vs-evil-51ab23d9dab5e.jpg"
        guid="plex://movie/5d776883ebdf2200209c104e"
        key="/library/metadata/5d776883ebdf2200209c104e" rating="8.5"
        ratingKey="5d776883ebdf2200209c104e" studio="Eden Rock Media"
        tagline="Evil just messed with the wrong hillbillies." type="movie"
        thumb="https://metadata-static.plex.tv/c/gracenote/ce5e380d9209dc7fa5fbb8fb3cff9d48.jpg"
        addedAt="1291852800" duration="5340000"
        publicPagesURL="https://watch.plex.tv/movie/tucker-and-dale-vs-evil"
        slug="tucker-and-dale-vs-evil" expiresAt="1713941940" userState="0"
        title="Tucker and Dale vs Evil" contentRating="R" originallyAvailableAt="2010-12-09"
        year="2010" availabilityId="62cf3270700e44e58631846c"
        streamingMediaId="62cf3270700e44e5863182d6" audienceRating="8.5"
        audienceRatingImage="rottentomatoes://image.rating.upright"
        ratingImage="rottentomatoes://image.rating.ripe" imdbRatingCount="192418"
        playableKey="provider://tv.plex.provider.vod/library/metadata/5d776883ebdf2200209c104e">
        ...
    </Video>
    <Video art="https://metadata-static.plex.tv/9/gracenote/91e174f0c46ea20c58192bfef5aa6f1e.jpg"
        guid="plex://movie/6310ea4493df84910ae108a2"
        key="/library/metadata/6310ea4493df84910ae108a2" rating="9.1"
        ratingKey="6310ea4493df84910ae108a2" studio="A24" tagline="Meet the man of your dreams."
        type="movie"
        thumb="https://metadata-static.plex.tv/6/gracenote/6b1ab0cb7db6d33b6de803e22d1db37b.jpg"
        addedAt="1699574400" duration="6120000"
        publicPagesURL="https://watch.plex.tv/movie/dream-scenario-2" slug="dream-scenario-2"
        expiresAt="1709942340" userState="0" title="Dream Scenario" contentRating="R"
        originallyAvailableAt="2023-11-10" year="2023" audienceRating="6.8"
        audienceRatingImage="rottentomatoes://image.rating.upright"
        ratingImage="rottentomatoes://image.rating.ripe" imdbRatingCount="39881">
        ...
    </Video>
    ...

Each Video element includes a guid. This is also known as a 'plex media key' in wiki land and every movie, TV show, TV season, & TV episode will have a unique guid assigned to it.

It's important to note that there is no id in the Video element and the key/ratingKey do not point to a key on your server (e.g. it's not like /library/metadata/123). This means that you cannot directly map the items in this response into your local server without changing the lookup strategy. My understanding is that lookups should use the guid instead.

Based on that, when we want to view the Watchlist in Kodi, we need to map the items from that Watchlist response into items that were synced into Kodi. We can do that by looking up items in the plex db based on that guid. The flow would be:
Watchlist Video.guid -> Plex DB lookup by guid -> Kodi item

This requires the addition of a new guid column in the plex db, which requires a database reset/recreation. I also added new indexes for that column to enable quick lookups.

The end result is that the Watchlist will sync correctly and show items that are available in Kodi.

Some pictures:

My watchlist on plex web:
2024-03-03_17-22-25

Me, about to add the watchlist to my home page in arctic fuse skin. It shows up alongside search, channels, watch later:
image

The watchlist items showing up on my home screen. Each item correctly points to the kodi item and is playable
image

@croneter
Copy link
Owner

croneter commented Mar 6, 2024

Love this!

@AvAars
Copy link

AvAars commented Mar 7, 2024

You read my mind! Was looking for this yesterday

Would it be possible to separate the watchlist per library as well?

@Spacetech
Copy link
Author

You read my mind! Was looking for this yesterday

Would it be possible to separate the watchlist per library as well?

I added that

@croneter
Copy link
Owner

Thanks so much!! ❤️

@croneter croneter merged commit 5e14075 into croneter:python3-beta Mar 26, 2024
1 check passed
@bokkoman
Copy link

I think this came in 3.9.1 of PKC? Cause I'm getting an error with that version that plex-guid is missing?
I had to revert back to 3.9.0.

@croneter
Copy link
Owner

Could you please share a debug log (see https://github.com/croneter/PlexKodiConnect/wiki/How-to-Report-A-Bug) and open a new issue? Thanks @bokkoman

@bokkoman
Copy link

Could you please share a debug log (see https://github.com/croneter/PlexKodiConnect/wiki/How-to-Report-A-Bug) and open a new issue? Thanks @bokkoman

Here's the log.
If you search for plex_guid you should find it.
kodi.log

I only had 1 item in Watchlist.

@AvAars
Copy link

AvAars commented Mar 27, 2024

Did you do a db reset @bokkoman ?

This requires the addition of a new guid column in the plex db, which requires a database reset/recreation.

@bokkoman
Copy link

bokkoman commented Mar 27, 2024

Did you do a db reset @bokkoman ?

This requires the addition of a new guid column in the plex db, which requires a database reset/recreation.

No? But you don't get this info when you update automatically.
In fact, imo, it should automatically reset your db if there's breaking changes like this.
Perhaps give a warning first that it is going to reset db because there's an update which requires a new DB.

Also, where does it say this? I know it was necessary with 3.8.8 (iirc) cause of the missing movies.
I know it is on this PR, but not in the update info on the Releases page.

croneter added a commit that referenced this pull request Mar 29, 2024
croneter added a commit that referenced this pull request Mar 29, 2024
Force a database reset, necessary due to #2041
@Spacetech Spacetech deleted the watchlist branch March 29, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants