def _create_episode_item(seasonid, episodeid_value, episode, episodes_list,
                         common_data):
    is_playable = episode['summary']['isPlayable']
    episodeid = seasonid.derive_episode(episodeid_value)
    list_item = ListItemW(label=episode['title'])
    list_item.setProperties({
        'isPlayable': str(is_playable).lower(),
        'nf_videoid': episodeid.to_string()
    })
    add_info_list_item(list_item, episodeid, episode, episodes_list.data,
                       False, common_data)
    set_watched_status(list_item, episode, common_data)
    if is_playable:
        url = common.build_url(videoid=episodeid,
                               mode=G.MODE_PLAY,
                               params=common_data['params'])
        list_item.addContextMenuItems(
            generate_context_menu_items(episodeid, False, None))
    else:
        # The video is not playable, try check if there is a date
        list_item.setProperty('nf_availability_message',
                              get_availability_message(episode))
        url = common.build_url(['show_availability_message'],
                               mode=G.MODE_ACTION)
    return url, list_item, False
Example #2
0
def _create_profile_item(profile_guid, is_selected, is_autoselect, is_library_playback, detailed_info):
    profile_name = G.LOCAL_DB.get_profile_config('profileName', '???', guid=profile_guid)
    profile_attributes = []
    if G.LOCAL_DB.get_profile_config('isPinLocked', False, guid=profile_guid):
        profile_attributes.append('[COLOR red]' + common.get_local_string(20068) + '[/COLOR]')
    if G.LOCAL_DB.get_profile_config('isAccountOwner', False, guid=profile_guid):
        profile_attributes.append(common.get_local_string(30221))
    if G.LOCAL_DB.get_profile_config('isKids', False, guid=profile_guid):
        profile_attributes.append(common.get_local_string(30222))
    if is_autoselect and detailed_info:
        profile_attributes.append(common.get_local_string(30054))
    if is_library_playback and detailed_info:
        profile_attributes.append(common.get_local_string(30051))
    attributes_desc = '[CR]'.join(profile_attributes) + '[CR]' if profile_attributes else ''
    description = attributes_desc + '[' + G.LOCAL_DB.get_profile_config('language_desc', '', guid=profile_guid) + ']'

    if detailed_info:
        menu_items = generate_context_menu_profile(profile_guid, is_autoselect, is_library_playback)
    else:
        menu_items = []
    list_item = ListItemW(label=profile_name)
    list_item.setProperties({
        'nf_guid': profile_guid,
        'nf_description': description.replace('[CR]', ' - ')
    })
    list_item.setArt({'icon': G.LOCAL_DB.get_profile_config('avatar', '', guid=profile_guid)})
    list_item.setInfo('video', {'plot': description})
    list_item.select(is_selected)
    list_item.addContextMenuItems(menu_items)
    return (common.build_url(pathitems=['home'], params={'switch_profile_guid': profile_guid}, mode=G.MODE_DIRECTORY),
            list_item,
            True)
Example #3
0
def _create_video_item(videoid_value, video, video_list, perpetual_range_start,
                       common_data):  # pylint: disable=unused-argument
    videoid = common.VideoId.from_videolist_item(video)
    is_folder = videoid.mediatype == common.VideoId.SHOW
    is_playable = video['availability']['isPlayable']
    is_video_playable = not is_folder and is_playable
    is_in_mylist = videoid in common_data['mylist_items']
    list_item = ListItemW(label=video['title'])
    list_item.setProperties({
        'isPlayable':
        str(is_video_playable).lower(),
        'nf_videoid':
        videoid.to_string(),
        'nf_is_in_mylist':
        str(is_in_mylist),
        'nf_perpetual_range_start':
        str(perpetual_range_start)
    })
    add_info_list_item(list_item, videoid, video, video_list.data,
                       is_in_mylist, common_data)
    if not is_folder:
        set_watched_status(list_item, video, common_data)
    if is_playable:
        # The movie or tvshow (episodes) is playable
        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'])
        list_item.addContextMenuItems(
            generate_context_menu_items(
                videoid, is_in_mylist, perpetual_range_start,
                common_data['ctxmenu_remove_watched_status']))
    else:
        # The movie or tvshow (episodes) is not available
        # Try check if there is a availability date
        list_item.setProperty('nf_availability_message',
                              get_availability_message(video))
        # Check if the user has set "Remind Me" feature,
        try:
            #  Due to the add-on cache we can not change in easy way the value stored in database cache,
            #  then we temporary override the value (see 'remind_me' in navigation/actions.py)
            is_in_remind_me = G.CACHE.get(CACHE_BOOKMARKS,
                                          f'is_in_remind_me_{videoid}')
        except CacheMiss:
            #  The website check the "Remind Me" value on key "inRemindMeList" and also "queue"/"inQueue"
            is_in_remind_me = video['inRemindMeList'] or video['queue'][
                'inQueue']
        trackid = video['trackIds']['trackId_jaw']
        list_item.addContextMenuItems(
            generate_context_menu_remind_me(videoid, is_in_remind_me, trackid))
        url = common.build_url(['show_availability_message'],
                               videoid=videoid,
                               mode=G.MODE_ACTION)
    return url, list_item, is_folder and is_playable
def _create_video_item(videoid_value, video, video_list, perpetual_range_start,
                       common_data):  # pylint: disable=unused-argument
    videoid = common.VideoId.from_videolist_item(video)
    is_folder = videoid.mediatype == common.VideoId.SHOW
    is_playable = video['availability']['isPlayable']
    is_video_playable = not is_folder and is_playable
    is_in_mylist = videoid in common_data['mylist_items']
    list_item = ListItemW(label=video['title'])
    list_item.setProperties({
        'isPlayable':
        str(is_video_playable).lower(),
        'nf_videoid':
        videoid.to_string(),
        'nf_is_in_mylist':
        str(is_in_mylist),
        'nf_perpetual_range_start':
        str(perpetual_range_start)
    })
    add_info_list_item(list_item, videoid, video, video_list.data,
                       is_in_mylist, common_data)
    if not is_folder:
        set_watched_status(list_item, video, common_data)
    if is_playable:
        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'])
        list_item.addContextMenuItems(
            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
        list_item.setProperty('nf_availability_message',
                              get_availability_message(video))
        url = common.build_url(['show_availability_message'],
                               mode=G.MODE_ACTION)
    return url, list_item, is_folder and is_playable