trakt / Plex-Trakt-Scrobbler

Add what you are watching on Plex to trakt.tv
1.45k stars 167 forks source link

tv shows not scrobbling with new scanner/agent #596

Open rnpasinos opened 3 years ago

rnpasinos commented 3 years ago

i have recently created a new movies and tv shows library using the new scanner and agent.

the new movies library, using the PLEX MOVIE scanner and agent are scrobbling properly. i am able to verify that it's able to push and pull watched items and i am able to see the progress of the movie i am watching on trakt.

however, it's not the case for the new tv shows library, using the PLEX TV SERIES scanner and agent. i can confirm that scrobbling on my old library works, using the PLEX SERIES SCANNER.

for now, i'm keeping my old library and continue to watch tv shows from there. hopefully the devs can update the plug-in to support the new scanner/agent.

jeff15110168 commented 2 years ago

Ok, I redid my change as per suggested. The patch isn't needed, instead I've updated the build_episode routine for the scrobbling request so that if the episode being played is a single episode it'll just use all of the ID's that the plex metadata returned.

So how to apply this now?

Quickest way, just download the zip from my fork and replace your Trakttv.bundle plugin folder with the one you just downloaded.

After going away and spending a bit more time on it, I've improved my version so that it now pulls back the show metadata to get the external ids and year for the show, and passes it all along to Trakt as part of the scrobbling message.

So the scrobble message to trakt now looks something like:

{
    "app_date": None,
    "progress": 14.24,
    "app_version": "1.3.3",
    "show": {
        "title": "Hawkeye (2021)",
        "ids": {
            "imdb": "tt10160804",
            "tmdb": 88329,
            "tvdb": 367146
        },
        "year": 2021
    },
    "episode": {
        "season": 1,
        "number": 1,
        "title": "Never Meet Your Heroes"
    }
}

This should now mean that,

  1. the correct show is matched in trakt as I belive the ids take precendence over the show title when trakt is matching the show and now it's grabbing all the show ids and ignoring the episode ids.
  2. multipart episodes should now scrobble correctly again, there is already logic to figure out multipart episodes and which one to currently scrobble, so I've made sure it's still used as were now grabbing the correct show ids to send to trakt.

does replacing the zip folder of "trakttv.bundle" require you to reconfigure any sort of Trakt settings, or is it plug and play once you replace the entire folder?

edit - i tried replacing the folder as is, and then trying to gain access to the trakt plugin using both Kitana and http://trakt-for-plex.github.io/configuration/#/connect ; now i can't access trakt in both environments. When i searched up some of the error messages ("Plex account is missing the server token"), i get the exact same issue as reported here: https://github.com/trakt/Plex-Trakt-Scrobbler/issues/335. I also tried rolling back to my old traktv.bundle folder i replaced, and i now still can't access trakt (did i just nuke my trakt plugin install?)

image

image

jeff15110168 commented 2 years ago

@Cornishman I was following another issue thread (https://github.com/trakt/Plex-Trakt-Scrobbler/issues/611), and it led me to this where @rg9400 wrote:

To fix this issue, you just need to use the version in this PR. It's unclear when it will be merged since the maintainers aren't around. It grabs the token automatically from the settings without any further user intervention needed.

Do you know if this means that the trakttv.bundle needs to be updated to potentially be able to pull the authentication token "PlexOnlineToken"?

EDIT: Hmm....while researching my error messages above, suddenly both interfaces (Kitana and web) are working again for me (I have Corningman's fork installed). But now i dont have real-time scrobbling working anymore, i start playing a movie or tv show and it doesn't immediately show the playback progress bar that used to be almost instant. But when i did run a full-sync on Kitana, the tv shows with a suffix (like "Foundation (2021)") showed up in my Continue Watching inside trakt.tv. So i know the plugin is syncing correctly with Trakt <-> Plex, but real-time scrobbling somehow isn't working anymore.

Cornishman commented 2 years ago

@Cornishman I was following another issue thread (#611), and it led me to this where @rg9400 wrote:

To fix this issue, you just need to use the version in this PR. It's unclear when it will be merged since the maintainers aren't around. It grabs the token automatically from the settings without any further user intervention needed.

Do you know if this means that the trakttv.bundle needs to be updated to potentially be able to pull the authentication token "PlexOnlineToken"?

@jeff15110168 Ah, I was not aware of this other issue. However I am now as I too have just encountered the same issue with the PlexOnlineToken being missing.

What I might do is create a seperate branch which also includes that fix so that users can grab a single trakttv.bundle with both fixes involved. I'll update you once I get around to doing that.

In the mean time an alternative solution is to download my branch and replace your existing trakttv.bundle directory, then once you've done that, to download/copy this file and replace the Trakttv.bundle/Contents/Libraries/Shared/plugin/modules/migrations/account.py file with this, which is the file with the PlexOnlineToken fix.

the-jeffski commented 2 years ago

@Cornishman So I replaced with your code and I get a failure to scrobble. I tried then with a clean library, fresh set up of the plugin and imported one TV series using all defaults and the same occurs. Error I get in the Trakt log is:

2021-12-16 08:47:14,596 - plex_metadata.guid               (7fb3d1a79b38) :  WARNING (plex_metadata.guid:115) - Unsupported metadata agent: plex
2021-12-16 08:47:14,596 - plugin.scrobbler.methods.core.base (7fb3d1a79b38) :  WARNING (plugin.scrobbler.methods.core.base:14) - Unsupported guid: 'episode' (agent: 'plex')
2021-12-16 08:47:14,597 - plugin.scrobbler.methods.s_websocket (7fb3d1a79b38) :  INFO (plugin.scrobbler.methods.s_websocket:69) - No request returned for action 'start' (payload: {'part': 1, 'view_offset': 0, 'rating_key': 12})
2021-12-16 08:47:42,718 - plex.objects.core.base           (7fb3d1a79b38) :  WARNING (plex.objects.core.base:156) - [Episode] Omitted attribute: grandparentguid
2021-12-16 08:47:42,719 - plex.objects.core.base           (7fb3d1a79b38) :  WARNING (plex.objects.core.base:156) - [Episode] Omitted attribute: parentguid
2021-12-16 08:47:42,720 - pyemitter                        (7fb3d1a79b38) :  WARNING (pyemitter:178) - [websocket.playing] Exception raised in: WebSocket.on_playing - 'list' object has no attribute 'valid'
Traceback (most recent call last):
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/Trakttv.bundle/Contents/Libraries/Shared/pyemitter.py", line 175, in __call_sync
    callback(*args, **kwargs)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/Trakttv.bundle/Contents/Libraries/Shared/plugin/scrobbler/methods/s_websocket.py", line 65, in on_playing
    view_offset=payload.get('view_offset')
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/Trakttv.bundle/Contents/Libraries/Shared/plugin/scrobbler/methods/core/base.py", line 56, in build_request
    result = cls.build_episode(metadata, guid, part)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/Trakttv.bundle/Contents/Libraries/Shared/plugin/scrobbler/methods/core/base.py", line 84, in build_episode
    ids = Identifier.get_ids(episode.guids, strict=False)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/Trakttv.bundle/Contents/Libraries/Shared/plugin/core/identifier.py", line 22, in get_ids
    if guid and guid.valid and guid.service in GUID_SERVICES:
AttributeError: 'list' object has no attribute 'valid'
Cornishman commented 2 years ago

@the-jeffski Can I check, are you running a plex server version 1.22.3 or higher (which version?) and are you using the new Plex Scanner/Agents? The old Agents/Scanners I believe won't work with this change as they don't do metadata in the same way. image

The error seems to suggest an issue with the metadata Guid's attached to the epsiode, this could be because of the above not being configured, or it could be something else. Any chance you can grab the xml from plex for the episode via the "Get Info" -> "View XML" option in plex, that would show what it's pulling back. The bit we are focused on is the Guid nodes under the Video section.

<MediaContainer>
    <Video>
        <Media>
            <Part>
                ...
            </Part>
        </Media>
        <Guid id="imdb://tt10166574"/>
        <Guid id="tmdb://2670881"/>
        <Guid id="tvdb://8287132"/>
    </Video>
</MediaContainer>
the-jeffski commented 2 years ago

@Cornishman Yes, so created brand new docker instance and its running Version 1.25.2.5319 . Imported some files using the defaults so image And then connected trakt. Play episode and the error orccurs. I put the full xml here https://pastebin.com/MNkA1CS9 . The library scan has picked up 3 ID's.

Cornishman commented 2 years ago

@the-jeffski My apologies, I apparently missed that change and failed to commit it to my branch originally. I have now corrected that issue hopefully, so if you download the latest master version from my fork this hopefully works a lot better for you. Again sorry about that, was a very obvious oversight on my part! 😞

jeff15110168 commented 2 years ago

Thanks so much Cornishman for your help on this! Is the latest master you referenced right above include the fix you were mentioning below? I somehow have lost the ability to realtime scrobble (only sync works) so hoping I can get that back up and running.

@jeff15110168 Ah, I was not aware of this other issue. However I am now as I too have just encountered the same issue with the PlexOnlineToken being missing.

What I might do is create a seperate branch which also includes that fix so that users can grab a single trakttv.bundle with both fixes involved. I'll update you once I get around to doing that.

Cornishman commented 2 years ago

@jeff15110168 Try this branch instead, direct zip link. It's a separate branch that includes both my fix from here as well as the PlexOnlineToken fix pending in #615.

Let me know how you get on 👍

jeff15110168 commented 2 years ago

@jeff15110168 Try this branch instead, direct zip link. It's a separate branch that includes both my fix from here as well as the PlexOnlineToken fix pending in #615.

Let me know how you get on 👍

Installed this and fixed all my issues! Now real time scrobbling and sync work perfectly. Thank you so so much!!!

the-jeffski commented 2 years ago

@jeff15110168 Try this branch instead, direct zip link. It's a separate branch that includes both my fix from here as well as the PlexOnlineToken fix pending in #615.

Let me know how you get on 👍

Tested this branch and all working well for me too - all combinations of metadata working. God spot on the missed commit - happens to all of us!

SasSam commented 2 years ago

@jeff15110168 Try this branch instead, direct zip link. It's a separate branch that includes both my fix from here as well as the PlexOnlineToken fix pending in #615.

Let me know how you get on 👍

I can confirm that your patch is working for me! It's scrobbling again on-the-fly! 🎉 Cheers, @Cornishman ! 🥇

Amaury-T commented 2 years ago

Hello all,

First of all thanks for all the work with this fork and thanks @Cornishman. I am new to plex and I can't figure how to made track to work with this plugin. I have installed fork of @Cornishman, I have set it up (linking it to track.tv with the PIN), but now I can't seem to find any buttons or so to do a full sync between my plex server and track.tv. How do you guy's do that ? In the plugin section i can only "configure" this track plugin but nothing else. No sync/pull option, etc.

Big thanks in advance.

BR

the-jeffski commented 2 years ago

Hello all,

First of all thanks for all the work with this fork and thanks @Cornishman. I am new to plex and I can't figure how to made track to work with this plugin. I have installed fork of @Cornishman, I have set it up (linking it to track.tv with the PIN), but now I can't seem to find any buttons or so to do a full sync between my plex server and track.tv. How do you guy's do that ? In the plugin section i can only "configure" this track plugin but nothing else. No sync/pull option, etc.

Big thanks in advance.

BR

This should really be a new post if you need help. The FAQ answers all the setup steps and then the plugin will just run in the background on a sync schedule you have set.

Amaury-T commented 2 years ago

Hello @the-jeffski,

Yes sure, while debugging the "absence" of connection with track I ended up here and though I would asked. I'll create a new post with all the info. Thanks for confirming it's only a backround task with no possibility to trigger it manually.

BR

the-jeffski commented 2 years ago

You are prob best posting on the plex forum https://forums.plex.tv/t/rel-trakt-tv/60847 as its help you are after rather than a bug.

On Tue, Dec 28, 2021 at 4:04 PM Amaury Tinard @.***> wrote:

Hello @the-jeffski https://github.com/the-jeffski,

Yes sure, while debugging the "absence" of connection with track I ended up here and though I would asked. I'll create a new post with all the info. Thanks for confirming it's only a backround task with no possibility to trigger it manually.

BR

— Reply to this email directly, view it on GitHub https://github.com/trakt/Plex-Trakt-Scrobbler/issues/596#issuecomment-1002174485, or unsubscribe https://github.com/notifications/unsubscribe-auth/APEOZL7QZDNCOOGNQETK2RDUTHNXDANCNFSM437Q2Z2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

MagicSG1 commented 2 years ago

Been trying for 4 days to get this installed but it never seems to make a difference. Keep getting the same server token missing error. Have installed through webtools and manually and no dice. Literally deleted every instance of trakt from caches, log files etc and still nothing.

Running on unRaid

adambirds commented 2 years ago

Mine has been running fine for around 2 years, no changes, but I'm now getting this server token missing error like @MagicSG1 is.

s1kee commented 2 years ago

I've also been getting an error with the token missing even with @Cornishman's fix :(

coreyp93 commented 2 years ago

@Cornishman your updates seems mostly fine, and real-time scrobble works when I watch something in plex, I can see the live progress on trakt. However, it doesn't work as it used to, if I watch something outside of plex (on Kodi/other apps) which live scrobbles to trakt then plex doesn't show the real-time scrobble progress. It doesn't seem to show any partial watched content if watched outside of plex anymore, which it definitely used to. And I know the resume points have been saved on trakt, I use the trakt.tv playback progress manager. Do you know what is causing this, Is this fixable? Certainly would be handy to get that working again. Otherwise, plex does pull watched statuses just fine.

user4302 commented 2 years ago

I would delete the existing package you have installed. The entire folder. And copy the new folder into your plugin folder

i believe this worked for me as well. along with this. https://github.com/trakt/Plex-Trakt-Scrobbler/issues/335#issuecomment-232413606