fuzeman / trakt.py

Python interface for the Trakt.tv API
http://traktpy.readthedocs.org
MIT License
154 stars 34 forks source link

Documentation missing some big points #1

Closed razzeee closed 5 years ago

razzeee commented 9 years ago

Hey there,

seems to me like there are some calls missing from documentation, can't firgure out how to get a movie or show by id. Rating examples would be apreciated too.

Thanks

fuzeman commented 9 years ago

trakt.py was built for https://github.com/trakt/Plex-Trakt-Scrobbler, so it currently only supports the scrobble and sync methods of the API.

I'm planning on implementing the rest of the API, but currently don't have much time to work on this.

razzeee commented 9 years ago

@fuzeman thank you. I'm using it for the kodi plug in port too. So if I'm growing to like python I will add some pull requests here.

That being said, is there a way in your wrapper to convert the media objects it hands out to json, compatible to Trakt? I probably missed it somewhere

plittlefield commented 8 years ago

Hello All,

I would like to use this on the Linux command line, in a similar fashion to FlexGet, to be able to list and remove shows.

I have pulled with git, run travis_install.sh, run sudo python setup.py install.

I have created an API and put the 'id' and 'secret' in a simple python file.

from trakt import Trakt
Trakt.configuration.defaults.client(
    id='blablabla',
    secret='blablabla'
)
watched = Trakt['sync/watched'].movies()
for key, show in watched.items():
    print '%s (%s)' % (show.title, show.year)

I have just used the 'Retrieve shows that a user has watched' example, but it is not working for me.

The error is:-

Traceback (most recent call last):
  File "trakt_.py", line 12, in <module>
    for key, show in watched.items():
AttributeError: 'NoneType' object has no attribute 'items'

Can anyone help?

Thanks,

Paully

fuzeman commented 8 years ago

@plittlefield You need to authenticate with your Trakt.tv account.

For example:

from trakt import Trakt

# Configure client
Trakt.configuration.defaults.app(
    id='<APP ID>'  # (e.g. "478" for https://trakt.tv/oauth/applications/478)
)

Trakt.configuration.defaults.client(
    id='<CLIENT ID>',
    secret='<CLIENT SECRET>'
)

# Request authentication
print('Navigate to %s' % Trakt['oauth/pin'].url())
pin = raw_input('Pin: ')

# Exchange `pin` for an account authorization token
authorization = Trakt['oauth'].token_exchange(pin, 'urn:ietf:wg:oauth:2.0:oob')

if not authorization or not authorization.get('access_token'):
    print('ERROR: Authentication failed')
    exit(1)

# Configure client to use your account `authorization` by default
Trakt.configuration.defaults.oauth.from_response(authorization)

# Fetch watched items
for key, movie in Trakt['sync/watched'].movies().items():
    print('%s (%s)' % (movie.title, movie.year))

Note: PIN authentication has been deprecated, but it does still work and is the easiest authentication method to use.

plittlefield commented 8 years ago

Thanks for your help.

I am nearly there, but just getting stuck with the whole PIN thing.