def userlists(self):
        try:
            userlists = []
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            activity = trakt.getActivity()
        except:
            log_utils.log(sys.exc_info())
            pass

        try:
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            try:
                if activity > cache.timeout(self.trakt_user_list,
                                            self.traktlists_link,
                                            self.trakt_user):
                    raise Exception()
                userlists += cache.get(self.trakt_user_list, 720,
                                       self.traktlists_link, self.trakt_user)
            except:
                userlists += cache.get(self.trakt_user_list, 0,
                                       self.traktlists_link, self.trakt_user)
        except:
            log_utils.log(sys.exc_info())
            pass
        try:
            self.list = []
            if not self.imdb_user: raise Exception('No imdb user set.')
            userlists += cache.get(self.imdblists.get_user_lists,
                                   IMDB_USER_LIST_CACHE_TIMEOUT)
        except:
            log_utils.log(sys.exc_info())
            pass
        try:
            self.list = []
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            try:
                if activity > cache.timeout(self.trakt_user_list,
                                            self.traktlikedlists_link,
                                            self.trakt_user):
                    raise Exception()
                userlists += cache.get(self.trakt_user_list, 720,
                                       self.traktlikedlists_link,
                                       self.trakt_user)
            except:
                userlists += cache.get(self.trakt_user_list, 0,
                                       self.traktlikedlists_link,
                                       self.trakt_user)
        except:
            log_utils.log(sys.exc_info())
            pass

        self.list = userlists
        for i in range(0, len(self.list)):
            self.list[i].update({'image': 'userlists.png', 'action': 'movies'})
        self.addDirectory(self.list, queue=True)
        return self.list
Example #2
0
    def userlists(self):
        try:
            userlists = []
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            activity = trakt.getActivity()
        except:
            pass

        try:
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            try:
                if activity > cache.timeout(self.trakt_user_list,
                                            self.traktlists_link,
                                            self.trakt_user):
                    raise Exception()
                userlists += cache.get(self.trakt_user_list, 720,
                                       self.traktlists_link, self.trakt_user)
            except:
                userlists += cache.get(self.trakt_user_list, 0,
                                       self.traktlists_link, self.trakt_user)
        except:
            pass
        try:
            self.list = []
            if self.imdb_user == '': raise Exception()
            userlists += cache.get(self.imdb_user_list, 0, self.imdblists_link)
        except:
            pass
        try:
            self.list = []
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            try:
                if activity > cache.timeout(self.trakt_user_list,
                                            self.traktlikedlists_link,
                                            self.trakt_user):
                    raise Exception()
                userlists += cache.get(self.trakt_user_list, 720,
                                       self.traktlikedlists_link,
                                       self.trakt_user)
            except:
                userlists += cache.get(self.trakt_user_list, 0,
                                       self.traktlikedlists_link,
                                       self.trakt_user)
        except:
            pass

        self.list = userlists
        for i in range(0, len(self.list)):
            self.list[i].update({
                'image': 'userlists.png',
                'action': 'tvshows'
            })
        self.addDirectory(self.list)
        return self.list
Example #3
0
	def userlists(self):
		episodes = episodesx.episodes(type = self.type, kids = self.kids)
		userlists = []

		try:
			if trakt.getTraktCredentialsInfo() == False: raise Exception()
			activity = trakt.getActivity()
		except:
			pass

		try:
			if trakt.getTraktCredentialsInfo() == False: raise Exception()
			self.list = []
			try:
				if activity > cache.timeout(episodes.trakt_user_list, self.traktlists_link, self.trakt_user): raise Exception()
				userlists += cache.get(episodes.trakt_user_list, 3, self.traktlists_link, self.trakt_user)
			except:
				userlists += cache.get(episodes.trakt_user_list, 0, self.traktlists_link, self.trakt_user)
		except:
			pass

		try:
			if trakt.getTraktCredentialsInfo() == False: raise Exception()
			self.list = []
			try:
				if activity > cache.timeout(episodes.trakt_user_list, self.traktlikedlists_link, self.trakt_user): raise Exception()
				userlists += cache.get(episodes.trakt_user_list, 3, self.traktlikedlists_link, self.trakt_user)
			except:
				userlists += cache.get(episodes.trakt_user_list, 0, self.traktlikedlists_link, self.trakt_user)
		except:
			pass

		self.list = []

		# Filter the user's own lists that were
		for i in range(len(userlists)):
			contains = False
			adapted = userlists[i]['url'].replace('/me/', '/%s/' % self.trakt_user)
			for j in range(len(self.list)):
				if adapted == self.list[j]['url'].replace('/me/', '/%s/' % self.trakt_user):
					contains = True
					break
			if not contains:
				self.list.append(userlists[i])

		for i in range(0, len(self.list)): self.list[i].update({'image': 'traktlists.png', 'action': self.parameterize('seasonsList')})

		# Watchlist
		if trakt.getTraktCredentialsInfo():
		    self.list.insert(0, {'name' : interface.Translation.string(32033), 'url' : self.traktwatchlist_link, 'image': 'traktwatch.png', 'action': self.parameterize('seasons')})

		episodes.addDirectory(self.list, queue = True)
		return self.list
Example #4
0
	def userlists(self):
		episodes = episodesx.episodes(type = self.type, kids = self.kids)
		userlists = []

		try:
			if trakt.getTraktCredentialsInfo() == False: raise Exception()
			activity = trakt.getActivity()
		except:
			pass

		try:
			if trakt.getTraktCredentialsInfo() == False: raise Exception()
			self.list = []
			try:
				if activity > cache.timeout(episodes.trakt_user_list, self.traktlists_link, self.trakt_user): raise Exception()
				userlists += cache.get(episodes.trakt_user_list, 3, self.traktlists_link, self.trakt_user)
			except:
				userlists += cache.get(episodes.trakt_user_list, 0, self.traktlists_link, self.trakt_user)
		except:
			pass

		try:
			if trakt.getTraktCredentialsInfo() == False: raise Exception()
			self.list = []
			try:
				if activity > cache.timeout(episodes.trakt_user_list, self.traktlikedlists_link, self.trakt_user): raise Exception()
				userlists += cache.get(episodes.trakt_user_list, 3, self.traktlikedlists_link, self.trakt_user)
			except:
				userlists += cache.get(episodes.trakt_user_list, 0, self.traktlikedlists_link, self.trakt_user)
		except:
			pass

		self.list = []

		# Filter the user's own lists that were
		for i in range(len(userlists)):
			contains = False
			adapted = userlists[i]['url'].replace('/me/', '/%s/' % self.trakt_user)
			for j in range(len(self.list)):
				if adapted == self.list[j]['url'].replace('/me/', '/%s/' % self.trakt_user):
					contains = True
					break
			if not contains:
				self.list.append(userlists[i])

		for i in range(0, len(self.list)): self.list[i].update({'image': 'traktlists.png', 'action': self.parameterize('seasonList')})

		# Watchlist
		if trakt.getTraktCredentialsInfo():
		    self.list.insert(0, {'name' : interface.Translation.string(32033), 'url' : self.traktwatchlist_link, 'context' : self.traktwatchlist_link, 'image': 'traktwatch.png', 'action': self.parameterize('seasons')})

		episodes.addDirectory(self.list, queue = True)
		return self.list
    def library(self):
        self.addDirectoryItem(32557, 'openSettings&query=4.0', 'tools.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32558, 'updateLibrary&query=tool',
                              'library_update.png', 'DefaultAddonProgram.png')
        self.addDirectoryItem(32559,
                              control.setting('library.movie'),
                              'movies.png',
                              'DefaultMovies.png',
                              isAction=False)
        self.addDirectoryItem(32560,
                              control.setting('library.tv'),
                              'tvshows.png',
                              'DefaultTVShows.png',
                              isAction=False)

        if trakt.getTraktCredentialsInfo():
            self.addDirectoryItem(32561, 'moviesToLibrary&url=traktcollection',
                                  'trakt.png', 'DefaultMovies.png')
            self.addDirectoryItem(32562, 'moviesToLibrary&url=traktwatchlist',
                                  'trakt.png', 'DefaultMovies.png')
            self.addDirectoryItem(32563,
                                  'tvshowsToLibrary&url=traktcollection',
                                  'trakt.png', 'DefaultTVShows.png')
            self.addDirectoryItem(32564, 'tvshowsToLibrary&url=traktwatchlist',
                                  'trakt.png', 'DefaultTVShows.png')

        self.endDirectory()
Example #6
0
    def onPlayBackStarted(self):
        if control.getKodiVersion() < 18:
            control.execute('Dialog.Close(all,true)')

            if control.setting('bookmarks') == 'true' and int(
                    self.offset) > 120 and self.isPlayingVideo():
                if control.setting('bookmarks.auto') == 'true':
                    self.seekTime(float(self.offset))
                else:
                    self.pause()
                    minutes, seconds = divmod(float(self.offset), 60)
                    hours, minutes = divmod(minutes, 60)
                    label = '%02d:%02d:%02d' % (hours, minutes, seconds)
                    label = six.ensure_str(control.lang2(12022).format(label))
                    if control.setting(
                            'rersume.source'
                    ) == '1' and trakt.getTraktCredentialsInfo() == True:
                        label += '[CR]  (Trakt scrobble)'
                    yes = control.yesnoDialog(label,
                                              heading=control.lang2(13404))
                    if yes:
                        self.seekTime(float(self.offset))
                    self.pause()

            subtitles().get(self.name, self.imdb, self.season, self.episode)
            self.idleForPlayback()
        else:
            self.onAVStarted()
Example #7
0
 def library(self):
     movie_library = control.setting('library.movie')
     tv_library = control.setting('library.tv')
     self.addDirectoryItem(32558, 'updateLibrary&query=tool',
                           'library_update.png', 'DefaultAddonProgram.png')
     if len(control.listDir(movie_library)[0]) > 0:
         self.addDirectoryItem(32559,
                               movie_library,
                               'movies.png',
                               'DefaultMovies.png',
                               isAction=False)
     if len(control.listDir(tv_library)[0]) > 0:
         self.addDirectoryItem(32560,
                               tv_library,
                               'tvshows.png',
                               'DefaultTVShows.png',
                               isAction=False)
     if trakt.getTraktCredentialsInfo():
         self.addDirectoryItem(32561, 'moviesToLibrary&url=traktcollection',
                               'trakt.png', 'DefaultMovies.png')
         self.addDirectoryItem(32562, 'moviesToLibrary&url=traktwatchlist',
                               'trakt.png', 'DefaultMovies.png')
         self.addDirectoryItem(32563,
                               'tvshowsToLibrary&url=traktcollection',
                               'trakt.png', 'DefaultTVShows.png')
         self.addDirectoryItem(32564, 'tvshowsToLibrary&url=traktwatchlist',
                               'trakt.png', 'DefaultTVShows.png')
     self.endDirectory()
Example #8
0
    def __init__(self, type='show'):
        self.list = []
        self.type = type
        self.lang = control.apiLanguage()['tvdb']
        self.season_special = False

        self.datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(hours=5))
        self.today_date = (self.datetime).strftime('%Y-%m-%d')

        tvdb_key_list = [
            'MDZjZmYzMDY5MGY5Yjk2MjI5NTcwNDRmMjE1OWZmYWU=',
            'MUQ2MkYyRjkwMDMwQzQ0NA==', 'N1I4U1paWDkwVUE5WU1CVQ=='
        ]
        self.tvdb_key = tvdb_key_list[int(control.setting('tvdb.api.key'))]

        self.tvdb_info_link = 'https://thetvdb.com/api/%s/series/%s/all/%s.zip' % (
            self.tvdb_key.decode('base64'), '%s', '%s')
        self.tvdb_by_imdb = 'https://thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=%s'
        self.tvdb_by_query = 'https://thetvdb.com/api/GetSeries.php?seriesname=%s'
        self.tvdb_image = 'https://thetvdb.com/banners/'
        self.tvdb_poster = 'https://thetvdb.com/banners/_cache/'

        self.trakt_user = control.setting('trakt.user').strip()
        self.traktCredentials = trakt.getTraktCredentialsInfo()
        self.traktwatchlist_link = 'https://api-v2launch.trakt.tv/users/me/watchlist/seasons'
        self.traktlist_link = 'https://api-v2launch.trakt.tv/users/%s/lists/%s/items'
        self.traktlists_link = 'https://api-v2launch.trakt.tv/users/me/lists'

        self.showunaired = control.setting('showunaired') or 'true'
        self.unairedcolor = control.setting('unaired.identify')
        self.unairedcolor = control.getColor(self.unairedcolor)
Example #9
0
    def onPlayBackStopped(self):
        control.sleep(2500)
        bookmarks().reset(self.currentTime, self.totalTime, self.name,
                          self.year)

        if control.setting(
                'trakt.scrobble') == 'true' and trakt.getTraktCredentialsInfo(
                ) == True:
            try:
                percent = float((self.currentTime / self.totalTime) * 100)
                if 1 < percent < 95:
                    trakt.scrobbleMovie(
                        self.imdb, percent
                    ) if self.content == 'movie' else trakt.scrobbleEpisode(
                        self.tvdb, self.season, self.episode, percent)
                    if control.setting('trakt.scrobble.notify') == 'true':
                        control.infoDialog('Trakt: Scrobbled')
            except:
                import traceback
                from resources.lib.modules import log_utils
                failure = traceback.format_exc()
                log_utils.log('Scrobble - Exception: ' + str(failure))
                control.infoDialog('Scrobble Failed')

        try:
            if (self.currentTime / self.totalTime) >= .90:
                self.libForPlayback()
        except:
            pass

        if control.setting('crefresh') == 'true':
            control.refresh()
    def library(self):
        self.addDirectoryItem("[B]LASTSHIP[/B]: Bibliothek aktualisieren",
                              'updateLibrary&query=tool', 'library_update.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem("[B]LASTSHIP[/B]: Film-Ordner",
                              control.setting('library.movie'),
                              'movies.png',
                              'DefaultMovies.png',
                              isAction=False)
        self.addDirectoryItem("[B]LASTSHIP[/B]: TV-Serien-Ordner",
                              control.setting('library.tv'),
                              'tvshows.png',
                              'DefaultTVShows.png',
                              isAction=False)

        if trakt.getTraktCredentialsInfo():
            self.addDirectoryItem("[B]TRAKT[/B]: Film-Sammlung importieren",
                                  'moviesToLibrary&url=traktcollection',
                                  'trakt.png', 'DefaultMovies.png')
            self.addDirectoryItem("[B]TRAKT[/B]: Film-Merkliste importieren",
                                  'moviesToLibrary&url=traktwatchlist',
                                  'trakt.png', 'DefaultMovies.png')
            self.addDirectoryItem(
                "[B]TRAKT[/B]: TV-Serien-Sammlung importieren",
                'tvshowsToLibrary&url=traktcollection', 'trakt.png',
                'DefaultTVShows.png')
            self.addDirectoryItem(
                "[B]TRAKT[/B]: TV-Serien-Merkliste importieren",
                'tvshowsToLibrary&url=traktwatchlist', 'trakt.png',
                'DefaultTVShows.png')

        self.endDirectory()
Example #11
0
    def onPlayBackStarted(self):
        if int(control.getKodiVersion()) < 18:
            control.execute('Dialog.Close(all,true)')

            if control.setting(
                    'bookmarks'
            ) == 'true' and not self.offset == '0' and self.isPlayingVideo():
                if control.setting('bookmarks.auto') == 'true':
                    self.seekTime(float(self.offset))
                else:
                    if control.setting(
                            'rersume.source'
                    ) == '1' and trakt.getTraktCredentialsInfo() == True:
                        yes = control.dialog.contextmenu([
                            "Resume (Trakt)",
                            control.lang(32501).encode('utf-8'),
                        ])
                        if yes == 0:
                            self.seekTime(float(self.offset))
                    else:
                        minutes, seconds = divmod(float(self.offset), 60)
                        hours, minutes = divmod(minutes, 60)
                        label = '%02d:%02d:%02d' % (hours, minutes, seconds)
                        label = (control.lang(32502) % label).encode('utf-8')
                        yes = control.dialog.contextmenu([
                            label,
                            control.lang(32501).encode('utf-8'),
                        ])
                        if yes == 0:
                            self.seekTime(float(self.offset))

            subtitles().get(self.name, self.imdb, self.season, self.episode)
            self.idleForPlayback()
        else:
            self.onAVStarted()
Example #12
0
    def __init__(self, type='show'):
        self.list = []
        self.type = type
        self.lang = control.apiLanguage()['tvdb']
        self.season_special = False

        self.datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(hours=5))
        self.today_date = (self.datetime).strftime('%Y-%m-%d')

        # self.tvdb_key = control.setting('tvdb.user')
        # if self.tvdb_key == '' or self.tvdb_key is None:
        self.tvdb_key = 'MUQ2MkYyRjkwMDMwQzQ0NA=='
        # decoded key above = 1D62F2F90030C444
        # Test for api response
        # http://thetvdb.com/api/1D62F2F90030C444/series/121361/all/en.zip

        self.tvdb_info_link = 'https://thetvdb.com/api/%s/series/%s/all/%s.zip' % (
            self.tvdb_key.decode('base64'), '%s', '%s')
        self.tvdb_by_imdb = 'https://thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=%s'
        self.tvdb_by_query = 'https://thetvdb.com/api/GetSeries.php?seriesname=%s'
        self.tvdb_image = 'https://thetvdb.com/banners/'
        self.tvdb_poster = 'https://thetvdb.com/banners/_cache/'

        self.trakt_user = control.setting('trakt.user').strip()
        self.traktCredentials = trakt.getTraktCredentialsInfo()
        self.traktwatchlist_link = 'http://api-v2launch.trakt.tv/users/me/watchlist/seasons'
        self.traktlist_link = 'http://api-v2launch.trakt.tv/users/%s/lists/%s/items'
        self.traktlists_link = 'http://api-v2launch.trakt.tv/users/me/lists'

        self.showunaired = control.setting('showunaired') or 'true'
        self.unairedcolor = control.setting('unaired.identify')
        self.unairedcolor = self.getUnairedColor(self.unairedcolor)
Example #13
0
    def __init__(self, type='show'):
        self.list = []
        self.type = type
        self.lang = control.apiLanguage()['tvdb']
        self.season_special = False
        self.disable_fanarttv = control.setting('disable.fanarttv')

        # self.date_time = (datetime.utcnow() - timedelta(hours=5))
        self.date_time = datetime.utcnow()
        self.today_date = (self.date_time).strftime('%Y-%m-%d')

        self.tvdb_key = control.setting('tvdb.api.key')

        self.tvdb_info_link = 'https://thetvdb.com/api/%s/series/%s/all/%s.zip' % (
            self.tvdb_key.decode('base64'), '%s', '%s')
        self.tvdb_by_imdb = 'https://thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=%s'
        self.tvdb_by_query = 'https://thetvdb.com/api/GetSeries.php?seriesname=%s'
        self.tvdb_image = 'https://thetvdb.com/banners/'
        self.tvdb_poster = 'https://thetvdb.com/banners/_cache/'

        self.trakt_user = control.setting('trakt.user').strip()
        self.traktCredentials = trakt.getTraktCredentialsInfo()
        self.traktwatchlist_link = 'https://api-v2launch.trakt.tv/users/me/watchlist/seasons'
        self.traktlist_link = 'https://api-v2launch.trakt.tv/users/%s/lists/%s/items'
        self.traktlists_link = 'https://api-v2launch.trakt.tv/users/me/lists'

        self.showunaired = control.setting('showunaired') or 'true'
        self.unairedcolor = control.getColor(
            control.setting('unaired.identify'))
Example #14
0
def settraktstatus(show_id, asset_id, progress, content, watched):

    import syncdata;
    from resources.lib.modules import trakt;

    try:

        if trakt.getTraktCredentialsInfo():

            tvdb_info = syncdata.fetchtraktupdateinfo(show_id, asset_id);

            if tvdb_info is not None and len(tvdb_info) == 3:

                (tvdb, season, episode) = tvdb_info;

                if watched == 1:
                    trakt.markEpisodeAsWatched(tvdb, season, episode);

                else:
                    trakt.markEpisodeAsNotWatched(tvdb, season, episode);

            trakt.stopProgress(content, show_id, asset_id, progress);

    except Exception as inst:
        logger.error(inst);
        pass;
Example #15
0
 def onPlayBackEnded(self):
     bookmarks.reset(1, 1, self.content, self.imdb, self.season,
                     self.episode)
     if (trakt.getTraktCredentialsInfo() == True
             and control.setting('trakt.scrobble') == 'true'):
         bookmarks.set_scrobble(1, 1, self.content, self.imdb, self.tmdb,
                                self.season, self.episode)
     self.libForPlayback()
Example #16
0
 def getGroups(self):
     if not trakt.getTraktCredentialsInfo():
         interface.Dialog.confirm(title=32007, message=35245)
         return None
     if self.sky_channels():
         channels = sorted([i for i in self.channels.iterkeys()])
         self.groupDirectory(channels)
     return self.channels
Example #17
0
 def __init__(self):
     self.artPath = control.artPath()
     self.iconLogos = control.setting('icon.logos') != 'Traditional'
     self.indexLabels = control.setting('index.labels') == 'true'
     self.traktCredentials = getTraktCredentialsInfo()
     self.traktIndicators = getTraktIndicatorsInfo()
     self.imdbCredentials = control.setting('imdb.user') != ''
     self.tmdbSessionID = control.setting('tmdb.session_id') != ''
Example #18
0
def main():
    while not control.monitor.abortRequested():
        xbmc.log('[ plugin.video.venom ]  Service Started', 2)
        syncWatched = None
        syncProgress = None
        schedTrakt = None
        libraryService = None
        CheckSettingsFile().run()
        SyncMyAccounts().run()
        ReuseLanguageInvokerCheck().run()
        if control.setting('library.service.update') == 'true':
            libraryService = True
            LibraryService().run()
        if control.setting('general.checkAddonUpdates') == 'true':
            AddonCheckUpdate().run()
        if trakt.getTraktCredentialsInfo() is True:
            if control.setting('indicators.alt') == '1':
                syncWatched = True
                SyncTraktWatched().run()
            if control.setting('bookmarks') == 'true' and control.setting(
                    'resume.source') == '1':
                syncProgress = True
                SyncTraktProgress().run()
            if control.setting('autoTraktOnStart') == 'true':
                SyncTraktCollection().run()
            if int(control.setting('schedTraktTime')) > 0:
                log_utils.log(
                    '#################### STARTING TRAKT SCHEDULING ################',
                    log_utils.LOGNOTICE)
                log_utils.log(
                    '#################### SCHEDULED TIME FRAME ' +
                    control.setting('schedTraktTime') +
                    ' HOURS ###############', log_utils.LOGNOTICE)
                timeout = 3600 * int(control.setting('schedTraktTime'))
                schedTrakt = threading.Timer(
                    timeout,
                    SyncTraktCollection().run
                )  # this only runs once at the designated interval time to wait...not repeating
                schedTrakt.start()
        break
    SettingsMonitor().waitForAbort()
    xbmc.log('[ plugin.video.venom ]  Settings Monitor Service Stopping...', 2)
    if syncWatched:
        xbmc.log(
            '[ plugin.video.venom ]  Trakt Watched Sync Service Stopping...',
            2)
    if syncProgress:
        xbmc.log(
            '[ plugin.video.venom ]  Trakt Progress Sync Service Stopping...',
            2)
    if libraryService:
        xbmc.log('[ plugin.video.venom ]  Library Update Service Stopping...',
                 2)
    if schedTrakt:
        schedTrakt.cancel()
        # xbmc.log('[ plugin.video.venom ]  Trakt Collection Sync Stopping...', 2)

    xbmc.log('[ plugin.video.venom ]  Service Stopped', 2)
Example #19
0
def get(media_type, imdb, season, episode, local=False):

    if control.setting('rersume.source') == '1' and trakt.getTraktCredentialsInfo() == True and local == False:
        try:
            if media_type == 'episode':

                # Looking for a Episode progress
                traktInfo = trakt.getTraktAsJson('https://api.trakt.tv/sync/playback/episodes?extended=full')
                for i in traktInfo:
                    if imdb == i['show']['ids']['imdb']:
                        # Checking Episode Number
                        if int(season) == i['episode']['season'] and int(episode) == i['episode']['number']:
                            seekable = 1 < i['progress'] < 92
                            if seekable:
                                # Calculating Offset to seconds
                                offset = (float(i['progress'] / 100) * int(i['episode']['runtime']) * 60)
                            else:
                                offset = 0
            else:

                # Looking for a Movie Progress
                traktInfo = trakt.getTraktAsJson('https://api.trakt.tv/sync/playback/movies?extended=full')
                for i in traktInfo:
                    if imdb == i['movie']['ids']['imdb']:
                        seekable = 1 < i['progress'] < 92
                        if seekable:
                            # Calculating Offset to seconds
                            offset = (float(i['progress'] / 100) * int(i['movie']['runtime']) * 60)
                        else:
                            offset = 0

            return offset

        except:
            return 0

    else:
        try:

            sql_select = "SELECT * FROM bookmarks WHERE imdb = '%s'" % imdb
            if media_type == 'episode':
                sql_select += " AND season = '%s' AND episode = '%s'" % (season, episode)

            control.makeFile(control.dataPath)
            dbcon = database.connect(control.bookmarksFile)
            dbcur = dbcon.cursor()
            dbcur.execute(sql_select)
            match = dbcur.fetchone()
            if match:
                offset = match[0]
                return float(offset)
            else:
                return 0
            dbcon.commit()
        except:
            log_utils.log('bookmarks_get', 1)
            return 0
    def userlists(self):
        try:
            userlists = []
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            activity = trakt.getActivity()
        except:
            pass

        try:
            if trakt.getTraktCredentialsInfo() == False:
                raise Exception("Trakt user not set")
            try:
                if activity > cache.timeout(self.trakt_user_list, self.traktlists_link, self.trakt_user): raise Exception()
                userlists += cache.get(self.trakt_user_list, 720, self.traktlists_link, self.trakt_user)
            except:
                userlists += cache.get(self.trakt_user_list, 0, self.traktlists_link, self.trakt_user)
        except Exception as e:
            log_utils.log('Trakt user list error: %s' % (e), log_utils.LOGWARNING)
            pass
        try:
            self.list = []
            if not self.imdb_user:
                raise Exception('IMDB user not set')
            userlists += cache.get(imdb_lists.IMDBLists('tvSeries',
                    imdb_user=self.imdb_user).get_user_lists, 0, 'tvSeries')
            log_utils.log(user_lists)
        except Exception as e:
            log_utils.log('IMDB user list error: %s' % (e), log_utils.LOGWARNING)
            pass
        try:
            self.list = []
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            try:
                if activity > cache.timeout(self.trakt_user_list, self.traktlikedlists_link, self.trakt_user): raise Exception()
                userlists += cache.get(self.trakt_user_list, 720, self.traktlikedlists_link, self.trakt_user)
            except:
                userlists += cache.get(self.trakt_user_list, 0, self.traktlikedlists_link, self.trakt_user)
        except:
            pass

        self.list = userlists
        for i in range(0, len(self.list)): self.list[i].update({'image': 'userlists.png', 'action': 'tvshows'})
        self.addDirectory(self.list)
        return self.list
Example #21
0
    def library(self):
        self.addDirectoryItem(32557, 'openSettings&query=5.0', 'tools.png', 'DefaultAddonProgram.png')
        self.addDirectoryItem(32558, 'updateLibrary&query=tool', 'library_update.png', 'DefaultAddonProgram.png')
        self.addDirectoryItem(32559, control.setting('library.movie'), 'movies.png', 'DefaultMovies.png', isAction=False)
        self.addDirectoryItem(32560, control.setting('library.tv'), 'tvshows.png', 'DefaultTVShows.png', isAction=False)

        if trakt.getTraktCredentialsInfo():
            self.addDirectoryItem(32561, 'moviesToLibrary&url=traktcollection', 'trakt.png', 'DefaultMovies.png')
            self.addDirectoryItem(32562, 'moviesToLibrary&url=traktwatchlist', 'trakt.png', 'DefaultMovies.png')
            self.addDirectoryItem(32563, 'tvshowsToLibrary&url=traktcollection', 'trakt.png', 'DefaultTVShows.png')
            self.addDirectoryItem(32564, 'tvshowsToLibrary&url=traktwatchlist', 'trakt.png', 'DefaultTVShows.png')

        self.endDirectory()
Example #22
0
    def userlists(self):
        try:
            userlists = []
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            activity = trakt.getActivity()
        except:
            pass

        try:
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            try:
                if activity > cache.timeout(self.trakt_user_list, self.traktlists_link): raise Exception()
                userlists += cache.get(self.trakt_user_list, 720, self.traktlists_link)
            except:
                userlists += cache.get(self.trakt_user_list, 0, self.traktlists_link)
        except:
            pass
        try:
            self.list = []
            if self.imdb_user == '': raise Exception()
            userlists += cache.get(self.imdb_user_list, 0, self.imdblists_link)
        except:
            pass
        try:
            self.list = []
            if trakt.getTraktCredentialsInfo() == False: raise Exception()
            try:
                if activity > cache.timeout(self.trakt_user_list, self.traktlikedlists_link): raise Exception()
                userlists += cache.get(self.trakt_user_list, 720, self.traktlikedlists_link)
            except:
                userlists += cache.get(self.trakt_user_list, 0, self.traktlikedlists_link)
        except:
            pass

        self.list = userlists
        for i in range(0, len(self.list)): self.list[i].update({'image': 'userlists.png', 'action': 'movies'})
        self.addDirectory(self.list, queue=True)
        return self.list
Example #23
0
 def __init__(self):
     self.list = []
     self.lang = control.apiLanguage()['tmdb']
     self.enable_fanarttv = getSetting('enable.fanarttv') == 'true'
     self.prefer_tmdbArt = getSetting('prefer.tmdbArt') == 'true'
     self.date_time = datetime.now()
     self.today_date = (self.date_time).strftime('%Y-%m-%d')
     self.tmdb_poster_path = 'https://image.tmdb.org/t/p/w342'
     self.trakt_user = getSetting('trakt.username').strip()
     self.traktCredentials = trakt.getTraktCredentialsInfo()
     # self.traktwatchlist_link = 'https://api.trakt.tv/users/me/watchlist/seasons'
     # self.traktlists_link = 'https://api.trakt.tv/users/me/lists'
     self.showunaired = getSetting('showunaired') == 'true'
     self.unairedcolor = control.getColor(getSetting('unaired.identify'))
     self.showspecials = getSetting('tv.specials') == 'true'
Example #24
0
 def __init__(self):
     xbmc.Player.__init__(self)
     self.play_next_triggered = False
     self.preScrape_triggered = False
     self.playback_resumed = False
     self.av_started = False
     self.media_type = None
     self.DBID = None
     self.offset = '0'
     self.media_length = 0
     self.current_time = 0
     self.meta = {}
     self.enable_playnext = control.setting('enable.playnext') == 'true'
     self.playnext_time = int(control.setting('playnext.time')) or 60
     self.traktCredentials = trakt.getTraktCredentialsInfo()
Example #25
0
    def onPlayBackStopped(self):
        if self.totalTime == 0 or self.currentTime == 0:
            control.sleep(2000)
            return
        bookmarks.reset(self.currentTime, self.totalTime, self.content,
                        self.imdb, self.season, self.episode)
        if (trakt.getTraktCredentialsInfo() == True
                and control.setting('trakt.scrobble') == 'true'):
            bookmarks.set_scrobble(self.currentTime, self.totalTime,
                                   self.content, self.imdb, self.tmdb,
                                   self.season, self.episode)

        if float(self.currentTime / self.totalTime) >= 0.92:
            self.libForPlayback()
            if control.setting('crefresh') == 'true':
                control.refresh()
Example #26
0
	def getChannels(self, group = None):
		if not trakt.getTraktCredentialsInfo():
			interface.Dialog.confirm(title = 32007, message = 35245)
			return None
		if len(self.channels.keys()) == 0:
			if not self.sky_channels():
				return None
		if self.sky_list(group = group):
			threads = []
			for i in range(0, len(self.items)): threads.append(workers.Thread(self.items_list, self.items[i]))
			[i.start() for i in threads]
			[i.join() for i in threads]
			self.list = metacache.local(self.list, self.tm_img_link, 'poster2', 'fanart')
			try: self.list = sorted(self.list, key = lambda k : k['channel'])
			except: pass
			self.channelDirectory(self.list)
		return self.list
Example #27
0
    def __init__(self, type='show'):
        self.list = []
        self.type = type
        self.lang = control.apiLanguage()['tmdb']
        self.season_special = False
        self.date_time = datetime.now()
        self.today_date = (self.date_time).strftime('%Y-%m-%d')

        self.tmdb_poster_path = 'https://image.tmdb.org/t/p/w300'
        self.trakt_user = control.setting('trakt.user').strip()
        self.traktCredentials = trakt.getTraktCredentialsInfo()
        self.traktwatchlist_link = 'https://api.trakt.tv/users/me/watchlist/seasons'
        self.traktlists_link = 'https://api.trakt.tv/users/me/lists'
        self.showunaired = control.setting('showunaired') == 'true'
        self.unairedcolor = control.getColor(
            control.setting('unaired.identify'))
        self.showspecials = control.setting('tv.specials') == 'true'
Example #28
0
    def tools(self):
        self.addDirectoryItem('[B]TheOath[/B] : Changelog', 'changelog',
                              'tools.png', 'DefaultAddonProgram.png')
        self.addDirectoryItem(32043, 'openSettings&query=0.0', 'tools.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32556, 'libraryNavigator', 'tools.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32049, 'viewsNavigator', 'tools.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32604, 'clearCacheSearch', 'tools.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32050, 'clearSources', 'tools.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32052, 'clearCache', 'tools.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32611, 'clearAllCache', 'tools.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32076, 'smuSettings', 'resolveurl.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem(32079, 'oathscrapersettings', 'icon.png',
                              'DefaultAddonProgram.png')
        if not control.condVisibility(
                'System.HasAddon(script.module.openscrapers)'):
            self.addDirectoryItem('[B]Openscrapers[/B] : Install',
                                  'installOpenscrapers', 'openscr.png',
                                  'DefaultAddonProgram.png')
        else:
            self.addDirectoryItem(32082, 'openscrapersettings', 'openscr.png',
                                  'DefaultAddonProgram.png')
        if not control.condVisibility('System.HasAddon(script.module.orion)'):
            self.addDirectoryItem('[B]Orion[/B] : Install', 'installOrion',
                                  'orion.png', 'DefaultAddonProgram.png')
        else:
            self.addDirectoryItem(32080, 'orionsettings', 'orion.png',
                                  'DefaultAddonProgram.png')
        if trakt.getTraktCredentialsInfo():
            self.addDirectoryItem(32093, 'syncTraktStatus', 'trakt.png',
                                  'DefaultAddonProgram.png')
        self.addDirectoryItem(32073, 'authTrakt', 'trakt.png',
                              'DefaultAddonProgram.png')

        self.endDirectory()
Example #29
0
	def get(self):
		if not trakt.getTraktCredentialsInfo():
			interface.Dialog.confirm(title = 32007, message = 35245)
			return

		channels = [
		('01', 'Sky Premiere', '4021'),
		('02', 'Sky Premiere +1', '1823'),
		('03', 'Sky Showcase', '4033'),
		('04', 'Sky Greats', '1815'),
		('05', 'Sky Disney', '4013'),
		('06', 'Sky Family', '4018'),
		('07', 'Sky Action', '4014'),
		('08', 'Sky Comedy', '4019'),
		('09', 'Sky Crime', '4062'),
		('10', 'Sky Drama', '4016'),
		('11', 'Sky Sci Fi', '4017'),
		('12', 'Sky Select', '4020'),
		('13', 'Film4', '4044'),
		('14', 'Film4 +1', '1629'),
		('15', 'TCM', '3811'),
		('16', 'TCM +1', '5275')
		]

		threads = []
		for i in channels: threads.append(workers.Thread(self.sky_list, i[0], i[1], i[2]))
		[i.start() for i in threads]
		[i.join() for i in threads]

		threads = []
		for i in range(0, len(self.items)): threads.append(workers.Thread(self.items_list, self.items[i]))
		[i.start() for i in threads]
		[i.join() for i in threads]

		self.list = metacache.local(self.list, self.tm_img_link, 'poster2', 'fanart')

		try: self.list = sorted(self.list, key=lambda k: k['num'])
		except: pass

		self.channelDirectory(self.list)
		return self.list
Example #30
0
def fetchtraktprogressdata(show_id, asset_id):

    import syncdata;
    from resources.lib.modules import trakt;

    try:

        if trakt.getTraktCredentialsInfo():

            trakt_info = syncdata.fetchtraktprogressinfo(show_id, asset_id);

            if trakt_info is not None and len(trakt_info) == 3:

                return trakt_info;

            else:
                return None;

    except Exception as inst:
        logger.error(inst);
        
        return None;
    def __init__(self, type='show'):
        self.list = []
        self.type = type
        self.lang = control.apiLanguage()['tvdb']
        self.season_special = False
        self.disable_fanarttv = control.setting('disable.fanarttv')

        # self.date_time = (datetime.utcnow() - timedelta(hours=5))
        self.date_time = datetime.utcnow()
        self.today_date = (self.date_time).strftime('%Y-%m-%d')

        self.tvdb_key = control.setting('tvdb.api.key')
        self.tvdb_image = 'https://thetvdb.com/banners/'
        self.tvdb_poster = 'https://thetvdb.com/banners/_cache/'

        self.trakt_user = control.setting('trakt.user').strip()
        self.traktCredentials = trakt.getTraktCredentialsInfo()
        self.traktwatchlist_link = 'https://api.trakt.tv/users/me/watchlist/seasons'
        self.traktlists_link = 'https://api.trakt.tv/users/me/lists'

        self.showunaired = control.setting('showunaired') or 'true'
        self.unairedcolor = control.getColor(
            control.setting('unaired.identify'))
Example #32
0
    def movieDirectory(self, items):
        if items == None or len(items) == 0: return

        isFolder = True if control.setting('autoplay') == 'false' and control.setting('hosts.mode') == '1' else False
        isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder

        playbackMenu = control.lang(30204).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30203).encode('utf-8')

        traktCredentials = trakt.getTraktCredentialsInfo()

        indicators = playcount.getMovieIndicators()

        cacheToDisc = False if not action == 'movieSearch' else True

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')
        sysaddon = sys.argv[0]

        for i in items:
            try:
                label = '%s (%s)' % (i['title'], i['year'])
                imdb, title, year = i['imdb'], i['originaltitle'], i['year']
                sysname = urllib.quote_plus('%s (%s)' % (title, year))
                sysimage = urllib.quote_plus(i['poster'])
                systitle = urllib.quote_plus(title)


                poster, banner, fanart = i['poster'], i['banner'], i['fanart']
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster


                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})
                if i['duration'] == '0': meta.update({'duration': '120'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass
                try: del meta['tagline']
                except: pass
                sysmeta = urllib.quote_plus(json.dumps(meta))


                url = '%s?action=play&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, sysmeta, self.systime)
                sysurl = urllib.quote_plus(url)

                path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb)

                if isFolder == True:
                    url = '%s?action=sources&title=%s&year=%s&imdb=%s&meta=%s' % (sysaddon, systitle, year, imdb, sysmeta)


                try:
                    overlay = int(playcount.getMovieOverlay(indicators, imdb))
                    if overlay == 7: meta.update({'playcount': 1, 'overlay': 7})
                    else: meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass

                cm = []

                cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta)))

                if isFolder == False:
                    cm.append((control.lang(30202).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon))

                if traktCredentials == True:
                    cm.append((control.lang(30208).encode('utf-8'), 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb)))

                cm.append((control.lang(30214).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname)))
                cm.append((control.lang(30205).encode('utf-8'), 'Action(Info)'))
                cm.append((control.lang(30206).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb)))
                cm.append((control.lang(30207).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb)))
                cm.append((control.lang(30212).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon))


                item = control.item(label=label, iconImage=poster, thumbnailImage=poster)

                try: item.setArt({'poster': poster, 'banner': banner})
                except: pass

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels = meta)
                item.setProperty('Video', 'true')
                #item.setProperty('IsPlayable', 'true')
                item.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()
            url = '%s?action=movies&url=%s' % (sysaddon, urllib.quote_plus(url))
            addonNext = control.addonNext()
            item = control.item(label=control.lang(30213).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext)
            item.addContextMenuItems([], replaceItems=True)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
        except:
            pass


        control.content(int(sys.argv[1]), 'movies')
        control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc)
        views.setView('movies', {'skin.confluence': 500})
Example #33
0
'''


import os,sys,urlparse

from resources.lib.modules import control
from resources.lib.modules import trakt


sysaddon = sys.argv[0] ; syshandle = int(sys.argv[1]) ; control.moderator()

artPath = control.artPath() ; addonFanart = control.addonFanart()

imdbCredentials = False if control.setting('imdb.user') == '' else True

traktCredentials = trakt.getTraktCredentialsInfo()

traktIndicators = trakt.getTraktIndicatorsInfo()

queueMenu = control.lang(32065).encode('utf-8')


class navigator:
    def root(self):
        self.addDirectoryItem(32001, 'movieNavigator', 'movies.png', 'DefaultMovies.png')
        self.addDirectoryItem(32002, 'tvNavigator', 'tvshows.png', 'DefaultTVShows.png')

        if not control.setting('lists.widget') == '0':
            self.addDirectoryItem(32003, 'mymovieNavigator', 'mymovies.png', 'DefaultVideoPlaylists.png')
            self.addDirectoryItem(32004, 'mytvNavigator', 'mytvshows.png', 'DefaultVideoPlaylists.png')
    def tvshowDirectory(self, items):
        if items == None or len(items) == 0: control.idle() ; sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')

        traktCredentials = trakt.getTraktCredentialsInfo()

        try: isOld = False ; control.item().getArt('type')
        except: isOld = True

        indicators = playcount.getTVShowIndicators(refresh=True) if action == 'tvshows' else playcount.getTVShowIndicators()

        flatten = True if control.setting('flatten.tvshows') == 'true' else False

        watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8')

        unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8')

        queueMenu = control.lang(32065).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')

        nextMenu = control.lang(32053).encode('utf-8')

        playRandom = control.lang(32535).encode('utf-8')

        addToLibrary = control.lang(32551).encode('utf-8')

        for i in items:
            try:
                label = i['title']
                systitle = sysname = urllib.quote_plus(i['originaltitle'])
                sysimage = urllib.quote_plus(i['poster'])
                imdb, tvdb, year = i['imdb'], i['tvdb'], i['year']

                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb})
                meta.update({'tvdb_id': tvdb})
                meta.update({'mediatype': 'tvshow'})
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(label))})
                if not 'duration' in i: meta.update({'duration': '60'})
                elif i['duration'] == '0': meta.update({'duration': '60'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass

                try:
                    overlay = int(playcount.getTVShowOverlay(indicators, tvdb))
                    if overlay == 7: meta.update({'playcount': 1, 'overlay': 7})
                    else: meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass


                if flatten == True:
                    url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb)
                else:
                    url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb)


                cm = []

                cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=season&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, urllib.quote_plus(systitle), urllib.quote_plus(year), urllib.quote_plus(imdb), urllib.quote_plus(tvdb))))

                cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb)))

                cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, imdb, tvdb)))

                if traktCredentials == True:
                    cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb)))

                if isOld == True:
                    cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))

                cm.append((addToLibrary, 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tvdb)))

                item = control.item(label=label)

                art = {}

                if 'poster' in i and not i['poster'] == '0':
                    art.update({'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster']})
                #elif 'poster2' in i and not i['poster2'] == '0':
                    #art.update({'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2']})
                else:
                    art.update({'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster})

                if 'banner' in i and not i['banner'] == '0':
                    art.update({'banner': i['banner']})
                #elif 'banner2' in i and not i['banner2'] == '0':
                    #art.update({'banner': i['banner2']})
                elif 'fanart' in i and not i['fanart'] == '0':
                    art.update({'banner': i['fanart']})
                else:
                    art.update({'banner': addonBanner})

                if 'clearlogo' in i and not i['clearlogo'] == '0':
                    art.update({'clearlogo': i['clearlogo']})

                if 'clearart' in i and not i['clearart'] == '0':
                    art.update({'clearart': i['clearart']})

                if settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0':
                    item.setProperty('Fanart_Image', i['fanart'])
                #elif settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0':
                    #item.setProperty('Fanart_Image', i['fanart2'])
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setArt(art)
                item.addContextMenuItems(cm)
                item.setInfo(type='Video', infoLabels = meta)

                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)

                control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()

            icon = control.addonNext()
            url = '%s?action=tvshowPage&url=%s' % (sysaddon, urllib.quote_plus(url))

            item = control.item(label=nextMenu)

            item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon})
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)

            control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
        except:
            pass

        control.content(syshandle, 'tvshows')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('tvshows', {'skin.estuary': 55, 'skin.confluence': 500})
Example #35
0
    def tvshowDirectory(self, items):
        if items == None or len(items) == 0: return

        isFolder = True if control.setting(
            'autoplay') == 'false' and control.setting(
                'hosts.mode') == '1' else False
        isFolder = False if control.window.getProperty(
            'PseudoTVRunning') == 'True' else isFolder

        traktCredentials = trakt.getTraktCredentialsInfo()

        indicators = playcount.getTVShowIndicators()

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting(
            'fanart')
        sysaddon = sys.argv[0]

        for i in items:
            try:
                label = i['title']
                systitle = sysname = urllib.quote_plus(i['originaltitle'])
                sysimage = urllib.quote_plus(i['poster'])
                imdb, tvdb, year = i['imdb'], i['tvdb'], i['year']

                poster, banner, fanart = i['poster'], i['banner'], i['fanart']
                if banner == '0' and not poster == '0': banner = poster
                if poster == '0': poster = addonPoster
                if banner == '0': banner = addonBanner

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s' % (sysaddon, sysname)
                })
                if i['duration'] == '0': meta.update({'duration': '60'})
                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass
                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (
                    sysaddon, systitle, year, imdb, tvdb)

                try:
                    overlay = int(playcount.getTVShowOverlay(indicators, tvdb))
                    if overlay == 7:
                        meta.update({'playcount': 1, 'overlay': 7})
                    else:
                        meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass

                cm = []

                if isFolder == False:
                    cm.append((control.lang(30232).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))

                if traktCredentials == True:
                    cm.append((control.lang(30236).encode(
                        'utf-8'
                    ), 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)'
                               % (sysaddon, sysname, tvdb)))

                cm.append((control.lang(30242).encode('utf-8'),
                           'RunPlugin(%s?action=trailer&name=%s)' %
                           (sysaddon, sysname)))
                cm.append(
                    (control.lang(30233).encode('utf-8'), 'Action(Info)'))
                cm.append((control.lang(30234).encode(
                    'utf-8'
                ), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)'
                           % (sysaddon, systitle, imdb, tvdb)))
                cm.append((control.lang(30235).encode(
                    'utf-8'
                ), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)'
                           % (sysaddon, systitle, imdb, tvdb)))
                cm.append((control.lang(30240).encode('utf-8'),
                           'RunPlugin(%s?action=addView&content=tvshows)' %
                           sysaddon))

                item = control.item(label=label,
                                    iconImage=poster,
                                    thumbnailImage=poster)

                try:
                    item.setArt({
                        'poster': poster,
                        'tvshow.poster': poster,
                        'season.poster': poster,
                        'banner': banner,
                        'tvshow.banner': banner,
                        'season.banner': banner
                    })
                except:
                    pass

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels=meta)
                item.setProperty('Video', 'true')
                item.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]),
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()
            url = '%s?action=tvshows&url=%s' % (sysaddon,
                                                urllib.quote_plus(url))
            addonNext = control.addonNext()
            item = control.item(label=control.lang(30241).encode('utf-8'),
                                iconImage=addonNext,
                                thumbnailImage=addonNext)
            item.addContextMenuItems([], replaceItems=False)
            if not addonFanart == None:
                item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=True)
        except:
            pass

        control.content(int(sys.argv[1]), 'tvshows')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
        views.setView('tvshows', {'skin.confluence': 500})
Example #36
0
import os, sys, urlparse

from resources.lib.modules import control
from resources.lib.modules import trakt

sysaddon = sys.argv[0]
syshandle = int(sys.argv[1])
()

artPath = control.artPath()
addonFanart = control.addonFanart()

imdbCredentials = False if control.setting('imdb.user') == '' else True

traktCredentials = trakt.getTraktCredentialsInfo()

traktIndicators = trakt.getTraktIndicatorsInfo()

queueMenu = control.lang(32065).encode('utf-8')


class navigator:
    def root(self):
        self.addDirectoryItem('Created by Genesis Reborn', 'ShowChangelog',
                              'icon.png', 'DefaultFolder.png')
        self.addDirectoryItem('Genesis Reborn Custom Viewtype',
                              'viewsNavigator', 'icon.png',
                              'DefaultAddonProgram.png')
        self.addDirectoryItem('Genesis Reborn Movies', 'movieNavigator',
                              'movies.png', 'DefaultMovies.png')
Example #37
0
def fetchshowstatus(showid):

    try:

        dbcon = database.connect(control.synchFile);
        dbcur = dbcon.cursor();

    except:
        return None;

    try:

        import itertools;
        from resources.lib.modules import trakt;


        if trakt.getTraktCredentialsInfo():

            sql_stmt = """
                SELECT asset_id
                    ,CASE
                        WHEN trakt_watched IS NOT NULL
                        THEN trakt_watched
                        WHEN fn_watched IS NOT NULL
                        THEN fn_watched
                        ELSE 0
                    END AS 'watched'
                    ,CASE
                        WHEN trakt_progress IS NOT NULL
                        THEN trakt_progress
                        WHEN fn_progress IS NOT NULL
                        THEN fn_progress
                        ELSE 0
                    END AS 'progress'
                FROM fn_episode_info
                WHERE show_id IN ('%s')
            """;

        else:

            sql_stmt = """
                SELECT asset_id
                    ,CASE
                        WHEN fn_watched IS NOT NULL
                        THEN fn_watched
                        ELSE 0
                    END AS 'watched'
                    ,CASE
                        WHEN fn_progress IS NOT NULL
                        THEN fn_progress
                        ELSE 0
                    END AS 'progress'
                FROM fn_episode_info
                WHERE show_id IN ('%s')
            """;

        dbcur.execute(sql_stmt % showid);

        desc = dbcur.description;
        column_names = [col[0] for col in desc];

        #statusmeta = {row[0]:dict(itertools.izip(column_names, row)) for row in dbcur};
        statusmeta = dict((row[0], dict(itertools.izip(column_names, row))) for row in dbcur)

        return statusmeta;

    except Exception as inst:
        #logger.error(inst);

        return None;
Example #38
0
	def episodeDirectory(self, items):
		if items == None or len(items) == 0:
			control.idle()
			sys.exit()

		sysaddon = sys.argv[0]

		syshandle = int(sys.argv[1])

		addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

		addonFanart, settingFanart = control.addonFanart(), tools.Settings.getBoolean('interface.fanart')

		traktCredentials = trakt.getTraktCredentialsInfo()

		try: isOld = False ; control.item().getArt('type')
		except: isOld = True

		isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false'

		indicators = playcount.getTVShowIndicators(refresh=True)

		try: multi = [i['tvshowtitle'] for i in items]
		except: multi = []
		multi = len([x for y,x in enumerate(multi) if x not in multi[:y]])
		multi = True if multi > 1 else False

		try: sysaction = items[0]['action']
		except: sysaction = ''

		isFolder = False if not sysaction == 'episodes' else True

		playbackMenu = control.lang(32063).encode('utf-8') if control.setting('playback.automatic.enabled') == 'true' else control.lang(32064).encode('utf-8')

		traktHas = trakt.getTraktIndicatorsInfo() == True
		watchedMenu = control.lang(32068).encode('utf-8') if traktHas else control.lang(32066).encode('utf-8')
		unwatchedMenu = control.lang(32069).encode('utf-8') if traktHas else control.lang(32067).encode('utf-8')

		unwatchedEnabled = tools.Settings.getBoolean('interface.tvshows.unwatched.enabled')
		unwatchedLimit = tools.Settings.getBoolean('interface.tvshows.unwatched.limit')

		airEnabled = tools.Settings.getBoolean('interface.tvshows.air.enabled')
		if airEnabled:
			airZone = tools.Settings.getInteger('interface.tvshows.air.zone')
			airLocation = tools.Settings.getInteger('interface.tvshows.air.location')
			airFormat = tools.Settings.getInteger('interface.tvshows.air.format')
			airAbbreviation = tools.Settings.getBoolean('interface.tvshows.air.abbreviation')
			airBold = tools.Settings.getBoolean('interface.tvshows.air.bold')
			airLabel = interface.Format.bold(interface.Translation.string(35032) + ': ')

		queueMenu = control.lang(32065).encode('utf-8')

		traktManagerMenu = control.lang(32070).encode('utf-8')

		tvshowBrowserMenu = control.lang(32071).encode('utf-8')

		media = tools.Media()

		for i in items:
			try:
				if not 'label' in i:
					i['label'] = i['title']
				if i['label'] == None or i['label'] == '' or i['label'] == '0':
					i['label'] = '%s %d' % (layoutEpisodeLong, int(i['episode']))

				label = None
				try: label = media.title(tools.Media.TypeEpisode, title = i['label'], season = i['season'], episode = i['episode'])
				except: pass
				if label == None:
					label = i['label']

				if multi == True and not label in i['tvshowtitle'] and not i['tvshowtitle'] in label:
					label = '%s - %s' % (i['tvshowtitle'], label)

				imdb, tvdb, year, season, episode, premiered = i['imdb'], i['tvdb'], i['year'], i['season'], i['episode'], i['premiered']

				# Make new episodes italicself.
				date = tools.Time.datetime(premiered, format = '%Y-%m-%d')
				current = datetime.datetime.now()
				if current <= date or current.date() == date.date():
					label = '[I]' + label + '[/I]'

				systitle = urllib.quote_plus(i['title'])
				systvshowtitle = urllib.quote_plus(i['tvshowtitle'])
				syspremiered = urllib.quote_plus(i['premiered'])

				meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
				meta.update({'mediatype': 'episode'})
				meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, systvshowtitle)})

				# Bubbles
				# Remove default time, since this might mislead users. Rather show no time.
				#if not 'duration' in i: meta.update({'duration': '60'})
				#elif i['duration'] == '0': meta.update({'duration': '60'})

				try: meta.update({'duration': str(int(meta['duration']) * 60)})
				except: pass
				try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
				except: pass
				try: meta.update({'title': i['label']})
				except: pass
				try: meta.update({'year': date.year}) # Kodi uses the year (the year the show started) as the year for the episode. Change it from the premiered date.
				except: pass

				if airEnabled:
					air = []
					airday = None
					airtime = None
					if 'airday' in meta and not meta['airday'] == None and not meta['airday'] == '':
						airday = meta['airday']
					if 'airtime' in meta and not meta['airtime'] == None and not meta['airtime'] == '':
						airtime = meta['airtime']
						if 'airzone' in meta and not meta['airzone'] == None and not meta['airzone'] == '':
							if airLocation == 1: zoneTo = meta['airzone']
							elif airLocation == 2: zoneTo = tools.Time.ZoneUtc
							else: zoneTo = tools.Time.ZoneLocal
							airtime = tools.Time.local(stringTime = meta['airtime'], stringDay = airday, zoneFrom = meta['airzone'], zoneTo = zoneTo)
							if airday:
								airday = airtime[1]
								airtime = airtime[0]
					if airday:
						if airAbbreviation:
							try: airday = airday[:3]
							except: pass
						air.append(airday)
					if airtime: air.append(airtime)
					if len(air) > 0:
						if airFormat == 0: air = airtime
						elif airFormat == 1: air = airday
						elif airFormat == 2: air = air = ' '.join(air)

						if airLocation == 0 or airLocation == 1:
							air = '[%s]' % air

						if airBold: air = interface.Format.bold(air)

						if airLocation == 0: label = '%s %s' % (air, label)
						elif airLocation == 1: label = '%s %s' % (label, air)
						elif airLocation == 2: meta['plot'] = '%s%s\r\n%s' % (airLabel, air, meta['plot'])
						elif airLocation == 3: meta['plot'] = '%s%s\r\n%s' % (airLabel, meta['plot'], air)

					airEnabled = tools.Settings.getBoolean('interface.tvshows.air.enabled')
					if airEnabled:
						airZone = tools.Settings.getInteger('interface.tvshows.air.zone')
						airLocation = tools.Settings.getInteger('interface.tvshows.air.location')
						airFormat = tools.Settings.getInteger('interface.tvshows.air.format')
						airAbbreviation = tools.Settings.getBoolean('interface.tvshows.air.abbreviation')
						airBold = tools.Settings.getBoolean('interface.tvshows.air.bold')

				sysmeta = urllib.quote_plus(json.dumps(meta))

				url = self.parameterize('%s?action=play&title=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s&tvshowtitle=%s&premiered=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, tvdb, season, episode, systvshowtitle, syspremiered, sysmeta, self.systime))
				sysurl = urllib.quote_plus(url)

				path = self.parameterize('%s?action=play&title=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s&tvshowtitle=%s&premiered=%s' % (sysaddon, systitle, year, imdb, tvdb, season, episode, systvshowtitle, syspremiered))

				if isFolder == True:
					url = self.parameterize('%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s&episode=%s' % (sysaddon, systvshowtitle, year, imdb, tvdb, season, episode))


				cm = []

				cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

				if multi == True:
					link = self.parameterize('%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systvshowtitle, year, imdb, tvdb))
					cm.append((tvshowBrowserMenu, 'Container.Update(%s,return)' % link))

				try:
					overlay = int(playcount.getEpisodeOverlay(indicators, imdb, tvdb, season, episode))
					if overlay == 7:
						if not traktHas:
							link = self.parameterize('%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=6' % (sysaddon, imdb, tvdb, season, episode))
							cm.append((unwatchedMenu, 'RunPlugin(%s)' % link))
						meta.update({'playcount': 1, 'overlay': 7})
					else:
						if not traktHas:
							link = self.parameterize('%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=7' % (sysaddon, imdb, tvdb, season, episode))
							cm.append((watchedMenu, 'RunPlugin(%s)' % link))
						meta.update({'playcount': 0, 'overlay': 6})
				except:
					overlay = None

				if traktCredentials == True:
					link = self.parameterize('%s?action=traktManager&tvdb=%s&season=%s&episode=%s' % (sysaddon, tvdb, season, episode))
					cm.append((traktManagerMenu, 'RunPlugin(%s)' % link))

				if not self.kidsOnly() and control.setting('downloads.manual.enabled') == 'true':
					cm.append((control.lang(33585).encode('utf-8'), 'Container.Update(%s?action=downloadsManager)' % (sysaddon)))

				if isFolder == False:
					cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta)))

				if isOld == True:
					cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))


				item = control.item(label=label)

				if multi and unwatchedEnabled and not overlay == None and not overlay == 7:
					try:
						count = playcount.getShowCount(indicators, tvdb, unwatchedLimit)
						if count:
							item.setProperty('TotalEpisodes', str(count['total']))
							item.setProperty('WatchedEpisodes', str(count['watched']))
							item.setProperty('UnWatchedEpisodes', str(count['unwatched']))
					except:
						pass

				art = {}

				poster = '0'
				if poster == '0' and 'poster3' in i: poster = i['poster3']
				if poster == '0' and 'poster2' in i: poster = i['poster2']
				if poster == '0' and 'poster' in i: poster = i['poster']

				icon = '0'
				if icon == '0' and 'icon3' in i: icon = i['icon3']
				if icon == '0' and 'icon2' in i: icon = i['icon2']
				if icon == '0' and 'icon' in i: icon = i['icon']

				thumb = '0'
				if thumb == '0' and 'thumb3' in i: thumb = i['thumb3']
				if thumb == '0' and 'thumb2' in i: thumb = i['thumb2']
				if thumb == '0' and 'thumb' in i: thumb = i['thumb']

				banner = '0'
				if banner == '0' and 'banner3' in i: banner = i['banner3']
				if banner == '0' and 'banner2' in i: banner = i['banner2']
				if banner == '0' and 'banner' in i: banner = i['banner']

				fanart = '0'
				if settingFanart:
					if fanart == '0' and 'fanart3' in i: fanart = i['fanart3']
					if fanart == '0' and 'fanart2' in i: fanart = i['fanart2']
					if fanart == '0' and 'fanart' in i: fanart = i['fanart']

				clearlogo = '0'
				if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo']

				clearart = '0'
				if clearart == '0' and 'clearart' in i: clearart = i['clearart']

				if poster == '0': poster = addonPoster
				if icon == '0': icon = poster
				if thumb == '0': thumb = poster
				if banner == '0': banner = addonBanner
				if fanart == '0': fanart = addonFanart

				if not poster == '0' and not poster == None: art.update({'poster' : poster, 'tvshow.poster' : poster, 'season.poster' : poster})
				if not icon == '0' and not icon == None: art.update({'icon' : icon})
				if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb})
				if not banner == '0' and not banner == None: art.update({'banner' : banner})
				if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo})
				if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart})
				if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart)

				item.setArt(art)
				item.addContextMenuItems(cm)
				item.setProperty('IsPlayable', isPlayable)
				item.setInfo(type='Video', infoLabels = meta)

				control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder)
			except:
				tools.Logger.error
				pass

		# Bubbles
		# Show multi as show, in order to display unwatched count.
		if multi:
			control.content(syshandle, 'tvshows')
			control.directory(syshandle, cacheToDisc=True)
			views.setView('shows', {'skin.estuary': 55, 'skin.confluence': 500})
		else:
			control.content(syshandle, 'episodes')
			control.directory(syshandle, cacheToDisc=True)
			views.setView('episodes', {'skin.estuary': 55, 'skin.confluence': 504})
Example #39
0
	def __init__(self, type='show', notifications=True):
		self.page_limit = control.setting('page.item.limit')
		self.search_page_limit = control.setting('search.page.limit')
		self.list = []
		self.meta = []
		self.threads = []
		self.type = type
		self.lang = control.apiLanguage()['tmdb']
		self.notifications = notifications
		self.disable_fanarttv = control.setting('disable.fanarttv') == 'true'
		self.date_time = datetime.now()
		self.today_date = (self.date_time).strftime('%Y-%m-%d')

		self.tvdb_key = control.setting('tvdb.api.key')
		self.imdb_user = control.setting('imdb.user').replace('ur', '')
		self.user = str(self.imdb_user) + str(self.tvdb_key)

		self.imdb_link = 'https://www.imdb.com'
		self.persons_link = 'https://www.imdb.com/search/name?count=100&name='
		self.personlist_link = 'https://www.imdb.com/search/name?count=100&gender=male,female'
		self.popular_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&num_votes=100,&release_date=,date[0]&sort=moviemeter,asc&count=%s&start=1' % self.page_limit
		self.airing_link = 'https://www.imdb.com/search/title?title_type=tv_episode&release_date=date[1],date[0]&sort=moviemeter,asc&count=%s&start=1' % self.page_limit
		self.active_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&num_votes=10,&production_status=active&sort=moviemeter,asc&count=%s&start=1' % self.page_limit
		self.premiere_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&languages=en&num_votes=10,&release_date=date[60],date[0]&sort=release_date,desc&count=%s&start=1' % self.page_limit
		self.rating_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&num_votes=5000,&release_date=,date[0]&sort=user_rating,desc&count=%s&start=1' % self.page_limit
		self.views_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&num_votes=100,&release_date=,date[0]&sort=num_votes,desc&count=%s&start=1' % self.page_limit
		self.person_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&release_date=,date[0]&role=%s&sort=year,desc&count=%s&start=1' % ('%s', self.page_limit)
		self.genre_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&release_date=,date[0]&genres=%s&sort=%s&count=%s&start=1' % ('%s', self.imdb_sort(type='imdbshows'), self.page_limit)
		self.keyword_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&release_date=,date[0]&keywords=%s&sort=%s&count=%s&start=1' % ('%s', self.imdb_sort(type='imdbshows'), self.page_limit)
		self.language_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&num_votes=100,&production_status=released&primary_language=%s&sort=%s&count=%s&start=1' % ('%s', self.imdb_sort(type='imdbshows'), self.page_limit)
		self.certification_link = 'https://www.imdb.com/search/title?title_type=tv_series,mini_series&release_date=,date[0]&certificates=%s&sort=%s&count=%s&start=1' % ('%s', self.imdb_sort(type='imdbshows'), self.page_limit)
		self.imdbwatchlist_link = 'https://www.imdb.com/user/ur%s/watchlist?sort=date_added,desc' % self.imdb_user # only used to get users watchlist ID
		self.imdbwatchlist2_link = 'https://www.imdb.com/list/%s/?view=detail&sort=%s&title_type=tvSeries,tvMiniSeries&start=1' % ('%s', self.imdb_sort(type='shows.watchlist'))
		self.imdblists_link = 'https://www.imdb.com/user/ur%s/lists?tab=all&sort=mdfd&order=desc&filter=titles' % self.imdb_user
		self.imdblist_link = 'https://www.imdb.com/list/%s/?view=detail&sort=%s&title_type=tvSeries,tvMiniSeries&start=1' % ('%s', self.imdb_sort())
		self.imdbratings_link = 'https://www.imdb.com/user/ur%s/ratings?sort=your_rating,desc&mode=detail&start=1' % self.imdb_user # IMDb ratings does not take title_type so filter in imdb_list() function
		self.anime_link = 'https://www.imdb.com/search/keyword?keywords=anime&title_type=tvSeries,miniSeries&sort=moviemeter,asc&count=%s&start=1' % self.page_limit

		self.trakt_user = control.setting('trakt.user').strip()
		self.traktCredentials = trakt.getTraktCredentialsInfo()
		self.trakt_link = 'https://api.trakt.tv'
		self.search_link = 'https://api.trakt.tv/search/show?limit=%s&page=1&query=' % self.search_page_limit
		self.traktlist_link = 'https://api.trakt.tv/users/%s/lists/%s/items/shows'
		self.traktlikedlists_link = 'https://api.trakt.tv/users/likes/lists?limit=1000000'
		self.traktlists_link = 'https://api.trakt.tv/users/me/lists'
		self.traktwatchlist_link = 'https://api.trakt.tv/users/me/watchlist/shows'
		self.traktcollection_link = 'https://api.trakt.tv/users/me/collection/shows'
		self.trakttrending_link = 'https://api.trakt.tv/shows/trending?page=1&limit=%s' % self.page_limit
		self.traktpopular_link = 'https://api.trakt.tv/shows/popular?page=1&limit=%s' % self.page_limit
		self.traktrecommendations_link = 'https://api.trakt.tv/recommendations/shows?limit=40'
		self.progress_link = 'https://api.trakt.tv/sync/watched/shows?extended=noseasons'
		self.hiddenprogress_link = 'https://api.trakt.tv/users/hidden/progress_watched?limit=1000&type=show'

		self.tvmaze_link = 'https://www.tvmaze.com'
		self.tmdb_key = control.setting('tmdb.api.key')
		if self.tmdb_key == '' or self.tmdb_key is None:
			self.tmdb_key = '3320855e65a9758297fec4f7c9717698'
		self.tmdb_session_id = control.setting('tmdb.session_id')
		self.tmdb_link = 'https://api.themoviedb.org'
		self.tmdb_userlists_link = 'https://api.themoviedb.org/3/account/{account_id}/lists?api_key=%s&language=en-US&session_id=%s&page=1' % ('%s', self.tmdb_session_id)
		self.tmdb_watchlist_link = 'https://api.themoviedb.org/3/account/{account_id}/watchlist/tv?api_key=%s&session_id=%s&sort_by=created_at.asc&page=1' % ('%s', self.tmdb_session_id)
		self.tmdb_favorites_link = 'https://api.themoviedb.org/3/account/{account_id}/favorite/tv?api_key=%s&session_id=%s&sort_by=created_at.asc&page=1' % ('%s', self.tmdb_session_id) 
		self.tmdb_popular_link = 'https://api.themoviedb.org/3/tv/popular?api_key=%s&language=en-US&region=US&page=1'
		self.tmdb_toprated_link = 'https://api.themoviedb.org/3/tv/top_rated?api_key=%s&language=en-US&region=US&page=1'
		self.tmdb_ontheair_link = 'https://api.themoviedb.org/3/tv/on_the_air?api_key=%s&language=en-US&region=US&page=1'
		self.tmdb_airingtoday_link = 'https://api.themoviedb.org/3/tv/airing_today?api_key=%s&language=en-US&region=US&page=1'
		self.tmdb_networks_link = 'https://api.themoviedb.org/3/discover/tv?api_key=%s&sort_by=popularity.desc&with_networks=%s&page=1'
Example #40
0
def synchistory(funshows, showid):

    if len(funshows) > 0:
        import json;
        import syncdata;

        from resources.lib.modules import client;
        from resources.lib.modules import cookiecache;
        from resources.lib.modules import control;
        from resources.lib.modules import trakt;
        from dateutil.relativedelta import relativedelta;


        try:

            expired = syncdata.fetchfnhistorycheck(showid);
            expired = expireddate(expired);

            if expired:
                
                rdate = datetime.datetime.now() + relativedelta(hours =+ 24);
                syncdata.insertfnhistorycheck(showid, rdate);

                syncdata.insertfnepisodes(funshows, 'series');

                uid = setting('fn.uid');

                if uid is not None:

                    cookie = cookiecache.fetch(uid.lower(), 1);
                    agent = setting(control.lang(32215).encode('utf-8'));

                    if agent is None:
                        agent = 'Sony-PS3';

                    headers = {'User-Agent': agent};

                    historyset = client.request(funimation_url % (uid, showid), headers=headers, redirect=False, cookie=cookie);
                    historyset = json.loads(historyset);

                    if 'videos' not in historyset:
                        syncdata.insertfnepisodes(historyset, 'history');


        except Exception as inst:
            logger.error(inst);
            pass;


        if trakt.getTraktCredentialsInfo():

            try:

                expired = syncdata.fetchtraktprogresslastupdated();
                expired = expireddate(expired);

                if expired:
                    traktprogress = trakt.getTrakt('sync/playback/episodes?type=episodes');
                    traktprogress = json.loads(traktprogress);

                    rdate = datetime.datetime.now() + relativedelta(hours =+ 24);

                    syncdata.synctraktprogress(traktprogress, rdate);

            except Exception as inst:
                logger.error(inst);
                pass;

            try:

                expired = syncdata.fetchtraktwatchedcheck(showid);
                expired = expireddate(expired);

                if expired:
                    
                    rdate = datetime.datetime.now() + relativedelta(hours =+ 24);
                    syncdata.inserttraktwatchedcheck(showid, rdate);

                    tvdbids = syncdata.fetchupdated(showid);

                    for tvdbid in tvdbids:
                        
                        traktids = trakt.getTrakt('search/tvdb/%s?id_type=tvdb&id=%s&type=show' % (tvdbid[0], tvdbid[0]));

                        try:

                            traktids = json.loads(traktids)[0]['show']['ids'];

                            watched = trakt.getTrakt('shows/%s/progress/watched?hidden=false&specials=false&count_specials=false' % traktids['slug']);
                            seasons = json.loads(watched)['seasons'];

                            for season in seasons:

                                for ep in season['episodes']:
                                    
                                    ep.update({
                                        'show_id': showid,
                                        'season_number': season['number'],
                                        'trakt_series_id': traktids['trakt'],
                                        'trakt_slug': traktids['slug'],
                                        'tvdbid': tvdbid[0],
                                        'completed': (1 if ep['completed'] is True else 'NULL')
                                    });

                                syncdata.insertfnepisodes(season['episodes'], 'trakt');


                        except Exception as inst:
                            logger.error(inst);
                            pass;


            except Exception as inst:
                logger.error(inst);
                pass;
Example #41
0
    def tvshowDirectory(self, items):
        if items == None or len(items) == 0: control.idle() ; sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')

        traktCredentials = trakt.getTraktCredentialsInfo()

        try: isOld = False ; control.item().getArt('type')
        except: isOld = True

        isEstuary = True if 'estuary' in control.skin else False

        indicators = playcount.getTVShowIndicators(refresh=True) if action == 'tvshows' else playcount.getTVShowIndicators()

        watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8')

        unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8')

        queueMenu = control.lang(32065).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')

        nextMenu = control.lang(32053).encode('utf-8')


        for i in items:
            try:
                label = i['title']
                systitle = sysname = urllib.quote_plus(i['originaltitle'])
                sysimage = urllib.quote_plus(i['poster'])
                imdb, tvdb, year = i['imdb'], i['tvdb'], i['year']


                poster, banner, fanart = i['poster'], i['banner'], i['fanart']
                if banner == '0' and not fanart == '0': banner = fanart
                elif banner == '0' and not poster == '0': banner = poster
                if poster == '0': poster = addonPoster
                if banner == '0': banner = addonBanner


                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'mediatype': 'tvshow'})
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})
                if i['duration'] == '0': meta.update({'duration': '60'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass
                if isEstuary == True:
                    try: del meta['cast']
                    except: pass

                try:
                    overlay = int(playcount.getTVShowOverlay(indicators, tvdb))
                    if overlay == 7: meta.update({'playcount': 1, 'overlay': 7})
                    else: meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass


                url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb)


                cm = []

                cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb)))

                cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, imdb, tvdb)))

                if traktCredentials == True:
                    cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb)))

                if isOld == True:
                    cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))


                item = control.item(label=label)

                item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner})

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.addContextMenuItems(cm)
                item.setInfo(type='Video', infoLabels = meta)

                control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()

            icon = control.addonNext()
            url = '%s?action=tvshowPage&url=%s' % (sysaddon, urllib.quote_plus(url))

            item = control.item(label=nextMenu)

            item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'tvshow.poster': icon, 'season.poster': icon, 'banner': icon, 'tvshow.banner': icon, 'season.banner': icon})
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)

            control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
        except:
            pass

        control.content(syshandle, 'tvshows')
        #control.do_block_check(False)
        control.directory(syshandle, cacheToDisc=True)
        views.setView('tvshows', {'skin.confluence': 500})
Example #42
0
    def movieDirectory(self, items):
        if items == None or len(items) == 0: control.idle() ; sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')

        traktCredentials = trakt.getTraktCredentialsInfo()

        try: isOld = False ; control.item().getArt('type')
        except: isOld = True

        isEstuary = True if 'estuary' in control.skin else False

        isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false'

        indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators()

        playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8')

        watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8')

        unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8')

        queueMenu = control.lang(32065).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')

        nextMenu = control.lang(32053).encode('utf-8')


        for i in items:
            try:
                label = '%s (%s)' % (i['title'], i['year'])
                imdb, title, year = i['imdb'], i['originaltitle'], i['year']
                sysname = urllib.quote_plus('%s (%s)' % (title, year))
                systitle = urllib.quote_plus(title)


                poster, banner, fanart = i['poster'], i['banner'], i['fanart']
                if banner == '0' and not fanart == '0': banner = fanart
                elif banner == '0' and not poster == '0': banner = poster
                if poster == '0': poster = addonPoster
                if banner == '0': banner = addonBanner


                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'mediatype': 'movie'})
                #meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})
                meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb})
                if i['duration'] == '0': meta.update({'duration': '120'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass
                if isEstuary == True:
                    try: del meta['cast']
                    except: pass

                sysmeta = urllib.quote_plus(json.dumps(meta))


                url = '%s?action=play&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, sysmeta, self.systime)
                sysurl = urllib.quote_plus(url)

                path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb)


                cm = []

                cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                try:
                    overlay = int(playcount.getMovieOverlay(indicators, imdb))
                    if overlay == 7:
                        cm.append((unwatchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb)))
                        meta.update({'playcount': 1, 'overlay': 7})
                    else:
                        cm.append((watchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb)))
                        meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass

                if traktCredentials == True:
                    cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb)))

                cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta)))

                if isOld == True:
                    cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))


                item = control.item(label=label)

                item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner})

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.addContextMenuItems(cm)
                item.setProperty('IsPlayable', isPlayable)
                item.setInfo(type='Video', infoLabels = meta)

                control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()

            icon = control.addonNext()
            url = '%s?action=moviePage&url=%s' % (sysaddon, urllib.quote_plus(url))

            item = control.item(label=nextMenu)

            item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon})
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)

            control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
        except:
            pass


        control.content(syshandle, 'movies')
        #control.do_block_check(False)
        control.directory(syshandle, cacheToDisc=True)
        views.setView('movies', {'skin.confluence': 500})
Example #43
0
    def tvshowDirectory(self, items):
        if items == None or len(items) == 0: return

        isFolder = True if control.setting('autoplay') == 'false' and control.setting('hosts.mode') == '1' else False
        isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder

        traktCredentials = trakt.getTraktCredentialsInfo()

        indicators = playcount.getTVShowIndicators()

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')
        sysaddon = sys.argv[0]

        for i in items:
            try:
                label = i['title']
                systitle = sysname = urllib.quote_plus(i['originaltitle'])
                sysimage = urllib.quote_plus(i['poster'])
                imdb, tvdb, year = i['imdb'], i['tvdb'], i['year']


                poster, banner, fanart = i['poster'], i['banner'], i['fanart']
                if banner == '0' and not poster == '0': banner = poster
                if poster == '0': poster = addonPoster
                if banner == '0': banner = addonBanner


                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})
                if i['duration'] == '0': meta.update({'duration': '60'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass
                sysmeta = urllib.quote_plus(json.dumps(meta))


                url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb)


                try:
                    overlay = int(playcount.getTVShowOverlay(indicators, tvdb))
                    if overlay == 7: meta.update({'playcount': 1, 'overlay': 7})
                    else: meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass


                cm = []

                if isFolder == False:
                    cm.append((control.lang(30232).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon))

                if traktCredentials == True:
                    cm.append((control.lang(30236).encode('utf-8'), 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb)))

                cm.append((control.lang(30242).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname)))
                cm.append((control.lang(30233).encode('utf-8'), 'Action(Info)'))
                cm.append((control.lang(30234).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb)))
                cm.append((control.lang(30235).encode('utf-8'), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, imdb, tvdb)))
                cm.append((control.lang(30240).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon))


                item = control.item(label=label, iconImage=poster, thumbnailImage=poster)

                try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner})
                except: pass

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels = meta)
                item.setProperty('Video', 'true')
                item.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()
            url = '%s?action=tvshows&url=%s' % (sysaddon, urllib.quote_plus(url))
            addonNext = control.addonNext()
            item = control.item(label=control.lang(30241).encode('utf-8'), iconImage=addonNext, thumbnailImage=addonNext)
            item.addContextMenuItems([], replaceItems=False)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
        except:
            pass


        control.content(int(sys.argv[1]), 'tvshows')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
        views.setView('tvshows', {'skin.estuary': 54, 'skin.confluence': 500})
Example #44
0
	def seasonDirectory(self, items):
		if items == None or len(items) == 0: control.idle() ; sys.exit()

		sysaddon = sys.argv[0]

		syshandle = int(sys.argv[1])

		addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

		addonFanart, settingFanart = control.addonFanart(), tools.Settings.getBoolean('interface.fanart')

		traktCredentials = trakt.getTraktCredentialsInfo()

		try: isOld = False ; control.item().getArt('type')
		except: isOld = True

		try: indicators = playcount.getSeasonIndicators(items[0]['imdb'])
		except: pass

		traktHas = trakt.getTraktIndicatorsInfo() == True
		watchedMenu = control.lang(32068).encode('utf-8') if traktHas else control.lang(32066).encode('utf-8')
		unwatchedMenu = control.lang(32069).encode('utf-8') if traktHas else control.lang(32067).encode('utf-8')

		unwatchedEnabled = tools.Settings.getBoolean('interface.tvshows.unwatched.enabled')
		unwatchedLimit = tools.Settings.getBoolean('interface.tvshows.unwatched.limit')

		queueMenu = control.lang(32065).encode('utf-8')

		traktManagerMenu = control.lang(32070).encode('utf-8')

		media = tools.Media()

		try: multi = [i['tvshowtitle'] for i in items]
		except: multi = []
		multi = len([x for y,x in enumerate(multi) if x not in multi[:y]])
		multi = True if multi > 1 else False

		for i in items:
			try:
				label = None
				try:
					label = media.title(tools.Media.TypeSeason, season = i['season'])
				except: pass
				if label == None:
					label = i['season']

				if multi == True and not label in i['tvshowtitle'] and not i['tvshowtitle'] in label:
					label = '%s - %s' % (i['tvshowtitle'], label)

				systitle = sysname = urllib.quote_plus(i['tvshowtitle'])

				imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i['season']

				meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
				meta.update({'mediatype': 'tvshow'})
				meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})

				# Bubbles
				# Remove default time, since this might mislead users. Rather show no time.
				#if not 'duration' in i: meta.update({'duration': '60'})
				#elif i['duration'] == '0': meta.update({'duration': '60'})

				try: meta.update({'duration': str(int(meta['duration']) * 60)})
				except: pass
				try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
				except: pass
				try: meta.update({'tvshowtitle': i['label']})
				except: pass
				try:
					# Year is the shows year, not the seasons year. Extract the correct year frpm the premier date.
					yearNew = i['premiered']
					yearNew = re.findall('(\d{4})', yearNew)[0]
					yearNew = yearNew.encode('utf-8')
					meta.update({'year': yearNew})
				except:
					pass

				try:
					if season in indicators:
						meta.update({'playcount': 1, 'overlay': 7})
						overlay = 7
					else:
						meta.update({'playcount': 0, 'overlay': 6})
						overlay = 6
				except:
					overlay = None


				url = self.parameterize('%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tvdb, season))


				cm = []

				cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

				if not traktHas:
					link = self.parameterize('%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7' % (sysaddon, systitle, imdb, tvdb, season))
					cm.append((watchedMenu, 'RunPlugin(%s)' % link))

					link = self.parameterize('%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6' % (sysaddon, systitle, imdb, tvdb, season))
					cm.append((unwatchedMenu, 'RunPlugin(%s)' % link))

				if traktCredentials == True:
					link = self.parameterize('%s?action=traktManager&tvdb=%s&season=%s' % (sysaddon, tvdb, season))
					cm.append((traktManagerMenu, 'RunPlugin(%s)' % link))

				if not self.kidsOnly() and control.setting('downloads.manual.enabled') == 'true':
					cm.append((control.lang(33585).encode('utf-8'), 'RunPlugin(%s?action=downloadsManager)' % (sysaddon)))

				if isOld == True:
					cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))


				item = control.item(label=label)

				if unwatchedEnabled and not overlay == None and not overlay == 7:
					try:
						count = playcount.getSeasonCount(imdb, season, unwatchedLimit)
						if count:
							item.setProperty('TotalEpisodes', str(count['total']))
							item.setProperty('WatchedEpisodes', str(count['watched']))
							item.setProperty('UnWatchedEpisodes', str(count['unwatched']))
					except:
						pass

				art = {}

				# First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
				poster = '0'
				if poster == '0' and 'poster3' in i: poster = i['thumb3']
				if poster == '0' and 'poster2' in i: poster = i['thumb2']
				if poster == '0' and 'poster' in i: poster = i['thumb']
				if poster == '0' and 'poster3' in i: poster = i['poster3']
				if poster == '0' and 'poster2' in i: poster = i['poster2']
				if poster == '0' and 'poster' in i: poster = i['poster']

				icon = '0'
				if icon == '0' and 'icon3' in i: icon = i['icon3']
				if icon == '0' and 'icon2' in i: icon = i['icon2']
				if icon == '0' and 'icon' in i: icon = i['icon']

				thumb = '0'
				if thumb == '0' and 'thumb3' in i: thumb = i['thumb3']
				if thumb == '0' and 'thumb2' in i: thumb = i['thumb2']
				if thumb == '0' and 'thumb' in i: thumb = i['thumb']

				banner = '0'
				if banner == '0' and 'banner3' in i: banner = i['banner3']
				if banner == '0' and 'banner2' in i: banner = i['banner2']
				if banner == '0' and 'banner' in i: banner = i['banner']

				fanart = '0'
				if settingFanart:
					if fanart == '0' and 'fanart3' in i: fanart = i['fanart3']
					if fanart == '0' and 'fanart2' in i: fanart = i['fanart2']
					if fanart == '0' and 'fanart' in i: fanart = i['fanart']

				clearlogo = '0'
				if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo']

				clearart = '0'
				if clearart == '0' and 'clearart' in i: clearart = i['clearart']

				if poster == '0': poster = addonPoster
				if icon == '0': icon = poster
				if thumb == '0': thumb = poster
				if banner == '0': banner = addonBanner
				if fanart == '0': fanart = addonFanart

				if not poster == '0' and not poster == None: art.update({'poster' : poster, 'tvshow.poster' : poster, 'season.poster' : poster})
				if not icon == '0' and not icon == None: art.update({'icon' : icon})
				if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb})
				if not banner == '0' and not banner == None: art.update({'banner' : banner})
				if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo})
				if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart})
				if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart)

				item.setArt(art)
				item.addContextMenuItems(cm)
				item.setInfo(type='Video', infoLabels = meta)

				control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
			except:
				pass

		try: control.property(syshandle, 'showplot', items[0]['plot'])
		except: pass

		control.content(syshandle, 'seasons')
		control.directory(syshandle, cacheToDisc=True)
		views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
Example #45
0
    def tvshowDirectory(self, items):
        if items == None or len(items) == 0: control.idle() ; sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')

        traktCredentials = trakt.getTraktCredentialsInfo()

        try: isOld = False ; control.item().getArt('type')
        except: isOld = True

        indicators = playcount.getTVShowIndicators(refresh=True) if action == 'tvshows' else playcount.getTVShowIndicators()

        flatten = True if control.setting('flatten.tvshows') == 'true' else False

        watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8')

        unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8')

        queueMenu = control.lang(32065).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')

        nextMenu = control.lang(32053).encode('utf-8')

        playRandom = control.lang(32535).encode('utf-8')


        for i in items:
            try:
                label = i['title']
                systitle = sysname = urllib.quote_plus(i['originaltitle'])
                sysimage = urllib.quote_plus(i['poster'])
                imdb, tvdb, year = i['imdb'], i['tvdb'], i['year']

                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb})
                meta.update({'tvdb_id': tvdb})
                meta.update({'mediatype': 'tvshow'})
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})
                if not 'duration' in i: meta.update({'duration': '60'})
                elif i['duration'] == '0': meta.update({'duration': '60'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass

                try:
                    overlay = int(playcount.getTVShowOverlay(indicators, tvdb))
                    if overlay == 7: meta.update({'playcount': 1, 'overlay': 7})
                    else: meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass


                if flatten == True:
                    url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb)
                else:
                    url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb)


                cm = []

                cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=season&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, urllib.quote_plus(systitle), urllib.quote_plus(year), urllib.quote_plus(imdb), urllib.quote_plus(tvdb))))

                cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                #cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb)))

                #cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, imdb, tvdb)))

                if traktCredentials == True:
                    cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb)))

                if isOld == True:
                    cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))


                item = control.item(label=label)

                art = {}

                if 'poster' in i and not i['poster'] == '0':
                    art.update({'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster']})
                #elif 'poster2' in i and not i['poster2'] == '0':
                    #art.update({'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2']})
                else:
                    art.update({'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster})

                if 'banner' in i and not i['banner'] == '0':
                    art.update({'banner': i['banner']})
                #elif 'banner2' in i and not i['banner2'] == '0':
                    #art.update({'banner': i['banner2']})
                elif 'fanart' in i and not i['fanart'] == '0':
                    art.update({'banner': i['fanart']})
                else:
                    art.update({'banner': addonBanner})

                if 'clearlogo' in i and not i['clearlogo'] == '0':
                    art.update({'clearlogo': i['clearlogo']})

                if 'clearart' in i and not i['clearart'] == '0':
                    art.update({'clearart': i['clearart']})

                if settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0':
                    item.setProperty('Fanart_Image', i['fanart'])
                #elif settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0':
                    #item.setProperty('Fanart_Image', i['fanart2'])
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setArt(art)
                item.addContextMenuItems(cm)
                item.setInfo(type='Video', infoLabels = meta)

                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)

                control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()

            icon = control.addonNext()
            url = '%s?action=tvshowPage&url=%s' % (sysaddon, urllib.quote_plus(url))

            item = control.item(label=nextMenu)

            item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon})
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)

            control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
        except:
            pass

        control.content(syshandle, 'tvshows')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('tvshows', {'skin.estuary': 55, 'skin.confluence': 500})
Example #46
0
    def movieDirectory(self, items):
        if items == None or len(items) == 0: control.idle() ; sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')

        traktCredentials = trakt.getTraktCredentialsInfo()

        try: isOld = False ; control.item().getArt('type')
        except: isOld = True

        isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false'

        indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators()

        playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8')

        watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8')

        unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8')

        queueMenu = control.lang(32065).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')

        nextMenu = control.lang(32053).encode('utf-8')

        addToLibrary = control.lang(32551).encode('utf-8')

        for i in items:
            try:
                label = '%s (%s)' % (i['title'], i['year'])
                imdb, tmdb, title, year = i['imdb'], i['tmdb'], i['originaltitle'], i['year']
                sysname = urllib.quote_plus('%s (%s)' % (title, year))
                systitle = urllib.quote_plus(title)

                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb})
                meta.update({'tmdb_id': tmdb})
                meta.update({'mediatype': 'movie'})
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(label))})
                #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb})
                if not 'duration' in i: meta.update({'duration': '120'})
                elif i['duration'] == '0': meta.update({'duration': '120'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass

                poster = [i[x] for x in ['poster3', 'poster', 'poster2'] if i.get(x, '0') != '0']
                poster = poster[0] if poster else addonPoster
                meta.update({'poster': poster})

                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=play&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, sysmeta, self.systime)
                sysurl = urllib.quote_plus(url)

                path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb)


                cm = []

                cm.append(('Find similar',
                           'ActivateWindow(10025,%s?action=movies&url=https://api.trakt.tv/movies/%s/related,return)' % (
                           sysaddon, imdb)))

                cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                try:
                    overlay = int(playcount.getMovieOverlay(indicators, imdb))
                    if overlay == 7:
                        cm.append((unwatchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb)))
                        meta.update({'playcount': 1, 'overlay': 7})
                    else:
                        cm.append((watchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb)))
                        meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass

                if traktCredentials == True:
                    cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb)))

                cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta)))

                if isOld == True:
                    cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))

                cm.append((addToLibrary, 'RunPlugin(%s?action=movieToLibrary&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s)' % (sysaddon, sysname, systitle, year, imdb, tmdb)))

                item = control.item(label=label)

                art = {}
                art.update({'icon': poster, 'thumb': poster, 'poster': poster})

                if 'banner' in i and not i['banner'] == '0':
                    art.update({'banner': i['banner']})
                else:
                    art.update({'banner': addonBanner})

                if 'clearlogo' in i and not i['clearlogo'] == '0':
                    art.update({'clearlogo': i['clearlogo']})

                if 'clearart' in i and not i['clearart'] == '0':
                    art.update({'clearart': i['clearart']})


                if settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0':
                    item.setProperty('Fanart_Image', i['fanart2'])
                elif settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0':
                    item.setProperty('Fanart_Image', i['fanart'])
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setArt(art)
                item.addContextMenuItems(cm)
                item.setProperty('IsPlayable', isPlayable)
                item.setInfo(type='Video', infoLabels = meta)

                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)

                control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()

            icon = control.addonNext()
            url = '%s?action=moviePage&url=%s' % (sysaddon, urllib.quote_plus(url))

            item = control.item(label=nextMenu)

            item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon})
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)

            control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
        except:
            pass

        control.content(syshandle, 'movies')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('movies', {'skin.estuary': 55, 'skin.confluence': 500})