GithubHelp home page GithubHelp logo

How to use a proxy? about trakt.py HOT 6 CLOSED

razzeee avatar razzeee commented on June 15, 2024
How to use a proxy?

from trakt.py.

Comments (6)

fuzeman avatar fuzeman commented on June 15, 2024

It looks like you can just set an environment variable to enable the use of a proxy.

Something like this might work (set the environment variable before any calls to trakt.py):

import os

os.environ['HTTP_PROXY'] = 'http://...'
# or
os.environ['HTTPS_PROXY'] = 'http://...'

If this doesn't work, I can just add an extra configuration parameter into trakt.py.

from trakt.py.

razzeee avatar razzeee commented on June 15, 2024

Can you please have a look if I missed something?
razzeee/script.trakt@3eab97a
https://github.com/Razzeee/script.trakt/issues/181#issuecomment-98806541

from trakt.py.

fuzeman avatar fuzeman commented on June 15, 2024

Looks like the environment variables don't work with requests.Session, try this instead (update to the develop branch of trakt.py):

Trakt.http.proxies = {
    'http': 'http://<username>:<password>@<host>:<port>',
    'https': 'http://<username>:<password>@<host>:<port>'
}

Note: the proxies dictionary maps specific request schemes to a proxy, set both "http" and "https" to the same proxy url.

from trakt.py.

razzeee avatar razzeee commented on June 15, 2024

I'm not sure I understand you? Should there be a new commit to the develop branch?

Should this stay like this or do I use the real url? Should both be http or can both also be https?

Trakt.http.proxies = {
    'http': 'http://<username>:<password>@<host>:<port>',
    'https': 'http://<username>:<password>@<host>:<port>'
}

from trakt.py.

fuzeman avatar fuzeman commented on June 15, 2024

Woops, only pushed the commit to my private git server. fedd568 adds the "proxies" attribute.

You should be able to just replace:

        proxyURL = checkAndConfigureProxy()
        if proxyURL:
            if proxyURL.startswith('http://'):
                os.environ['HTTP_PROXY'] = proxyURL
            elif proxyURL.startswith('https://'):
                os.environ['HTTPS_PROXY'] = proxyURL

with (untested, make sure the indentation is correct):

        proxyURL = checkAndConfigureProxy()
        if proxyURL:
            Trakt.http.proxies = {
                'http': proxyURL,
                'https': proxyURL
            }

from trakt.py.

razzeee avatar razzeee commented on June 15, 2024

Working flawless, thank you!

from trakt.py.

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.