Esempio n. 1
0
    def __init__(self, instance='Default'):
        oauth_provider = common.PM.getPluginByIdentifier("de.lad1337.trakt.tv")
        if oauth_provider:
            self.oauth = oauth_provider.oauth
        MediaAdder.__init__(self, instance=instance)

        self.client = None
        if self.oauth and self.oauth.authorized:
            self.client = Client(self.oauth.session)
Esempio n. 2
0
 def __init__(self, instance='Default'):
     Provider.__init__(self, instance=instance)
     self.client = Client()
     if self.oauth.authorized:
         self.client = Client(self.oauth.session)
Esempio n. 3
0
class TraktTV(Provider):
    version = "0.9"
    identifier = "de.lad1337.trakt.tv"
    _tag = 'trakt'
    single = True
    types = ['de.lad1337.tv']
    _config = {
        'api_key': '',
        'release_delta': 0,
    }
    config_meta = {
        'plugin_desc':'TV show info from http://trakt.tv.',
        'release_delta': {'human': 'Timedelta for the air time in hours', 'desc': 'e.g. -8 or 12'}
    }

    oauth = OAuth(
        "8224c88cc14f27ab6e0d894dec500f7c46bd5de71fdc1b27cac6be8c027f023b",
        "1f2d6776d86e0265585b3b6488bc62892079cfa9298a69aa363e61b4d7b8fccd",
        authorization_url="https://trakt.tv/oauth/authorize",
        token_url="https://api.trakt.tv/oauth/token"
    )

    def __init__(self, instance='Default'):
        Provider.__init__(self, instance=instance)
        self.client = Client()
        if self.oauth.authorized:
            self.client = Client(self.oauth.session)

    def searchForElement(self, term=''):
        self.progress.reset()
        mediaType = MediaType.get(MediaType.identifier == 'de.lad1337.tv')
        mtm = common.PM.getMediaTypeManager('de.lad1337.tv')[0]
        fakeRoot = mtm.getFakeRoot(term)


        log('trakt.tv searching for %s' % term)

        _results = self.client.shows(term)
        self.progress.total = len(_results)
        for _show in _results:
            self.progress.addItem()
            self._build_show(_show, fakeRoot, mediaType, just_show=True)

        return fakeRoot

    def _build_show(self, show_, fakeRoot, mediaType, just_show=False):
        show = Element()
        show.mediaType = mediaType
        show.parent = fakeRoot
        show.type = 'Show'
        show.setField('title', show_.title, self.tag)
        show.setField('overview', show_.overview, self.tag)
        show.setField('year', show_.year, self.tag)
        show.setField('show_status', show_.status, self.tag)
        show.setField('country', show_.country, self.tag)
        show.setField('genres', ', '.join(show_.genres), self.tag)
        show.setField('runtime', show_.runtime, self.tag)
        show.setField('poster_image', show_.images.poster.medium, self.tag)
        show.setField('banner_image', show_.images.banner.full, self.tag)
        show.setField('fanart_image', show_.images.fanart.medium, self.tag)
        for id_key in ["tvdb", "imdb", "trakt"]:
            id_ = getattr(show_.ids, id_key)
            if id_:
                show.setField('id', id_, id_key)
        show.saveTemp()
        if just_show:
            return

        for season_ in show_.seasons:
            season = Element()
            season.mediaType = mediaType
            season.parent = show
            season.type = 'Season'
            season.setField('number', season_.number, self.tag)
            season.setField('poster_image', season_.images.poster.medium, self.tag)
            season.saveTemp()
            for episode_ in season_.episodes:
                episode = Element()
                episode.mediaType = mediaType
                episode.parent = season
                episode.type = 'Episode'
                episode.setField('title', episode_.title, self.tag)
                episode.setField('season', episode_.season, self.tag)
                episode.setField('number', episode_.number, self.tag)
                episode.setField('overview', episode_.overview, self.tag)
                episode.setField('id', episode_.ids.tvdb, "tvdb")
                if episode_.first_aired:
                    episode.setField('airdate', episode_.first_aired, self.tag)
                else:
                    episode.setField('airdate', common.FAKEDATE, self.tag)
                episode.setField(
                    'screencap_image', episode_.images.screenshot.medium, self.tag)
                episode.saveTemp()


    def getElement(self, show_id, element=None, tag=None):
        mediaType = MediaType.get(MediaType.identifier == 'de.lad1337.tv')
        mtm = common.PM.getMediaTypeManager('de.lad1337.tv')[0]
        fakeRoot = mtm.getFakeRoot(show_id)

        show = Show(self.client, show_id) # only supports trakt id
        log("building show: %s" % show)
        self._build_show(show, fakeRoot, mediaType)

        for ele in fakeRoot.decendants:
            if int(ele.getField('id', tag)) == int(show_id):
                return ele
        return False
Esempio n. 4
0
 def __init__(self, instance='Default'):
     Provider.__init__(self, instance=instance)
     self.client = Client()
     if self.oauth.authorized:
         self.client = Client(self.oauth.session)
Esempio n. 5
0
class TraktTV(Provider):
    version = "0.11"
    identifier = "de.lad1337.trakt.tv"
    _tag = 'trakt'
    single = True
    types = ['de.lad1337.tv']
    _config = {
        'api_key': '',
        'release_delta': 0,
    }
    config_meta = {
        'plugin_desc': 'TV show info from http://trakt.tv.',
        'release_delta': {
            'human': 'Timedelta for the air time in hours',
            'desc': 'e.g. -8 or 12'
        }
    }

    oauth = OAuth(
        "8224c88cc14f27ab6e0d894dec500f7c46bd5de71fdc1b27cac6be8c027f023b",
        "1f2d6776d86e0265585b3b6488bc62892079cfa9298a69aa363e61b4d7b8fccd",
        authorization_url="https://trakt.tv/oauth/authorize",
        token_url="https://api.trakt.tv/oauth/token")

    def __init__(self, instance='Default'):
        Provider.__init__(self, instance=instance)
        self.client = Client()
        if self.oauth.authorized:
            self.client = Client(self.oauth.session)

    def searchForElement(self, term=''):
        self.progress.reset()
        mediaType = MediaType.get(MediaType.identifier == 'de.lad1337.tv')
        mtm = common.PM.getMediaTypeManager('de.lad1337.tv')[0]
        fakeRoot = mtm.getFakeRoot(term)

        log('trakt.tv searching for %s' % term)

        _results = self.client.shows(term)
        self.progress.total = len(_results)
        for _show in _results:
            self.progress.addItem()
            self._build_show(_show, fakeRoot, mediaType, just_show=True)

        return fakeRoot

    def _build_show(self, show_, fakeRoot, mediaType, just_show=False):
        show = Element()
        show.mediaType = mediaType
        show.parent = fakeRoot
        show.type = 'Show'
        show.setField('title', show_.title, self.tag)
        show.setField('overview', show_.overview, self.tag)
        show.setField('year', show_.year, self.tag)
        show.setField('show_status', show_.status, self.tag)
        show.setField('country', show_.country, self.tag)
        show.setField('genres', ', '.join(show_.genres), self.tag)
        show.setField('runtime', show_.runtime, self.tag)
        show.setField('poster_image', show_.images.poster.medium, self.tag)
        show.setField('banner_image', show_.images.banner.full, self.tag)
        show.setField('fanart_image', show_.images.fanart.medium, self.tag)
        for id_key in ["tvdb", "imdb", "trakt"]:
            id_ = getattr(show_.ids, id_key)
            if id_:
                show.setField('id', id_, id_key)
        show.saveTemp()
        if just_show:
            return

        for season_ in show_.seasons:
            season = Element()
            season.mediaType = mediaType
            season.parent = show
            season.type = 'Season'
            season.setField('number', season_.number, self.tag)
            season.setField('poster_image', season_.images.poster.medium,
                            self.tag)
            season.saveTemp()
            for episode_ in season_.episodes:
                episode = Element()
                episode.mediaType = mediaType
                episode.parent = season
                episode.type = 'Episode'
                episode.setField('title', episode_.title, self.tag)
                episode.setField('season', episode_.season, self.tag)
                episode.setField('number', episode_.number, self.tag)
                episode.setField('overview', episode_.overview, self.tag)
                episode.setField('id', episode_.ids.tvdb, "tvdb")
                if episode_.first_aired:
                    episode.setField('airdate', episode_.first_aired, self.tag)
                else:
                    episode.setField('airdate', common.FAKEDATE, self.tag)
                episode.setField('screencap_image',
                                 episode_.images.screenshot.medium, self.tag)
                episode.saveTemp()

    def getElement(self, show_id, element=None, tag=None):
        mediaType = MediaType.get(MediaType.identifier == 'de.lad1337.tv')
        mtm = common.PM.getMediaTypeManager('de.lad1337.tv')[0]
        fakeRoot = mtm.getFakeRoot(show_id)

        show = Show(self.client, show_id)  # only supports trakt id
        log("building show: %s" % show)
        self._build_show(show, fakeRoot, mediaType)

        for ele in fakeRoot.decendants:
            if int(ele.getField('id', tag)) == int(show_id):
                return ele
        return False
Esempio n. 6
0
class TraktTV(Provider):
    version = "0.11"
    identifier = "de.lad1337.trakt.tv"
    _tag = "trakt"
    single = True
    types = ["de.lad1337.tv"]
    _config = {"api_key": "", "release_delta": 0}
    config_meta = {
        "plugin_desc": "TV show info from http://trakt.tv.",
        "release_delta": {"human": "Timedelta for the air time in hours", "desc": "e.g. -8 or 12"},
    }

    oauth = OAuth(
        "8224c88cc14f27ab6e0d894dec500f7c46bd5de71fdc1b27cac6be8c027f023b",
        "1f2d6776d86e0265585b3b6488bc62892079cfa9298a69aa363e61b4d7b8fccd",
        authorization_url="https://trakt.tv/oauth/authorize",
        token_url="https://api.trakt.tv/oauth/token",
    )

    def __init__(self, instance="Default"):
        Provider.__init__(self, instance=instance)
        self.client = Client()
        if self.oauth.authorized:
            self.client = Client(self.oauth.session)

    def searchForElement(self, term=""):
        self.progress.reset()
        mediaType = MediaType.get(MediaType.identifier == "de.lad1337.tv")
        mtm = common.PM.getMediaTypeManager("de.lad1337.tv")[0]
        fakeRoot = mtm.getFakeRoot(term)

        log("trakt.tv searching for %s" % term)

        _results = self.client.shows(term)
        self.progress.total = len(_results)
        for _show in _results:
            self.progress.addItem()
            self._build_show(_show, fakeRoot, mediaType, just_show=True)

        return fakeRoot

    def _build_show(self, show_, fakeRoot, mediaType, just_show=False):
        show = Element()
        show.mediaType = mediaType
        show.parent = fakeRoot
        show.type = "Show"
        show.setField("title", show_.title, self.tag)
        show.setField("overview", show_.overview, self.tag)
        show.setField("year", show_.year, self.tag)
        show.setField("show_status", show_.status, self.tag)
        show.setField("country", show_.country, self.tag)
        show.setField("genres", ", ".join(show_.genres), self.tag)
        show.setField("runtime", show_.runtime, self.tag)
        show.setField("poster_image", show_.images.poster.medium, self.tag)
        show.setField("banner_image", show_.images.banner.full, self.tag)
        show.setField("fanart_image", show_.images.fanart.medium, self.tag)
        for id_key in ["tvdb", "imdb", "trakt"]:
            id_ = getattr(show_.ids, id_key)
            if id_:
                show.setField("id", id_, id_key)
        show.saveTemp()
        if just_show:
            return

        for season_ in show_.seasons:
            season = Element()
            season.mediaType = mediaType
            season.parent = show
            season.type = "Season"
            season.setField("number", season_.number, self.tag)
            season.setField("poster_image", season_.images.poster.medium, self.tag)
            season.saveTemp()
            for episode_ in season_.episodes:
                episode = Element()
                episode.mediaType = mediaType
                episode.parent = season
                episode.type = "Episode"
                episode.setField("title", episode_.title, self.tag)
                episode.setField("season", episode_.season, self.tag)
                episode.setField("number", episode_.number, self.tag)
                episode.setField("overview", episode_.overview, self.tag)
                episode.setField("id", episode_.ids.tvdb, "tvdb")
                if episode_.first_aired:
                    episode.setField("airdate", episode_.first_aired, self.tag)
                else:
                    episode.setField("airdate", common.FAKEDATE, self.tag)
                episode.setField("screencap_image", episode_.images.screenshot.medium, self.tag)
                episode.saveTemp()

    def getElement(self, show_id, element=None, tag=None):
        mediaType = MediaType.get(MediaType.identifier == "de.lad1337.tv")
        mtm = common.PM.getMediaTypeManager("de.lad1337.tv")[0]
        fakeRoot = mtm.getFakeRoot(show_id)

        show = Show(self.client, show_id)  # only supports trakt id
        log("building show: %s" % show)
        self._build_show(show, fakeRoot, mediaType)

        for ele in fakeRoot.decendants:
            if int(ele.getField("id", tag)) == int(show_id):
                return ele
        return False