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 scrobble user filter function #324

Closed
xsnaruto opened this issue Jun 4, 2021 · 9 comments · Fixed by #502
Closed

Add scrobble user filter function #324

xsnaruto opened this issue Jun 4, 2021 · 9 comments · Fixed by #502
Labels
help wanted Extra attention is needed

Comments

@xsnaruto
Copy link

xsnaruto commented Jun 4, 2021

Seems like for now, the watch function will scrobble all users status to my trakt account.
It would be great if we could filter users at the time of scrobble.

@glensc
Copy link
Collaborator

glensc commented Jun 4, 2021

@xsnaruto could you explain it more widely, making examples, sharing links etc? as I'm not familiar with the concept.

@xsnaruto
Copy link
Author

xsnaruto commented Jun 5, 2021

@xsnaruto could you explain it more widely, making examples, sharing links etc? as I'm not familiar with the concept.

Sorry, English is not my native language, maybe my expression is not good enough.

Well, what I want to say is that I found that when I turn on the scrobble feature, all the playback records of plex users under my management, it will processes them.

I have a few family members linked to my Plex, so even other users start playing, I will see my own trakt also got update.

I hope scrobble feature could filter Plex user, to scrobble only my Plex user's status.

I don't know how to explain it with share link or any other way, so, still in text, sorry.

Cheers🤣

@glensc
Copy link
Collaborator

glensc commented Jun 5, 2021

@xsnaruto yes, a longer explanation always better, I understand now.

Anyway, when you configured this app, did you chose managed user?

The current code acts on such message from websocket:

{
    'type': 'playing',
    'size': 1,
    'PlaySessionStateNotification': [
        {
            'sessionKey': '8',
            'guid': '',
            'ratingKey': '10623',
            'url': '',
            'key': '/library/metadata/10623',
            'viewOffset': 5930000,
            'playQueueItemID': 22306,
            'state': 'playing',
            'transcodeSession': 'jef0tvnla5gt8c18ira1ddz7'
        }
    ]
}

so as you can see, no user context there, may need to dig into transcodeSession, or playQueueItemID, maybe there's some user context.

@keldian
Copy link

keldian commented Aug 2, 2021

Having this issue as well. I don't quite understand @glensc's post but I'm assuming it doesn't contain a user-side solution.

For my part, I did not choose a managed user when configuring the app (none of the managed users is my main account).

@glensc glensc added the help wanted Extra attention is needed label Aug 6, 2021
@iamkroot
Copy link

iamkroot commented Aug 12, 2021

@glensc take a look at the /status/sessions endpoint. It has the user info. You can take a look at
https://github.com/iamkroot/trakt-scrobbler/blob/892877851fd82b23bd3d9bfe70d82ebfb73c994e/trakt_scrobbler/player_monitors/plex.py#L81
to see how I parse it. I don't use webhooks, and the output of this endpoint is the source of truth for my app. You may have to add some logic to match the notification with the session.

@chrillep
Copy link
Contributor

chrillep commented Sep 3, 2021

@glensc take a look at the /status/sessions endpoint. It has the user info. You can take a look at

https://github.com/iamkroot/trakt-scrobbler/blob/892877851fd82b23bd3d9bfe70d82ebfb73c994e/trakt_scrobbler/player_monitors/plex.py#L81

to see how I parse it. I don't use webhooks, and the output of this endpoint is the source of truth for my app. You may have to add some logic to match the notification with the session.

I'm not really sure what the equivalent would be in the used Python PlexAPI package any thoughts? 😊

@glensc
Copy link
Collaborator

glensc commented Sep 4, 2021

Dunno, try some code search:

@iamkroot
Copy link

iamkroot commented Sep 4, 2021

I guess this is the relevant method: https://python-plexapi.readthedocs.io/en/latest/modules/server.html#plexapi.server.PlexServer.sessions

@imjuzcy
Copy link
Contributor

imjuzcy commented Sep 7, 2021

Any updates on this? I did some research and indeed plexapi.server.PlexServer.sessions is the method to use. It returns a list of current playing media. For each media there will be a attribute usernames which is a list of usernames that is currently watching this media. So plex.sessions()[0].usernames will give a list of username strings for the first session. But I guess the devs already know this. My python-fu is not good enough to implement this but I'm also waiting for this feature.

Repository owner locked as resolved and limited conversation to collaborators Jan 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
6 participants