def tvshows(tvshowtitle, imdb, tvdb, season, watched):
    control.busy()
    try:
        import sys,xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()

        from metahandler import metahandlers
        from resources.lib.indexers import episodes

        metaget = metahandlers.MetaData(preparezip=False)

        name = control.addonInfo('name')

        dialog = control.progressDialogBG
        dialog.create(str(name), str(tvshowtitle))
        dialog.update(0, str(name), str(tvshowtitle))

        metaget.get_meta('tvshow', name='', imdb_id=imdb)

        items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False)
        try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))]
        except: pass
        items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items]

        for i in range(len(items)):
            if xbmc.abortRequested == True: return sys.exit()

            dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label']))

            season, episode = items[i]['season'], items[i]['episode']
            metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
            metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))

        try: dialog.close()
        except: pass
    except:
        try: dialog.close()
        except: pass


    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()

        if season:
            from resources.lib.indexers import episodes
            items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, season, idx=False)
            items = [(int(i['season']), int(i['episode'])) for i in items]
            items = [i[1] for i in items if int('%01d' % int(season)) == int('%01d' % i[0])]
            for i in items:
                if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, i)
                else: trakt.markEpisodeAsNotWatched(tvdb, season, i)
        else:
            if int(watched) == 7: trakt.markTVShowAsWatched(tvdb)
            else: trakt.markTVShowAsNotWatched(tvdb)
        trakt.cachesyncTVShows()
    except:
        pass

    control.refresh()
Beispiel #2
0
def markEpisodeDuringPlayback(imdb, tvdb, season, episode, watched):
    try:
        if traktIndicators:
            if int(watched) == 5:
                trakt.markEpisodeAsWatched(imdb, tvdb, season, episode)
            else:
                trakt.markEpisodeAsNotWatched(imdb, tvdb, season, episode)
            trakt.cachesyncTVShows()
            # if trakt.getTraktAddonEpisodeInfo():
            # trakt.markEpisodeAsNotWatched(imdb, tvdb, season, episode)
        else:
            from metahandler import metahandlers
            metaget = metahandlers.MetaData(tmdb_api_key, omdb_api_key,
                                            tvdb_api_key)
            metaget.get_meta('tvshow', name='', imdb_id=imdb)
            metaget.get_episode_meta('',
                                     imdb_id=imdb,
                                     season=season,
                                     episode=episode)
            metaget.change_watched('episode',
                                   '',
                                   imdb_id=imdb,
                                   season=season,
                                   episode=episode,
                                   watched=int(watched))
    except:
        from resources.lib.modules import log_utils
        log_utils.error()
Beispiel #3
0
def markEpisodeDuringPlayback(imdb, tvdb, season, episode, watched):
    try:
        if trakt.getTraktIndicatorsInfo() is False:
            raise Exception()

        if int(watched) == 7:
            trakt.markEpisodeAsWatched(tvdb, season, episode)
        else:
            trakt.markEpisodeAsNotWatched(tvdb, season, episode)
        trakt.cachesyncTVShows()

        if trakt.getTraktAddonEpisodeInfo() is True:
            trakt.markEpisodeAsNotWatched(tvdb, season, episode)
    except Exception:
        pass

    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        metaget.get_meta('tvshow', name='', imdb_id=imdb)
        metaget.get_episode_meta('',
                                 imdb_id=imdb,
                                 season=season,
                                 episode=episode)
        metaget.change_watched('episode',
                               '',
                               imdb_id=imdb,
                               season=season,
                               episode=episode,
                               watched=int(watched))
    except Exception:
        pass
Beispiel #4
0
def episodes(imdb, tvdb, season, episode, watched):
    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()
        if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, episode)
        else: trakt.markEpisodeAsNotWatched(tvdb, season, episode)
        trakt.cachesyncTVShows()
        control.refresh()
    except:
        pass

    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        metaget.get_meta('tvshow', name='', imdb_id=imdb)
        metaget.get_episode_meta('',
                                 imdb_id=imdb,
                                 season=season,
                                 episode=episode)
        metaget.change_watched('episode',
                               '',
                               imdb_id=imdb,
                               season=season,
                               episode=episode,
                               watched=int(watched))
        if trakt.getTraktIndicatorsInfo() == False: control.refresh()
    except:
        pass
def markEpisodeDuringPlayback(imdb, tvdb, season, episode, watched):
	try:
		if traktIndicators is False:
			raise Exception()

		if int(watched) == 7:
			trakt.markEpisodeAsWatched(imdb, tvdb, season, episode)
		else:
			trakt.markEpisodeAsNotWatched(imdb, tvdb, season, episode)

		trakt.cachesyncTVShows()

		# if trakt.getTraktAddonEpisodeInfo() is True:
			# log_utils.log('trakt.getTraktAddonEpisodeInfo = True', __name__, log_utils.LOGDEBUG)
			# trakt.markEpisodeAsNotWatched(imdb, tvdb, season, episode)
	except:
		pass

	try:
		from metahandler import metahandlers
		metaget = metahandlers.MetaData()
		metaget.get_meta('tvshow', name='', imdb_id=imdb)
		metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
		metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))
	except:
		pass
Beispiel #6
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;
Beispiel #7
0
def markEpisodeDuringPlayback(imdb, tvdb, season, episode, watched):
    try:
        if trakt.getTraktIndicatorsInfo() == False:
            raise Exception()

        setting = None

        if int(watched) == 7:
            # Only mark as watched if the previous watch is more than a week ago.
            # Trakt allows to mark an item with multiple watches, eg: watching a movie multiple times.
            # However, if the playback is stopped at almost the end of the stream and then finished a few days later, it will be marked watched multiple times.
            # Ignore these marks for items watched more than a week ago.

            allow = True
            setting = tools.Settings.getInteger(
                'accounts.informants.trakt.watched')

            if setting == 0:
                try:
                    watchedTime = trakt.watchedShowsTime(tvdb, season, episode)
                    watchedTime = convert.ConverterTime(
                        value=watchedTime,
                        format=convert.ConverterTime.FormatDateTimeJson
                    ).timestamp()
                    currentTime = tools.Time.timestamp()
                    differenceTime = currentTime - watchedTime
                    allow = differenceTime > 604800
                except:
                    pass
            elif setting == 1:
                trakt.markEpisodeAsNotWatched(imdb, tvdb, season, episode)

            if allow: trakt.markEpisodeAsWatched(imdb, tvdb, season, episode)
        else:
            trakt.markEpisodeAsNotWatched(imdb, tvdb, season, episode)

        trakt.cachesyncTVShows()

        if (setting == None
                or setting == 1) and trakt.getTraktAddonEpisodeInfo() == True:
            trakt.markEpisodeAsNotWatched(imdb, tvdb, season, episode)
    except:
        pass

    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        metaget.get_meta('tvshow', name='', imdb_id=imdb)
        metaget.get_episode_meta('',
                                 imdb_id=imdb,
                                 season=season,
                                 episode=episode)
        metaget.change_watched('episode',
                               '',
                               imdb_id=imdb,
                               season=season,
                               episode=episode,
                               watched=int(watched))
    except:
        pass
def markEpisodeDuringPlayback(imdb, tvdb, season, episode, watched):
    try:
        if trakt.getTraktIndicatorsInfo() == False:
            raise Exception()

        if int(watched) == 7:
            trakt.markEpisodeAsWatched(tvdb, season, episode)
        else:
            trakt.markEpisodeAsNotWatched(tvdb, season, episode)
        trakt.cachesyncTVShows()

        if trakt.getTraktAddonEpisodeInfo() == True:
            trakt.markEpisodeAsNotWatched(tvdb, season, episode)
    except:
        pass

    try:
        from metahandler import metahandlers

        metaget = metahandlers.MetaData(preparezip=False)
        metaget.get_meta("tvshow", name="", imdb_id=imdb)
        metaget.get_episode_meta("", imdb_id=imdb, season=season, episode=episode)
        metaget.change_watched("episode", "", imdb_id=imdb, season=season, episode=episode, watched=int(watched))
    except:
        pass
def markEpisodeDuringPlayback(imdb, tmdb, season, episode, watched):
    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()

        if int(watched) == 7: trakt.markEpisodeAsWatched(imdb, season, episode)
        else: trakt.markEpisodeAsNotWatched(imdb, season, episode)
        trakt.cachesyncTVShows()

        if trakt.getTraktAddonEpisodeInfo() == True:
            trakt.markEpisodeAsNotWatched(imdb, season, episode)
    except:
        pass

    try:
        if int(watched) == 7:
            bookmarks.reset(1, 1, 'episode', imdb, season, episode)
    except:
        pass
def episodes(imdb, tvdb, season, episode, watched):
    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()
        if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, episode)
        else: trakt.markEpisodeAsNotWatched(tvdb, season, episode)
        trakt.cachesyncTVShows()
        control.refresh()
    except:
        pass

    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        metaget.get_meta('tvshow', name='', imdb_id=imdb)
        metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
        metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))
        if trakt.getTraktIndicatorsInfo() == False: control.refresh()
    except:
        pass
Beispiel #11
0
def markEpisodeDuringPlayback(imdb, tvdb, season, episode, watched):
    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()

        if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, episode)
        else: trakt.markEpisodeAsNotWatched(tvdb, season, episode)
        trakt.cachesyncTVShows()

        if trakt.getTraktAddonEpisodeInfo() == True:
            trakt.markEpisodeAsNotWatched(tvdb, season, episode)
    except:
        pass

    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False, tmdb_api_key='f3248106719173ab34be38966164050d')
        metaget.get_meta('tvshow', name='', imdb_id=imdb)
        metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
        metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))
    except:
        pass
def episodes(imdb, tmdb, season, episode, watched):
    #    control.busy()
    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()
        if int(watched) == 7: trakt.markEpisodeAsWatched(imdb, season, episode)
        else: trakt.markEpisodeAsNotWatched(imdb, season, episode)
        trakt.cachesyncTVShows()
        control.refresh()
#        control.idle()
    except:
        pass

    try:
        if int(watched) == 7:
            bookmarks.reset(1, 1, 'episode', imdb, season, episode)
        else:
            bookmarks._delete_record('episode', imdb, season, episode)
        if trakt.getTraktIndicatorsInfo() == False: control.refresh()


#        control.idle()
    except:
        pass
def tvshows(tvshowtitle, imdb, tmdb, season, watched):
    control.busy()
    try:
        import sys, xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()

        from resources.lib.indexers import episodes

        name = control.addonInfo('name')

        dialog = control.progressDialogBG
        dialog.create(str(name), str(tvshowtitle))
        dialog.update(0, str(name), str(tvshowtitle))

        #log_utils.log('playcount_season: ' + str(season))
        items = []
        if season:
            items = episodes.episodes().get(tvshowtitle,
                                            '0',
                                            imdb,
                                            tmdb,
                                            meta=None,
                                            season=season,
                                            idx=False)
            items = [
                i for i in items
                if int('%01d' % int(season)) == int('%01d' % int(i['season']))
            ]
            items = [{
                'label':
                '%s S%02dE%02d' %
                (tvshowtitle, int(i['season']), int(i['episode'])),
                'season':
                int('%01d' % int(i['season'])),
                'episode':
                int('%01d' % int(i['episode'])),
                'unaired':
                i['unaired']
            } for i in items]

            for i in range(len(items)):
                if control.monitor.abortRequested(): return sys.exit()

                dialog.update(int((100 / float(len(items))) * i), str(name),
                              str(items[i]['label']))

                _season, _episode, unaired = items[i]['season'], items[i][
                    'episode'], items[i]['unaired']
                if int(watched) == 7:
                    if not unaired == 'true':
                        bookmarks.reset(1, 1, 'episode', imdb, _season,
                                        _episode)
                    else:
                        pass
                else:
                    bookmarks._delete_record('episode', imdb, _season,
                                             _episode)

        else:
            seasons = episodes.seasons().get(tvshowtitle,
                                             '0',
                                             imdb,
                                             tmdb,
                                             meta=None,
                                             idx=False)
            seasons = [i['season'] for i in seasons]
            #log_utils.log('playcount_seasons: ' + str(seasons))
            for s in seasons:
                items = episodes.episodes().get(tvshowtitle,
                                                '0',
                                                imdb,
                                                tmdb,
                                                meta=None,
                                                season=s,
                                                idx=False)
                items = [{
                    'label':
                    '%s S%02dE%02d' %
                    (tvshowtitle, int(i['season']), int(i['episode'])),
                    'season':
                    int('%01d' % int(i['season'])),
                    'episode':
                    int('%01d' % int(i['episode'])),
                    'unaired':
                    i['unaired']
                } for i in items]
                #log_utils.log('playcount_items2: ' + str(items))

                for i in range(len(items)):
                    if control.monitor.abortRequested(): return sys.exit()

                    dialog.update(int((100 / float(len(items))) * i),
                                  str(name), str(items[i]['label']))

                    _season, _episode, unaired = items[i]['season'], items[i][
                        'episode'], items[i]['unaired']
                    if int(watched) == 7:
                        if not unaired == 'true':
                            bookmarks.reset(1, 1, 'episode', imdb, _season,
                                            _episode)
                        else:
                            pass
                    else:
                        bookmarks._delete_record('episode', imdb, _season,
                                                 _episode)

        try:
            dialog.close()
        except:
            pass
    except:
        log_utils.log('playcount_local_shows', 1)
        try:
            dialog.close()
        except:
            pass

    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()

        #log_utils.log('playcount_season: ' + str(season))
        if season:
            from resources.lib.indexers import episodes
            items = episodes.episodes().get(tvshowtitle,
                                            '0',
                                            imdb,
                                            tmdb,
                                            meta=None,
                                            season=season,
                                            idx=False)
            items = [(int(i['season']), int(i['episode'])) for i in items]
            items = [
                i[1] for i in items
                if int('%01d' % int(season)) == int('%01d' % i[0])
            ]
            for i in items:
                if int(watched) == 7:
                    trakt.markEpisodeAsWatched(imdb, season, i)
                else:
                    trakt.markEpisodeAsNotWatched(imdb, season, i)
        else:
            if int(watched) == 7: trakt.markTVShowAsWatched(imdb)
            else: trakt.markTVShowAsNotWatched(imdb)
        trakt.cachesyncTVShows()
    except:
        log_utils.log('playcount_trakt_shows', 1)
        pass

    control.refresh()
    control.idle()