示例#1
0
def build_mainmenu_listing(loco_list):
    """Builds the main menu listing (my list, continue watching, etc.)"""
    from resources.lib.kodi.context_menu import generate_context_menu_mainmenu
    directory_items = []
    common_data = {
        'profile_language_code':
        G.LOCAL_DB.get_profile_config('language', ''),
        'supplemental_info_color':
        get_color_name(G.ADDON.getSettingInt('supplemental_info_color'))
    }
    for menu_id, data in iteritems(G.MAIN_MENU_ITEMS):
        if data.get('has_show_setting',
                    True) and not G.ADDON.getSettingBool('_'.join(
                        ('show_menu', menu_id))):
            continue
        if data['loco_known']:
            list_id, video_list = loco_list.find_by_context(
                data['loco_contexts'][0])
            if not list_id:
                continue
            menu_title = video_list['displayName']
            dict_item = _create_videolist_item(list_id,
                                               video_list,
                                               data,
                                               common_data,
                                               static_lists=True)
        else:
            menu_title = common.get_local_string(data['label_id']) if data.get(
                'label_id') else 'Missing menu title'
            menu_description = (common.get_local_string(data['description_id'])
                                if data['description_id'] is not None else '')
            dict_item = {
                'url': common.build_url(data['path'], mode=G.MODE_DIRECTORY),
                'label': menu_title,
                'art': {
                    'icon': data['icon']
                },
                'info': {
                    'plot': menu_description
                },  # The description
                'is_folder': True
            }
        dict_item['menu_items'] = generate_context_menu_mainmenu(menu_id)
        directory_items.append(dict_item)
        # Save the menu titles, to reuse it when will be open the content of menus
        G.LOCAL_DB.set_value(menu_id, {'title': menu_title}, TABLE_MENU_DATA)
    # Add profiles menu
    directory_items.append({
        'url':
        common.build_url(['profiles'], mode=G.MODE_DIRECTORY),
        'label':
        common.get_local_string(13200),  # "Profiles"
        'art': {
            'icon': 'DefaultUser.png'
        },
        'is_folder':
        True
    })
    G.CACHE_MANAGEMENT.execute_pending_db_ops()
    return directory_items, {}
def build_episode_listing(episodes_list, seasonid, pathitems=None):
    """Build a episodes listing of a season"""
    common_data = {
        'params':
        get_param_watched_status_by_profile(),
        'set_watched_status':
        G.ADDON.getSettingBool('ProgressManager_enabled'),
        'supplemental_info_color':
        get_color_name(G.ADDON.getSettingInt('supplemental_info_color')),
        'profile_language_code':
        G.LOCAL_DB.get_profile_config('language', ''),
        'active_profile_guid':
        G.LOCAL_DB.get_active_profile_guid()
    }
    directory_items = [
        _create_episode_item(seasonid, episodeid_value, episode, episodes_list,
                             common_data)
        for episodeid_value, episode in episodes_list.episodes.items()
    ]
    # add_items_previous_next_page use the new value of perpetual_range_selector
    add_items_previous_next_page(directory_items, pathitems,
                                 episodes_list.perpetual_range_selector)
    G.CACHE_MANAGEMENT.execute_pending_db_ops()
    return directory_items, {
        'title':
        episodes_list.tvshow['title'] + ' - ' +
        episodes_list.season['summary']['name']
    }
示例#3
0
def build_lolomo_category_listing(lolomo_cat_list, menu_data):
    """Build a folders listing of a LoLoMo category"""
    common_data = {
        'profile_language_code':
        G.LOCAL_DB.get_profile_config('language', ''),
        'supplemental_info_color':
        get_color_name(G.ADDON.getSettingInt('supplemental_info_color'))
    }
    directory_items = []
    for list_id, summary_data, video_list in lolomo_cat_list.lists():
        if summary_data['length'] == 0:  # Do not show empty lists
            continue
        menu_parameters = common.MenuIdParameters(list_id)
        # Create dynamic sub-menu info in MAIN_MENU_ITEMS
        sub_menu_data = menu_data.copy()
        sub_menu_data['path'] = [menu_data['path'][0], list_id, list_id]
        sub_menu_data['loco_known'] = False
        sub_menu_data['loco_contexts'] = None
        sub_menu_data['content_type'] = menu_data.get('content_type',
                                                      G.CONTENT_SHOW)
        sub_menu_data['title'] = summary_data['displayName']
        sub_menu_data['initial_menu_id'] = menu_data.get(
            'initial_menu_id', menu_data['path'][1])
        sub_menu_data['no_use_cache'] = menu_parameters.type_id == '101'
        G.LOCAL_DB.set_value(list_id, sub_menu_data, TABLE_MENU_DATA)
        directory_item = _create_category_item(list_id, video_list,
                                               sub_menu_data, common_data,
                                               summary_data)
        directory_items.append(directory_item)
    G.CACHE_MANAGEMENT.execute_pending_db_ops()
    return directory_items, {}
示例#4
0
def build_lolomo_listing(lolomo_list, menu_data, force_use_videolist_id=False, exclude_lolomo_known=False):
    """Build a listing of video lists (LoLoMo)"""
    # If contexts are specified (lolomo_contexts in the menu_data), then the lolomo_list data will be filtered by
    # the specified contexts, otherwise all LoLoMo items will be added
    common_data = {
        'menu_data': menu_data,
        'supplemental_info_color': get_color_name(g.ADDON.getSettingInt('supplemental_info_color')),
        'profile_language_code': g.LOCAL_DB.get_profile_config('language', '')
    }
    contexts = menu_data.get('lolomo_contexts')
    items_list = lolomo_list.lists_by_context(contexts) if contexts else iteritems(lolomo_list.lists)
    directory_items = []
    for video_list_id, video_list in items_list:
        menu_parameters = common.MenuIdParameters(video_list_id)
        if not menu_parameters.is_menu_id:
            continue
        if exclude_lolomo_known and menu_parameters.type_id != '28':
            # Keep only the menus genre
            continue
        list_id = (menu_parameters.context_id
                   if menu_parameters.context_id and not force_use_videolist_id
                   else video_list_id)
        # Create dynamic sub-menu info in MAIN_MENU_ITEMS
        sub_menu_data = menu_data.copy()
        sub_menu_data['path'] = [menu_data['path'][0], list_id, list_id]
        sub_menu_data['lolomo_known'] = False
        sub_menu_data['lolomo_contexts'] = None
        sub_menu_data['content_type'] = menu_data.get('content_type', g.CONTENT_SHOW)
        sub_menu_data['force_use_videolist_id'] = force_use_videolist_id
        sub_menu_data['title'] = video_list['displayName']
        sub_menu_data['initial_menu_id'] = menu_data.get('initial_menu_id', menu_data['path'][1])
        g.LOCAL_DB.set_value(list_id, sub_menu_data, TABLE_MENU_DATA)

        directory_items.append(_create_videolist_item(list_id, video_list, sub_menu_data, common_data))
    return directory_items, {}
示例#5
0
def build_video_listing(video_list, menu_data, sub_genre_id=None, pathitems=None, perpetual_range_start=None,
                        mylist_items=None):
    """Build a video listing"""
    common_data = {
        'params': get_param_watched_status_by_profile(),
        'mylist_items': mylist_items,
        'set_watched_status': G.ADDON.getSettingBool('ProgressManager_enabled'),
        'supplemental_info_color': get_color_name(G.ADDON.getSettingInt('supplemental_info_color')),
        'mylist_titles_color': (get_color_name(G.ADDON.getSettingInt('mylist_titles_color'))
                                if menu_data['path'][1] != 'myList'
                                else None),
        'profile_language_code': G.LOCAL_DB.get_profile_config('language', ''),
        'ctxmenu_remove_watched_status': menu_data['path'][1] == 'continueWatching',
        'active_profile_guid': G.LOCAL_DB.get_active_profile_guid()
    }
    directory_items = [_create_video_item(videoid_value, video, video_list, perpetual_range_start, common_data)
                       for videoid_value, video
                       in video_list.videos.items()]
    # If genre_id exists add possibility to browse LoCo sub-genres
    if sub_genre_id and sub_genre_id != 'None':
        # Create dynamic sub-menu info in MAIN_MENU_ITEMS
        menu_id = 'subgenre_' + sub_genre_id
        sub_menu_data = menu_data.copy()
        sub_menu_data['path'] = [menu_data['path'][0], menu_id, sub_genre_id]
        sub_menu_data['loco_known'] = False
        sub_menu_data['loco_contexts'] = None
        sub_menu_data['content_type'] = menu_data.get('content_type', G.CONTENT_SHOW)
        sub_menu_data.update({'title': common.get_local_string(30089)})
        sub_menu_data['initial_menu_id'] = menu_data.get('initial_menu_id', menu_data['path'][1])
        G.LOCAL_DB.set_value(menu_id, sub_menu_data, TABLE_MENU_DATA)
        # Create the folder for the access to sub-genre
        folder_dict_item = {
            'url': common.build_url(['genres', menu_id, sub_genre_id], mode=G.MODE_DIRECTORY),
            'label': common.get_local_string(30089),
            'art': {'icon': 'DefaultVideoPlaylists.png'},
            'info': {'plot': common.get_local_string(30088)},  # The description
            'is_folder': True
        }
        directory_items.insert(0, folder_dict_item)
    # add_items_previous_next_page use the new value of perpetual_range_selector
    add_items_previous_next_page(directory_items, pathitems, video_list.perpetual_range_selector, sub_genre_id)
    G.CACHE_MANAGEMENT.execute_pending_db_ops()
    return directory_items, {}
示例#6
0
def build_season_listing(season_list, tvshowid, pathitems=None):
    """Build a season listing"""
    common_data = {
        'supplemental_info_color': get_color_name(g.ADDON.getSettingInt('supplemental_info_color')),
        'profile_language_code': g.LOCAL_DB.get_profile_config('language', '')
    }
    directory_items = [_create_season_item(tvshowid, seasonid_value, season, season_list, common_data)
                       for seasonid_value, season
                       in iteritems(season_list.seasons)]
    # add_items_previous_next_page use the new value of perpetual_range_selector
    add_items_previous_next_page(directory_items, pathitems, season_list.perpetual_range_selector, tvshowid)
    return directory_items, {'title': season_list.tvshow['title'] + ' - ' + common.get_local_string(20366)[2:]}
def build_loco_listing(loco_list,
                       menu_data,
                       force_use_videolist_id=False,
                       exclude_loco_known=False):
    """Build a listing of video lists (LoCo)"""
    # If contexts are specified (loco_contexts in the menu_data), then the loco_list data will be filtered by
    # the specified contexts, otherwise all LoCo items will be added
    common_data = {
        'menu_data':
        menu_data,
        'supplemental_info_color':
        get_color_name(G.ADDON.getSettingInt('supplemental_info_color')),
        'profile_language_code':
        G.LOCAL_DB.get_profile_config('language', '')
    }
    contexts = menu_data.get('loco_contexts')
    items_list = loco_list.lists_by_context(
        contexts) if contexts else loco_list.lists.items()
    directory_items = []
    for video_list_id, video_list in items_list:
        menu_parameters = common.MenuIdParameters(video_list_id)
        if not menu_parameters.is_menu_id:
            continue
        list_id = (menu_parameters.context_id if menu_parameters.context_id
                   and not force_use_videolist_id else video_list_id)
        # Keep only some type of menus: 28=genre, 101=top 10
        if exclude_loco_known:
            if menu_parameters.type_id not in ['28', '101']:
                continue
            if menu_parameters.type_id == '101':
                # Top 10 list can be obtained only with 'video_list' query
                force_use_videolist_id = True
        # Create dynamic sub-menu info in MAIN_MENU_ITEMS
        sub_menu_data = menu_data.copy()
        sub_menu_data['path'] = [menu_data['path'][0], list_id, list_id]
        sub_menu_data['loco_known'] = False
        sub_menu_data['loco_contexts'] = None
        sub_menu_data['content_type'] = menu_data.get('content_type',
                                                      G.CONTENT_SHOW)
        sub_menu_data['force_use_videolist_id'] = force_use_videolist_id
        sub_menu_data['title'] = video_list['displayName']
        sub_menu_data['initial_menu_id'] = menu_data.get(
            'initial_menu_id', menu_data['path'][1])
        sub_menu_data['no_use_cache'] = menu_parameters.type_id == '101'
        G.LOCAL_DB.set_value(list_id, sub_menu_data, TABLE_MENU_DATA)

        directory_items.append(
            _create_videolist_item(list_id, video_list, sub_menu_data,
                                   common_data))
    G.CACHE_MANAGEMENT.execute_pending_db_ops()
    return directory_items, {}
示例#8
0
def build_season_listing(season_list, tvshowid, pathitems=None):
    """Build a season listing"""
    common_data = {
        'supplemental_info_color':
        get_color_name(G.ADDON.getSettingInt('supplemental_info_color')),
        'profile_language_code':
        G.LOCAL_DB.get_profile_config('language', '')
    }
    directory_items = [
        _create_season_item(tvshowid, seasonid_value, season, season_list,
                            common_data)
        for seasonid_value, season in season_list.seasons.items()
    ]
    # add_items_previous_next_page use the new value of perpetual_range_selector
    add_items_previous_next_page(directory_items, pathitems,
                                 season_list.perpetual_range_selector,
                                 tvshowid)
    G.CACHE_MANAGEMENT.execute_pending_db_ops()
    return directory_items, {
        'title':
        f'{season_list.tvshow["title"]} - {common.get_local_string(20366)[2:]}'
    }