How to use the trakt.interfaces.base.Interface 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 / trakt / interfaces / sync / core / mixins.py View on Github external
class Remove(Interface):
    @authenticated
    def remove(self, items, **kwargs):
        response = self.http.post(
            'remove',
            data=items,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return self.get_data(response, **kwargs)


class Delete(Interface):
    @authenticated
    def delete(self, playbackid, **kwargs):
        response = self.http.delete(
            path=str(playbackid),
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return 200 <= response.status_code < 300
github fuzeman / trakt.py / trakt / interfaces / sync / core / mixins.py View on Github external
from __future__ import absolute_import, division, print_function

from trakt.core.helpers import popitems
from trakt.core.pagination import PaginationIterator
from trakt.interfaces.base import Interface, authenticated
from trakt.mapper.sync import SyncMapper

import requests


class Get(Interface):
    flags = {}

    @authenticated
    def get(self, media=None, store=None, params=None, query=None, flat=False, **kwargs):
        if not params:
            params = []

        params.insert(0, media)

        # Request resource
        response = self.http.get(
            params=params,
            query=query,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
github trakt / Plex-Trakt-Scrobbler / Trakttv.bundle / Contents / Libraries / Shared / trakt / interfaces / sync / core / mixins.py View on Github external
class Remove(Interface):
    @authenticated
    def remove(self, items, **kwargs):
        response = self.http.post(
            'remove',
            data=items,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return self.get_data(response, **kwargs)


class Delete(Interface):
    @authenticated
    def delete(self, playbackid, **kwargs):
        response = self.http.delete(
            path=str(playbackid),
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return 200 <= response.status_code < 300
github timbooo / traktforalfred / trakt / interfaces / users / lists / __init__.py View on Github external
from trakt.interfaces.base import Interface
from trakt.mapper import ListMapper

# Import child interfaces
from trakt.interfaces.users.lists.list_ import UsersListInterface

__all__ = [
    'UsersListsInterface',
    'UsersListInterface'
]


class UsersListsInterface(Interface):
    path = 'users/*/lists'

    def create(self, username, name, description=None, privacy='private',
               display_numbers=False, allow_comments=True, **kwargs):
        data = {
            'name': name,
            'description': description,

            'privacy': privacy,
            'allow_comments': allow_comments,
            'display_numbers': display_numbers
        }

        # Remove attributes with `None` values
        for key in list(data.keys()):
            if data[key] is not None:
github fuzeman / trakt.py / trakt / interfaces / shows / __init__.py View on Github external
from __future__ import absolute_import, division, print_function

from trakt.core.helpers import popitems
from trakt.interfaces.base import Interface, authenticated
from trakt.mapper.progress import ProgressMapper
from trakt.mapper.summary import SummaryMapper

import requests


class ShowsInterface(Interface):
    path = 'shows'

    def get(self, id, extended=None, **kwargs):
        response = self.http.get(str(id), query={
            'extended': extended
        })

        item = self.get_data(response, **kwargs)

        if isinstance(item, requests.Response):
            return item

        return SummaryMapper.show(self.client, item)

    def trending(self, extended=None, **kwargs):
        response = self.http.get('trending', query={
github sharkykh / TraktPlaybackProgressManager / trakt / interfaces / sync / core / mixins.py View on Github external
return self.get(
            'shows',
            store,
            **kwargs
        )

    @authenticated
    def movies(self, store=None, **kwargs):
        return self.get(
            'movies',
            store,
            **kwargs
        )


class Add(Interface):
    @authenticated
    def add(self, items, **kwargs):
        response = self.http.post(
            data=items,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return self.get_data(response, **kwargs)


class Remove(Interface):
    @authenticated
    def remove(self, items, **kwargs):
github sharkykh / TraktPlaybackProgressManager / trakt / interfaces / sync / core / mixins.py View on Github external
from trakt.core.helpers import popitems
from trakt.core.pagination import PaginationIterator
from trakt.interfaces.base import authenticated, Interface
from trakt.mapper.sync import SyncMapper

import requests


class Get(Interface):
    flags = {}

    @authenticated
    def get(self, media=None, store=None, params=None, query=None, flat=False, **kwargs):
        if not params:
            params = []

        params.insert(0, media)

        # Request resource
        response = self.http.get(
            params=params,
            query=query,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
github trakt / Plex-Trakt-Scrobbler / Trakttv.bundle / Contents / Libraries / Shared / trakt / interfaces / sync / core / mixins.py View on Github external
class Add(Interface):
    @authenticated
    def add(self, items, **kwargs):
        response = self.http.post(
            data=items,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return self.get_data(response, **kwargs)


class Remove(Interface):
    @authenticated
    def remove(self, items, **kwargs):
        response = self.http.post(
            'remove',
            data=items,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return self.get_data(response, **kwargs)


class Delete(Interface):
    @authenticated
github fuzeman / trakt.py / trakt / interfaces / sync / core / mixins.py View on Github external
class Add(Interface):
    @authenticated
    def add(self, items, **kwargs):
        response = self.http.post(
            data=items,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return self.get_data(response, **kwargs)


class Remove(Interface):
    @authenticated
    def remove(self, items, **kwargs):
        response = self.http.post(
            'remove',
            data=items,
            **popitems(kwargs, [
                'authenticated',
                'validate_token'
            ])
        )

        return self.get_data(response, **kwargs)


class Delete(Interface):
    @authenticated
github timbooo / traktforalfred / trakt / interfaces / users / lists / list_.py View on Github external
from trakt.interfaces.base import Interface
from trakt.mapper import ListMapper, ListItemMapper


class UsersListInterface(Interface):
    path = 'users/*/lists/*'

    def get(self, username, id):
        response = self.http.get(
            '/users/%s/lists/%s' % (username, id),
        )

        if response.status_code < 200 or response.status_code >= 300:
            return None

        # Parse response
        item = self.get_data(response)

        # Map item to list object
        return ListMapper.custom_list(
            self.client, item,