Пример #1
0
def scrobbleMovie(imdb, tmdb, watched_percent):
    try:
        if not imdb.startswith('tt'): imdb = 'tt' + imdb
        timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.000Z")
        items = [{
            'progress': watched_percent,
            'paused_at': timestamp,
            'type': 'movie',
            'movie': {
                'ids': {
                    'imdb': imdb,
                    'tmdb': tmdb
                }
            }
        }]
        traktsync.insert_bookmarks(items, new_scrobble=True)
        if control.setting('trakt.scrobble.notify') == 'true':
            control.notification(message=32088)
        return getTrakt('/scrobble/pause', {
            "movie": {
                "ids": {
                    "imdb": imdb
                }
            },
            "progress": watched_percent
        })
    except:
        log_utils.error()
Пример #2
0
def scrobbleEpisode(imdb, tmdb, tvdb, season, episode, watched_percent):
	try:
		season, episode = int('%01d' % int(season)), int('%01d' % int(episode))
		timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.000Z")
		items = [{'progress': watched_percent, 'paused_at': timestamp, 'type': 'episode', 'episode': {'season': season, 'number': episode}, 'show': {'ids': {'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb}}}]
		traktsync.insert_bookmarks(items, new_scrobble=True)
		if control.setting('trakt.scrobble.notify') == 'true':
			control.notification(message=32088)
		return getTrakt('/scrobble/pause', {"show": {"ids": {"tvdb": tvdb}}, "episode": {"season": season, "number": episode}, "progress": watched_percent})
	except:
		log_utils.error()
Пример #3
0
def sync_progress():
    try:
        while not control.monitor.abortRequested():
            db_last_paused = traktsync.last_paused_at()
            activity = getPausedActivity()
            if activity - db_last_paused >= 120:  # do not sync unless 2 min difference or more
                log_utils.log('Trakt Progress Sync Update...(local db latest "paused_at" = %s, trakt api latest "paused_at" = %s)' % \
                     (str(db_last_paused), str(activity)), __name__, log_utils.LOGDEBUG)
                link = '/sync/playback/'
                items = getTraktAsJson(link)
                if items: traktsync.insert_bookmarks(items)
            if control.monitor.waitForAbort(60 * 15):
                break
    except:
        log_utils.error()