itsToggle / plex_debrid

Plex torrent streaming through Debrid Services
1.49k stars 127 forks source link

Trakt New API integration required #666

Open ghost opened 6 months ago

ghost commented 6 months ago

Hi I am raising this concern as the Trakt API to authenticate user has been deprecated I guess and it needs to be updated in the script.

Screenshot 2024-03-27 at 11 33 06

While setting up the service again, I found this issue here and I am not able to check the new content from Trakt and the new content can only be seen from Plex

mash2k3 commented 6 months ago

I was able to fixt trakt issue on mine, janky but it worked I tracked down trakt.py script in my docker subvolumes for plex_debrid i temporarily changed this function

def post(url, data):
    try:
        response = session.post(url, headers={
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
            'Content-type': "application/json", "trakt-api-key": client_id, "trakt-api-version": "2",
            "Authorization": "Bearer " + current_user[1]}, data=data)
        logerror(response)
        response = json.loads(response.content, object_hook=lambda d: SimpleNamespace(**d))
        time.sleep(1.1)
    except:
        response = None
    return response

to

def post(url, data):
    try:
        response = session.post(url, headers={
            'Content-type': "application/json"}, data=data)
        logerror(response)
        response = json.loads(response.content, object_hook=lambda d: SimpleNamespace(**d))
        time.sleep(1.1)
    except:
        response = None
    return response

restarted PD and went through trakt authorzation again saved settings reverted script change and restarted PD again

ghost commented 6 months ago

HI it worked for me. Thank you! I guess the author of this script should take a note of it and add it to the next version. Thanks so much @mash2k3

mash2k3 commented 6 months ago

I made changes to the fix, its more of a permanent fix no reverting required. in case dev does not fix before trakt token expires. adds a separate post(post2) function for oauth function.

image

If you dont feel comfortable editing file, i attached the file here. make sure to extract first then copy and overwrite in correct location. trakt.zip

ghost commented 6 months ago

Tell me one thing, whatever changes I made now based on your previous comment would require the need of re-authentication soon?

mash2k3 commented 6 months ago

Tell me one thing, whatever changes I made now based on your previous comment would require the need of re-authentication soon?

no re-authentication will come up in a month or so or several month, but when it does and you used the first fix method you will need to do the same thing with changing code and reverting.

With the second fix method you set it once and it should be good for the next re-authentications with out tinkering with the script.

ghost commented 6 months ago

Got it so shall I do this now or do it when re-authenticating next time? If I do the changes in script now, is there any need of re-authentication?

mash2k3 commented 6 months ago

Got it so shall I do this now or do it when re-authenticating next time? If I do the changes in script now, is there any need of re-authentication?

its up to you

ghost commented 6 months ago

Okay I have a made a changes

jmiller0 commented 6 months ago

does anyone have this in a fork?

poochie2 commented 5 months ago

Not understanding why this issue got closed exactly.

ccs46 commented 5 months ago

@mash2k3 Can you tell us where you put this or how to locate this file?

mash2k3 commented 5 months ago

@mash2k3 Can you tell us where you put this or how to locate this file?

basically you want to access your docker sub-volume for plex_debrid On my unraid i used winscp and connected using my ssh credentials and port 22. it should work the same for other linux servers or NAS. my path was what i pasted below but for you the value bcf216c3705d416a61f9be5be7b46703165759b3b1a41be541fe5fc12efc88e0 will be different. go to /var/lib/docker/btrfs/subvolumes/ first then search for trakt.py it will find the file and your correct folder name /var/lib/docker/btrfs/subvolumes/bcf216c3705d416a61f9be5be7b46703165759b3b1a41be541fe5fc12efc88e0/content/services image

For my ubuntu server on a cloud server i used filebrowser, which is a docker container. i installed following their instructions. on ubuntu the path is /var/lib/docker/overlay2 then i did the same thing above to find correct folder.

If you dont feel comfortable editing file, i attached the file here. make sure to extract first then copy and overwrite in correct location. trakt.zip

dreulavelle commented 5 months ago

You could just do docker exec -it plex_debrid /bin/bash to gain a shell to the docker container

poochie2 commented 5 months ago

You could just do docker exec -it plex_debrid /bin/bash to gain a shell to the docker container

In my book a volume for mounting the edited file does the job elegantly for the time being.

dreulavelle commented 5 months ago

Yeah bind mounting the dir as well would be really simple. Can just look at the Dockerfile to find out where it stores the app, then bind mount that dir locally.

Whatever is easiest for others 🍡

ccs46 commented 5 months ago

def post(url, data): try: response = session.post(url, headers={ 'Content-type': "application/json"}, data=data) logerror(response) response = json.loads(response.content, object_hook=lambda d: SimpleNamespace(**d)) time.sleep(1.1) except: response = None return response

So I think I was able to edit it, but it keeps creating a new container each time.

poochie2 commented 5 months ago

def post(url, data):

try:

    response = session.post(url, headers={

        'Content-type': "application/json"}, data=data)

    logerror(response)

    response = json.loads(response.content, object_hook=lambda d: SimpleNamespace(**d))

    time.sleep(1.1)

except:

    response = None

return response

So I think I was able to edit it, but it keeps creating a new container each time.

That why you want to mount the edit from the host to the container. Otherwise just use git and python directly.

ccs46 commented 5 months ago

So I got git to work with python and was able to reauthorize it using the code that popped up, but it's still giving the 401 unauthorized error.

poochie2 commented 5 months ago

I made changes to the fix, its more of a permanent fix no reverting required. in case dev does not fix before trakt token expires.

adds a separate post(post2) function for oauth function.

image

If you dont feel comfortable editing file, i attached the file here. make sure to extract first then copy and overwrite in correct location.

trakt.zip

This is the permafix.

ccs46 commented 5 months ago

I made changes to the fix, its more of a permanent fix no reverting required. in case dev does not fix before trakt token expires. adds a separate post(post2) function for oauth function. image If you dont feel comfortable editing file, i attached the file here. make sure to extract first then copy and overwrite in correct location. trakt.zip

This is the permafix.

I think there was something wrong with my config as it's working after I deleted settings.json and went through and redid it. Thank you for the help!