Exemplo n.º 1
0
def update_playcounts():

    videos_data = {}
    videos_data.update(get_movies_data())
    videos_data.update(get_episodes_data())

    if len(videos_data) > 0:
        playback_infos = get.video_playback_info(videos_data)
        videos = json.loads(playback_infos)['value']['videos']
        update_metadatas = []
        playcount_changed = False
        for video_id in videos:
            type = video_parser.parse_type(videos[video_id])
            if type is not 'show':
                playcount = video_parser.parse_duration_playcount(videos[video_id])[1]
                video_data = videos_data[video_id]
                if 'episode_id' in video_data:
                    if video_data['playcount'] != playcount:
                        update_episode_playcount(video_data['episode_id'], playcount)
                        playcount_changed = True
                else:
                    if video_data['playcount'] != playcount:
                        update_movie_playcount(video_data['movie_id'], playcount)
                        playcount_changed = True

        if playcount_changed:
            xbmc.executebuiltin("Container.Refresh")
Exemplo n.º 2
0
def update_playcounts():
    tv_dir = xbmc.translatePath(generic_utility.tv_dir())
    movie_dir = xbmc.translatePath(generic_utility.movie_dir())

    video_ids = []
    video_ids.extend(get_video_ids(tv_dir))
    video_ids.extend(get_video_ids(movie_dir))

    playback_infos = get.video_playback_info(video_ids)
    videos = json.loads(playback_infos)['value']['videos']
    update_metadatas = []
    for video_id in videos:
        playcount = video_parser.parse_duration_playcount(videos[video_id])[1]
        update_metadatas.append({'video_id': video_id, 'playcount': playcount})
    database.update_playcounts(update_metadatas)
    xbmc.executebuiltin("Container.Refresh")