Ejemplo n.º 1
0
def update_history():
    # result = tvshow_manager.to_watch()
    # print result
    trakt_manager = Trakt()
    tvshow_manager = TVShowTime()

    print 'Fetching Trakt.tv watched history...'
    history = trakt_manager.get_history()

    checkin_list = []
    list_shows = {}
    for ep in history:

        show = {
            "show_id": ep['show']['ids']['tvdb'],
            "season": ep['episode']['season'],
            "episode": ep['episode']['number']
        }

        # filter by greater ep and season
        filter_list = filter(
            lambda x: x['season'] >= show['season'] and x['show_id'] == show[
                'show_id'] and x['episode'] > show['episode'], checkin_list)
        if len(filter_list) == 0:
            checkin_list.append(show)

    print 'Saving progress on TVShowTime'
    print tvshow_manager.save_progress(checkin_list)