How to use the trakt.Trakt.configuration.auth function in trakt

To help you get started, we’ve selected a few trakt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fuzeman / trakt.py / tests / test_calendars.py View on Github external
def test_my_dvd():
    with HTTMock(mock.calendars_my, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            items = Trakt['calendars/my/dvd'].get()

    # Ensure request was successful
    assert_that(items, not_none())
    assert_that(items, has_length(3))

    # Guardians of the Galaxy (2014)
    assert_that(items[0], has_properties({
        'pk': ('imdb', 'tt2015381'),
        'title': u'Guardians of the Galaxy',
        'year': 2014,

        'released': date(2014, 8, 1)
    }))

    # Get On Up (2014)
github fuzeman / trakt.py / tests / test_sync_shows.py View on Github external
def test_playback():
    responses.add_callback(
        responses.GET, 'http://mock/sync/playback/episodes',
        callback=authenticated_response('fixtures/sync/playback/episodes.json'),
        content_type='application/json'
    )

    Trakt.base_url = 'http://mock'

    with Trakt.configuration.auth('mock', 'mock'):
        playback = Trakt['sync/playback'].episodes()

    assert playback is not None

    # Validate `Show`
    show = playback[('tvdb', '80348')]

    assert show.title == 'Chuck'
    assert show.year == 2007

    assert len(show.seasons) == 1

    # Validate `Season`
    season = show.seasons[1]

    assert season.show == show
github fuzeman / trakt.py / tests / users / lists / test_create.py View on Github external
def test_create():
    with HTTMock(mock.list_create, mock.fixtures):
        with Trakt.configuration.auth('mock', 'mock'):
            movies = Trakt['users/me/lists'].create(name='Movies')

    # Validate movies list
    assert movies is not None

    assert movies.name == 'Movies'
    assert movies.description is None
    assert movies.likes == 0

    assert movies.allow_comments is True
    assert movies.display_numbers is False

    assert movies.updated_at == datetime(2015, 6, 22, 2, 25, tzinfo=tzutc())

    assert movies.comment_count == 0
    assert movies.item_count == 2
github fuzeman / trakt.py / tests / sync / history / test_mixed.py View on Github external
def test_basic():
    with HTTMock(mock.fixtures, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            history = Trakt['sync/history'].get(pagination=True, per_page=5)

    # Ensure collection is valid
    assert_that(history, not_none())

    # Resolve all pages
    items = list(history)

    # Ensure all items have been returned
    assert_that(items, has_length(3))

    # Verify item identifiers
    assert_that(
        [item.id for item in items],
        equal_to(list(xrange(1, 4)))
    )
github fuzeman / trakt.py / tests / sync / watched / test_shows.py View on Github external
def test_watched():
    with HTTMock(mock.fixtures, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            collection = Trakt['sync/watched'].shows()

    # Ensure collection is valid
    assert_that(collection, not_none())
    assert_that(collection, has_length(9))

    # Chuck (2007)
    assert_that(collection[('tvdb', '80348')], has_properties({
        'pk': ('tvdb', '80348'),
        'title': 'Chuck',
        'year': 2007,

        # Seasons
        'seasons': all_of(
            has_length(1),
            has_entry(1, has_properties({
github fuzeman / trakt.py / tests / test_sync_shows.py View on Github external
def test_collection():
    responses.add_callback(
        responses.GET, 'http://mock/sync/collection/shows',
        callback=authenticated_response('fixtures/sync/collection/shows.json'),
        content_type='application/json'
    )

    Trakt.base_url = 'http://mock'

    with Trakt.configuration.auth('mock', 'mock'):
        collection = Trakt['sync/collection'].shows()

    assert collection is not None
    assert len(collection) == 4

    # Validate `Show`
    show = collection[('tvdb', '80348')]

    assert show.title == 'Chuck'
    assert show.year == 2007

    assert show.pk == ('tvdb', '80348')
    assert show.keys == [
        ('tvdb', '80348'),
        ('tmdb', '1404'),
        ('imdb', 'tt0934814'),
github fuzeman / trakt.py / tests / sync / watchlist / test_mixed.py View on Github external
def test_basic():
    with HTTMock(mock.fixtures, mock.unknown):
        with Trakt.configuration.auth('mock', 'mock'):
            watchlist = Trakt['sync/watchlist'].get(pagination=True, per_page=3)

    # Ensure collection is valid
    assert_that(watchlist, not_none())

    # Resolve all pages
    items = list(watchlist)

    # Validate items
    assert_that(items, contains(
        # TRON: Legacy (2010)
        all_of(
            instance_of(Movie),
            has_properties({
                'pk': ('imdb', 'tt1104001'),
                'title': 'TRON: Legacy',
github fuzeman / trakt.py / tests / test_sync_movies.py View on Github external
def test_playback():
    responses.add_callback(
        responses.GET, 'http://mock/sync/playback/movies',
        callback=authenticated_response('fixtures/sync/playback/movies.json'),
        content_type='application/json'
    )

    Trakt.base_url = 'http://mock'

    with Trakt.configuration.auth('mock', 'mock'):
        playback = Trakt['sync/playback'].movies()

    assert playback is not None

    # TRON: Legacy (2010)
    assert playback[('imdb', 'tt1104001')].title == 'TRON: Legacy'
    assert playback[('imdb', 'tt1104001')].year == 2010

    assert playback[('imdb', 'tt1104001')].pk == ('imdb', 'tt1104001')
    assert playback[('imdb', 'tt1104001')].keys == [
        ('imdb', 'tt1104001'),
        ('tmdb', '20526'),
        ('slug', 'tron-legacy-2010'),
        ('trakt', '12601')
    ]
github fuzeman / trakt.py / examples / media_center.py View on Github external
# Configure
    Trakt.configuration.defaults.client(
        id=os.environ.get('CLIENT_ID')
    )

    # Login
    username = os.environ.get('USERNAME')
    token = os.environ.get('AUTH_TOKEN')

    if token is None:
        # Attempt authentication (retrieve new token)
        token = Trakt['auth'].login(username, os.environ.get('PASSWORD'))

    print('Using token: %r' % token)

    with Trakt.configuration.auth(username, token):
        print(Trakt['sync/collection'].movies())

        with Trakt.configuration.http(retry=True):
            print(Trakt['movies'].get('tron-legacy-2010'))  # use only traktId, trakt slug or imdbId

            print(Trakt['shows'].get(1390))  # use only traktId, trakt slug or imdbId

            print(Trakt['shows'].seasons('tt0944947'))
            print(Trakt['shows'].season('game-of-thrones', 1))

            print(Trakt['shows'].episode('game-of-thrones', 1, 1))