def initial_mylist_sync(self, pathitems):
     """Perform an initial sync of My List and the Kodi library"""
     # pylint: disable=unused-argument
     from resources.lib.cache import CACHE_COMMON
     # This is a temporary workaround to prevent sync from mylist of non owner account profiles
     # TODO: in the future you can also add the possibility to synchronize from a chosen profile
     is_account_owner = g.LOCAL_DB.get_profile_config(
         'isAccountOwner', False)
     if not is_account_owner:
         ui.show_ok_dialog('Netflix', common.get_local_string(30223))
         return
     do_it = ui.ask_for_confirmation(common.get_local_string(30122),
                                     common.get_local_string(30123))
     if not do_it:
         return
     common.debug('Performing full sync from My List to Kodi library')
     library.purge()
     nfo_settings = nfo.NFOSettings()
     nfo_settings.show_export_dialog()
     # Invalidate my-list cached data to force to obtain new data
     g.CACHE.invalidate_entry(CACHE_COMMON, 'my_list_items')
     for videoid in api.mylist_items():
         library.execute_library_tasks(videoid, [library.export_item],
                                       common.get_local_string(30018),
                                       sync_mylist=False,
                                       nfo_settings=nfo_settings)
Beispiel #2
0
def generate_context_menu_items(videoid):
    """Generate context menu items for a listitem"""
    items = _generate_library_ctx_items(videoid)

    # Old rating system
    # if videoid.mediatype != common.VideoId.SEASON and \
    #    videoid.mediatype != common.VideoId.SUPPLEMENTAL:
    #     items.insert(0, _ctx_item('rate', videoid))

    if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.SHOW]:
        items.insert(0, _ctx_item('rate_thumb', videoid))

    if videoid.mediatype != common.VideoId.SUPPLEMENTAL and \
            videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.SHOW]:
        items.insert(0, _ctx_item('trailer', videoid))

    if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.SHOW]:
        list_action = ('remove_from_list'
                       if videoid in api.mylist_items() else 'add_to_list')
        items.insert(0, _ctx_item(list_action, videoid))

    if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.EPISODE]:
        # Add menu to allow change manually the watched status when progress manager is enabled
        if g.ADDON.getSettingBool('ProgressManager_enabled'):
            items.insert(0, _ctx_item('change_watched_status', videoid))

    return items
Beispiel #3
0
def generate_context_menu_items(videoid):
    """Generate context menu items for a listitem"""
    items = _generate_library_ctx_items(videoid)

    if videoid.mediatype != common.VideoId.SEASON:
        items.insert(0, _ctx_item('rate', videoid))

    if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.SHOW]\
        and g.PERSISTENT_STORAGE.get('profile_have_mylist_menu', False):
        list_action = ('remove_from_list' if videoid.value
                       in api.mylist_items() else 'add_to_list')
        items.insert(0, _ctx_item(list_action, videoid))

    return items
def generate_context_menu_items(videoid):
    """Generate context menu items for a listitem"""
    items = _generate_library_ctx_items(videoid)

    if videoid.mediatype != common.VideoId.SEASON:
        items.insert(0, _ctx_item('rate', videoid))

    if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.SHOW
                             ] and g.MAIN_MENU_HAVE_MYLIST:
        list_action = ('remove_from_list' if videoid.value
                       in api.mylist_items() else 'add_to_list')
        items.insert(0, _ctx_item(list_action, videoid))

    return items
def add_highlighted_title(list_item, videoid, infos):
    """Highlight menu item title when the videoid is contained in my-list"""
    color_index = g.ADDON.getSettingInt('highlight_mylist_titles')
    if not color_index:
        return
    apply_color = videoid in api.mylist_items()
    if list_item.getProperty('isFolder') == 'true':
        updated_title = _colorize_text(
            apply_color, color_index,
            g.py2_decode(list_item.getVideoInfoTag().getTitle()))
        list_item.setLabel(updated_title)
        infos['title'] = updated_title
    else:
        # When menu item is not a folder 'label' is replaced by 'title' property of infoLabel
        infos['title'] = _colorize_text(apply_color, color_index,
                                        infos['title'])
Beispiel #6
0
def add_highlighted_title(list_item, videoid, infos):
    """Highlight menu item title when the videoid is contained in my-list"""
    highlight_index = g.ADDON.getSettingInt('highlight_mylist_titles')
    if not highlight_index:
        return
    highlight_color = ['black', 'blue', 'red', 'green', 'white', 'yellow'][highlight_index]
    remove_color = videoid not in api.mylist_items()
    if list_item.getProperty('isFolder') == 'true':
        updated_title = _colorize_title(g.py2_decode(list_item.getVideoInfoTag().getTitle()),
                                        highlight_color,
                                        remove_color)
        list_item.setLabel(updated_title)
        infos['title'] = updated_title
    else:
        # When menu item is not a folder 'label' is replaced by 'title' property of infoLabel
        infos['title'] = _colorize_title(infos['title'], highlight_color, remove_color)
Beispiel #7
0
def generate_context_menu_items(videoid):
    """Generate context menu items for a listitem"""
    items = _generate_library_ctx_items(videoid)

    if videoid.mediatype != common.VideoId.SEASON and \
       videoid.mediatype != common.VideoId.SUPPLEMENTAL:
        items.insert(0, _ctx_item('rate', videoid))

    if videoid.mediatype != common.VideoId.SUPPLEMENTAL and \
            videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.SHOW]:
        items.insert(0, _ctx_item('trailer', videoid))

    if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.SHOW]:
        list_action = ('remove_from_list'
                       if videoid in api.mylist_items() else 'add_to_list')
        items.insert(0, _ctx_item(list_action, videoid))

    return items
 def initial_mylist_sync(self, pathitems):
     """Perform an initial sync of My List and the Kodi library"""
     # pylint: disable=unused-argument
     from resources.lib.cache import CACHE_COMMON
     do_it = ui.ask_for_confirmation(common.get_local_string(30122),
                                     common.get_local_string(30123))
     if not do_it:
         return
     common.debug('Performing full sync from My List to Kodi library')
     library.purge()
     nfo_settings = nfo.NFOSettings()
     nfo_settings.show_export_dialog()
     # Invalidate my-list cached data to force to obtain new data
     g.CACHE.invalidate_entry(CACHE_COMMON, 'my_list_items')
     for videoid in api.mylist_items():
         library.execute_library_tasks(videoid, [library.export_item],
                                       common.get_local_string(30018),
                                       sync_mylist=False,
                                       nfo_settings=nfo_settings)
Beispiel #9
0
def export_all_new_episodes():
    """
    Update the local Kodi library with new episodes of every exported shows
    """
    from resources.lib.cache import CACHE_COMMON
    from resources.lib.database.db_exceptions import ProfilesMissing
    if _export_all_new_episodes_running():
        return
    common.log('Starting to export new episodes for all tv shows')
    g.SHARED_DB.set_value('library_export_new_episodes_running', True)
    g.SHARED_DB.set_value('library_export_new_episode_start_time',
                          datetime.now())
    # Get the list of the tvshows exported to kodi library
    exported_videoids_values = g.SHARED_DB.get_tvshows_id_list()
    # Get the list of the tvshows exported but to exclude from updates
    excluded_videoids_values = g.SHARED_DB.get_tvshows_id_list(
        VidLibProp.exclude_update, True)

    # Before start to get updated mylist items, you have to select the owner account
    # TODO: in the future you can also add the possibility to synchronize from a chosen profile
    try:
        guid_owner_profile = g.LOCAL_DB.get_guid_owner_profile()
    except ProfilesMissing as exc:
        import traceback
        common.error(traceback.format_exc())
        ui.show_addon_error_info(exc)
        return
    if guid_owner_profile != g.LOCAL_DB.get_active_profile_guid():
        common.debug('Switching to owner account profile')
        api.activate_profile(guid_owner_profile)

    # Retrieve updated items from "my list"
    # Invalidate my-list cached data to force to obtain new data
    g.CACHE.invalidate_entry(CACHE_COMMON, 'my_list_items')
    mylist_videoids = api.mylist_items()

    # Check if any tvshow have been removed from the mylist
    for videoid_value in exported_videoids_values:
        if any(videoid.value == unicode(videoid_value)
               for videoid in mylist_videoids):
            continue
        # Tvshow no more exist in mylist so remove it from library
        videoid = common.VideoId.from_path(
            [common.VideoId.SHOW, videoid_value])
        execute_library_tasks_silently(videoid, [remove_item],
                                       sync_mylist=False)

    # Update or add tvshow in kodi library
    for videoid in mylist_videoids:
        # Only tvshows require be updated
        if videoid.mediatype != common.VideoId.SHOW:
            continue
        if videoid.value in excluded_videoids_values:
            continue
        if videoid.value in exported_videoids_values:
            # It is possible that the user has chosen not to export nfo for a tvshow
            nfo_export = g.SHARED_DB.get_tvshow_property(
                videoid.value, VidLibProp.nfo_export, False)
            nfo_settings = nfo.NFOSettings(nfo_export)
        else:
            nfo_settings = nfo.NFOSettings()
        export_new_episodes(videoid, True, nfo_settings)
        # add some randomness between show analysis to limit servers load and ban risks
        xbmc.sleep(random.randint(1000, 5001))

    g.SHARED_DB.set_value('library_export_new_episodes_running', False)
    if not g.ADDON.getSettingBool('disable_library_sync_notification'):
        ui.show_notification(common.get_local_string(30220), time=5000)
    common.debug('Notify service to update the library')
    common.send_signal(common.Signals.LIBRARY_UPDATE_REQUESTED)