Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Trakt New API integration required #666

Open
ghost opened this issue Mar 27, 2024 · 20 comments
Open

Trakt New API integration required #666

ghost opened this issue Mar 27, 2024 · 20 comments

Comments

@ghost
Copy link

ghost commented Mar 27, 2024

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
Copy link

mash2k3 commented Mar 28, 2024

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
Copy link
Author

ghost commented Mar 28, 2024

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

@ghost ghost closed this as completed Mar 28, 2024
@mash2k3
Copy link

mash2k3 commented Mar 28, 2024

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
Copy link
Author

ghost commented Mar 28, 2024

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

@mash2k3
Copy link

mash2k3 commented Mar 28, 2024

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
Copy link
Author

ghost commented Mar 28, 2024

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
Copy link

mash2k3 commented Mar 28, 2024

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
Copy link
Author

ghost commented Mar 28, 2024

Okay I have a made a changes

@jmiller0
Copy link

jmiller0 commented Apr 1, 2024

does anyone have this in a fork?

@poochie2
Copy link

Not understanding why this issue got closed exactly.

@ccs46
Copy link

ccs46 commented Apr 29, 2024

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

@mash2k3
Copy link

mash2k3 commented Apr 29, 2024

@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
Copy link

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

@poochie2
Copy link

poochie2 commented May 3, 2024

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
Copy link

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
Copy link

ccs46 commented May 3, 2024

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
Copy link

poochie2 commented May 3, 2024

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
Copy link

ccs46 commented May 3, 2024

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
Copy link

poochie2 commented May 3, 2024

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
Copy link

ccs46 commented May 3, 2024

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!

@ghost ghost reopened this May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants