Esempio n. 1
0
def _create_video_item(videoid_value, video, video_list, perpetual_range_start, common_data):
    is_playable = video['availability']['isPlayable']
    videoid = common.VideoId.from_videolist_item(video)
    is_folder = videoid.mediatype == common.VideoId.SHOW
    is_in_mylist = videoid in common_data['mylist_items']
    dict_item = {'video_id': videoid_value,
                 'media_type': videoid.mediatype if is_playable else None,
                 'label': video['title'],
                 'is_folder': is_folder,
                 'properties': {'nf_videoid': videoid.to_string(),
                                'nf_is_in_mylist': str(is_in_mylist),
                                'nf_perpetual_range_start': perpetual_range_start}}
    add_info_dict_item(dict_item, videoid, video, video_list.data, is_in_mylist, common_data)
    set_watched_status(dict_item, video, common_data)
    if is_playable:
        dict_item['url'] = common.build_url(videoid=videoid,
                                            mode=G.MODE_DIRECTORY if is_folder else G.MODE_PLAY,
                                            params=None if is_folder else common_data['params'])
        dict_item['menu_items'] = generate_context_menu_items(videoid, is_in_mylist, perpetual_range_start,
                                                              common_data['ctxmenu_remove_watched_status'])
    else:
        # The video is not playable, try check if there is a date
        dict_item['properties']['nf_availability_message'] = get_availability_message(video)
        dict_item['url'] = common.build_url(['show_availability_message'], mode=G.MODE_ACTION)
    return dict_item
Esempio n. 2
0
def _create_videolist_item(list_id,
                           video_list,
                           menu_data,
                           common_data,
                           static_lists=False):
    if static_lists and G.is_known_menu_context(video_list['context']):
        pathitems = list(menu_data['path'])  # Make a copy
        pathitems.append(video_list['context'])
    else:
        # It is a dynamic video list / menu context
        if menu_data.get('force_use_videolist_id', False):
            path = 'video_list'
        else:
            path = 'video_list_sorted'
        pathitems = [path, menu_data['path'][1], list_id]
    dict_item = {'label': video_list['displayName'], 'is_folder': True}
    add_info_dict_item(dict_item,
                       video_list.videoid,
                       video_list,
                       video_list.data,
                       False,
                       common_data,
                       art_item=video_list.artitem)
    # Add possibility to browse the sub-genres (see build_video_listing)
    sub_genre_id = video_list.get('genreId')
    params = {'sub_genre_id': unicode(sub_genre_id)} if sub_genre_id else None
    dict_item['url'] = common.build_url(pathitems,
                                        params=params,
                                        mode=G.MODE_DIRECTORY)
    return dict_item
def _create_videolist_item(list_id,
                           video_list,
                           menu_data,
                           common_data,
                           static_lists=False):
    if static_lists and G.is_known_menu_context(video_list['context']):
        pathitems = list(menu_data['path'])  # Make a copy
        pathitems.append(video_list['context'])
    else:
        # It is a dynamic video list / menu context
        if menu_data.get('force_use_videolist_id', False):
            path = 'video_list'
        else:
            path = 'video_list_sorted'
        pathitems = [path, menu_data['path'][1], list_id]
    dict_item = {'label': video_list['displayName'], 'is_folder': True}
    add_info_dict_item(dict_item, video_list.videoid, video_list,
                       video_list.data, False, common_data)
    dict_item['art'] = get_art(video_list.videoid, video_list.artitem,
                               common_data['profile_language_code'])
    dict_item['url'] = common.build_url(
        pathitems,
        # genre_id add possibility to browse the sub-genres (see build_video_listing)
        # Todo: Disabled sub-genre menu due to website changes
        # params={'genre_id': unicode(video_list.get('genreId'))},
        mode=G.MODE_DIRECTORY)
    return dict_item
Esempio n. 4
0
def _create_episode_item(seasonid, episodeid_value, episode, episodes_list,
                         common_data):
    is_playable = episode['summary']['isPlayable']
    episodeid = seasonid.derive_episode(episodeid_value)
    dict_item = {
        'video_id': episodeid_value,
        'media_type': episodeid.mediatype if is_playable else None,
        'label': episode['title'],
        'is_folder': False,
        'properties': {
            'nf_videoid': episodeid.to_string()
        }
    }
    add_info_dict_item(dict_item, episodeid, episode, episodes_list.data,
                       False, common_data)
    set_watched_status(dict_item, episode, common_data)
    if is_playable:
        dict_item['url'] = common.build_url(videoid=episodeid,
                                            mode=G.MODE_PLAY,
                                            params=common_data['params'])
        dict_item['menu_items'] = generate_context_menu_items(
            episodeid, False, None)
    else:
        # The video is not playable, try check if there is a date
        dict_item['properties'][
            'nf_availability_message'] = get_availability_message(episode)
        dict_item['url'] = common.build_url(['show_availability_message'],
                                            mode=G.MODE_ACTION)
    return dict_item
def _create_video_item(videoid_value, video, video_list, perpetual_range_start,
                       common_data):
    videoid = common.VideoId.from_videolist_item(video)
    is_folder = videoid.mediatype == common.VideoId.SHOW
    is_in_mylist = videoid in common_data['mylist_items']
    dict_item = {
        'video_id': videoid_value,
        'media_type': videoid.mediatype,
        'label': video['title'],
        'is_folder': is_folder,
        'properties': {
            'nf_videoid': videoid.to_string(),
            'nf_is_in_mylist': str(is_in_mylist),
            'nf_perpetual_range_start': perpetual_range_start
        }
    }
    add_info_dict_item(dict_item, videoid, video, video_list.data,
                       is_in_mylist, common_data)
    set_watched_status(dict_item, video, common_data)
    dict_item['art'] = get_art(videoid, video,
                               common_data['profile_language_code'])
    dict_item['url'] = common.build_url(
        videoid=videoid,
        mode=G.MODE_DIRECTORY if is_folder else G.MODE_PLAY,
        params=None if is_folder else common_data['params'])
    dict_item['menu_items'] = generate_context_menu_items(
        videoid, is_in_mylist, perpetual_range_start,
        common_data['ctxmenu_remove_watched_status'])
    return dict_item
Esempio n. 6
0
def _create_episode_item(seasonid, episodeid_value, episode, episodes_list, common_data):
    episodeid = seasonid.derive_episode(episodeid_value)
    dict_item = {'video_id': episodeid_value,
                 'media_type': episodeid.mediatype,
                 'title': episode['title'],
                 'is_folder': False}
    add_info_dict_item(dict_item, episodeid, episode, episodes_list.data, False, common_data)
    set_watched_status(dict_item, episode, common_data)
    dict_item['art'] = get_art(episodeid, episode, common_data['profile_language_code'])
    dict_item['url'] = common.build_url(videoid=episodeid, mode=g.MODE_PLAY, params=common_data['params'])
    dict_item['menu_items'] = generate_context_menu_items(episodeid, False, None)
    return dict_item
Esempio n. 7
0
def _create_season_item(tvshowid, seasonid_value, season, season_list, common_data):
    seasonid = tvshowid.derive_season(seasonid_value)
    dict_item = {
        'video_id': seasonid_value,
        'media_type': seasonid.mediatype,
        'title': season['summary']['name'],
        'is_folder': True
    }
    add_info_dict_item(dict_item, seasonid, season, season_list.data, False, common_data)
    dict_item['art'] = get_art(tvshowid, season, common_data['profile_language_code'])
    dict_item['url'] = common.build_url(videoid=seasonid, mode=g.MODE_DIRECTORY)
    dict_item['menu_items'] = generate_context_menu_items(seasonid, False, None)
    return dict_item
Esempio n. 8
0
def _create_season_item(tvshowid, seasonid_value, season, season_list, common_data):
    seasonid = tvshowid.derive_season(seasonid_value)
    dict_item = {
        'video_id': seasonid_value,
        'media_type': seasonid.mediatype,
        'label': season['summary']['name'],
        'is_folder': True,
        'properties': {'nf_videoid': seasonid.to_string()}
    }
    add_info_dict_item(dict_item, seasonid, season, season_list.data, False, common_data,
                       art_item=season_list.artitem)
    dict_item['url'] = common.build_url(videoid=seasonid, mode=G.MODE_DIRECTORY)
    dict_item['menu_items'] = generate_context_menu_items(seasonid, False, None)
    return dict_item
Esempio n. 9
0
def _create_video_item(videoid_value, video, video_list, perpetual_range_start, common_data):
    videoid = common.VideoId.from_videolist_item(video)
    is_folder = videoid.mediatype == common.VideoId.SHOW
    is_in_mylist = videoid in common_data['mylist_items']
    dict_item = {'video_id': videoid_value,
                 'media_type': videoid.mediatype,
                 'title': video['title'],
                 'is_folder': is_folder}
    add_info_dict_item(dict_item, videoid, video, video_list.data, is_in_mylist, common_data)
    set_watched_status(dict_item, video, common_data)
    dict_item['art'] = get_art(videoid, video, common_data['profile_language_code'])
    dict_item['url'] = common.build_url(videoid=videoid,
                                        mode=g.MODE_DIRECTORY if is_folder else g.MODE_PLAY,
                                        params=common_data['params'])
    dict_item['menu_items'] = generate_context_menu_items(videoid, is_in_mylist, perpetual_range_start)
    return dict_item
Esempio n. 10
0
def _create_episode_item(seasonid, episodeid_value, episode, episodes_list,
                         common_data):
    episodeid = seasonid.derive_episode(episodeid_value)
    dict_item = {
        'video_id': episodeid_value,
        'media_type': episodeid.mediatype,
        'label': episode['title'],
        'is_folder': False,
        'properties': {
            'nf_videoid': episodeid.to_string()
        }
    }
    add_info_dict_item(dict_item, episodeid, episode, episodes_list.data,
                       False, common_data)
    set_watched_status(dict_item, episode, common_data)
    dict_item['url'] = common.build_url(videoid=episodeid,
                                        mode=G.MODE_PLAY,
                                        params=common_data['params'])
    dict_item['menu_items'] = generate_context_menu_items(
        episodeid, False, None)
    return dict_item