예제 #1
0
def tvshowsUpdate(imdb, tvdb):
	try:
		if traktIndicators: return
		check_metahandler()
		from resources.lib.menus import episodes

		name = addonInfo('name')
		metaget = metahandlers.MetaData(tmdb_api_key, omdb_api_key, tvdb_api_key)
		metaget.get_meta('tvshow', name='', imdb_id=imdb)

		items = episodes.Episodes().get('', '0', imdb, '0', tvdb, create_directory=False)
		for i in range(len(items)):
			items[i]['season'] = int(items[i]['season'])
			items[i]['episode'] = int(items[i]['episode'])

		seasons = {}
		for i in items:
			if i['season'] not in seasons: seasons[i['season']] = []
			seasons[i['season']].append(i)

		countSeason = 0
		metaget.get_seasons('', imdb, seasons.keys()) # Must be called to initialize the database.

		for key, value in iter(seasons.items()):
			countEpisode = 0
			for i in value:
				countEpisode += int(metaget._get_watched_episode({'imdb_id': i['imdb'], 'season': i['season'], 'episode': i['episode'], 'premiered': ''}) == 5)
			countSeason += int(countEpisode == len(value))
			metaget.change_watched('season', '', imdb_id=imdb, season=key, watched = 5 if countEpisode == len(value) else 4)
		metaget.change_watched('tvshow', '', imdb_id=imdb, watched = 5 if countSeason == len(seasons.keys()) else 4)
	except:
		from resources.lib.modules import log_utils
		log_utils.error()
	containerRefresh()
예제 #2
0
def movies(name, imdb, watched):
	try:
		if traktIndicators:
			if int(watched) == 5: trakt.watch(name=name, imdb=imdb, refresh=True)
			else: trakt.unwatch(name=name, imdb=imdb, refresh=True)
		else:
			from metahandler import metahandlers
			metaget = metahandlers.MetaData(tmdb_api_key, omdb_api_key, tvdb_api_key)
			metaget.get_meta('movie', name=name, imdb_id=imdb)
			metaget.change_watched('movie', name=name, imdb_id=imdb, watched=int(watched))
			containerRefresh()
	except:
		from resources.lib.modules import log_utils
		log_utils.error()
예제 #3
0
def tvshowsUpdate(imdb, tvdb):
    try:
        if traktIndicators: return
        from metahandler import metahandlers
        from resources.lib.menus import seasons, episodes
        from resources.lib.indexers import tmdb as tmdb_indexer
        from resources.lib.database import cache
        from resources.lib.modules import log_utils

        # name = addonInfo('name')
        metaget = metahandlers.MetaData(tmdb_api_key, omdb_api_key,
                                        tvdb_api_key)
        show_meta = metaget.get_meta('tvshow', name='', imdb_id=imdb)
        log_utils.log('show_meta=%s' % show_meta)

        tvshowtitle = show_meta.get(
            'title', '')  # useless because it's in cleantitle format
        log_utils.log('tvshowtitle=%s' % tvshowtitle)

        # seasons_meta = seasons.Seasons().get('', '', imdb, '', tvdb, {}, create_directory=False)
        # items = seasons.Seasons().get('', '', imdb, '', tvdb, {}, create_directory=False)
        # def get(self, tvshowtitle, year, imdb, tmdb, tvdb, art, idx=True, create_directory=True):

        tmdb = ''
        if not tmdb and (imdb or tvdb):
            try:
                result = cache.get(tmdb_indexer.TVshows().IdLookup, 96, imdb,
                                   tvdb)
                tmdb = str(result.get('id')) if result else ''
            except:
                if control.setting('debug.level') != '1': return
                from resources.lib.modules import log_utils
                return log_utils.log(
                    'tvshowtitle: (%s) missing tmdb_id: ids={imdb: %s, tmdb: %s, tvdb: %s}'
                    % (tvshowtitle, imdb, tmdb, tvdb), __name__,
                    log_utils.LOGDEBUG)  # log TMDb shows that they do not have
        items = cache.get(tmdb_indexer.TVshows().get_showSeasons_meta, 96,
                          tmdb)
        log_utils.log('items=%s' % items)
        items = items.get('seasons', [])
        # for i in items:

        # items = episodes.Episodes().get('', '', imdb, '', tvdb, {}, create_directory=False)
        # def get(self, tvshowtitle, year, imdb, tmdb, tvdb, meta, season=None, episode=None, create_directory=True):
        # log_utils.log('items=%s' % items)

        for i in range(len(items)):
            log_utils.log('items[i]=%s' % items[i])

            items[i]['season'] = int(items[i]['season'])
            items[i]['episode'] = int(items[i]['episode'])

        seasons = {}
        for i in items:
            if i['season'] not in seasons: seasons[i['season']] = []
            seasons[i['season']].append(i)

        countSeason = 0
        metaget.get_seasons(
            '', imdb,
            seasons.keys())  # Must be called to initialize the database.

        for key, value in iter(seasons.items()):
            countEpisode = 0
            for i in value:
                countEpisode += int(
                    metaget._get_watched_episode({
                        'imdb_id': i['imdb'],
                        'season': i['season'],
                        'episode': i['episode'],
                        'premiered': ''
                    }) == 5)
            countSeason += int(countEpisode == len(value))
            metaget.change_watched(
                'season',
                '',
                imdb_id=imdb,
                season=key,
                watched=5 if countEpisode == len(value) else 4)
        metaget.change_watched(
            'tvshow',
            '',
            imdb_id=imdb,
            watched=5 if countSeason == len(seasons.keys()) else 4)
    except:
        from resources.lib.modules import log_utils
        log_utils.error()
    containerRefresh()