GithubHelp home page GithubHelp logo

Trakt Problem about plex_debrid HOT 2 OPEN

nequam avatar nequam commented on June 7, 2024
Trakt Problem

from plex_debrid.

Comments (2)

nequam avatar nequam commented on June 7, 2024

I just corrected the part where it gets a token, not where it was complaining continually that I need to add the user back again. I can't test that until I rebuild the docker container and push that to the machines that run things.

It was fun tracking it down and I learned a bit about python.

from plex_debrid.

nequam avatar nequam commented on June 7, 2024

The change fixed it, it now works perfectly. :)

This is the change that I made to /content/services/trakt.py

Starting around line 159, replaced the post and the oauth functions.


def post(url, data, auth=False):
    try:
        if auth:
            headers = {
                'Content-type': "application/json"
            }
        else:
            headers={
                'Content-type': "application/json", "trakt-api-key": client_id, "trakt-api-version": "2",
                "Authorization": "Bearer " + current_user[1]}
        response = session.post(url, headers=headers, data=data)
        logerror(response)
        response = json.loads(response.content, object_hook=lambda d: SimpleNamespace(**d))
        time.sleep(1.1)
    except:
        response = None
    return response


def oauth(code=""):
    if code == "":
        response = post(url='https://api.trakt.tv/oauth/device/code', data=json.dumps({'client_id': client_id}), auth=True)
        if not response is None:
            return response.device_code, response.user_code
        else:
            print("trakt.tv could not be reached right now! Please try again later. The script will most likely exit after this message.")
            time.sleep(5)
    else:
        response = None
        while response is None:
            response = post(url='https://api.trakt.tv/oauth/device/token', data=json.dumps(
                {'code': code, 'client_id': client_id, 'client_secret': client_secret}),auth=True)
            time.sleep(1)
        return response.access_token

from plex_debrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.