Exemplo n.º 1
0
    def __init__(self, params):
        common.debug('Initializing hub browser: {}'.format(params))
        self.params = params

        profile_id = params.get('profile_id')
        if profile_id:
            api.activate_profile(profile_id)
 def _home_autoselect_profile(self):
     """
     Show home listing if profile auto-selection is enabled
     :return: True when the auto-selection is done correctly
     """
     autoselect_profile_guid = g.LOCAL_DB.get_value(
         'autoselect_profile_guid', '')
     if autoselect_profile_guid:
         # Check if the GUID still exists in the profile list
         if autoselect_profile_guid not in g.LOCAL_DB.get_guid_profiles():
             common.warn(
                 'Auto-selection of profile not performed, the GUID {} not exist',
                 autoselect_profile_guid)
             g.LOCAL_DB.set_value('autoselect_profile_guid', '')
             g.settings_monitor_suspend(True)
             g.ADDON.setSetting('autoselect_profile_name', '')
             g.ADDON.setSettingBool('autoselect_profile_enabled', False)
             g.settings_monitor_suspend(False)
         else:
             common.info('Performing auto-selection of profile {}',
                         autoselect_profile_guid)
             api.activate_profile(autoselect_profile_guid)
             self.home(None, False)
             return True
     return False
Exemplo n.º 3
0
 def root(self, pathitems=None):
     """Show profiles or home listing is autologin es enabled"""
     # pylint: disable=unused-argument
     autologin = g.ADDON.getSettingBool('autologin_enable')
     profile_id = g.ADDON.getSetting('autologin_id')
     if autologin and profile_id:
         common.info('Performing auto-login for selected profile {}', profile_id)
         api.activate_profile(profile_id)
         self.home(None, False)
     else:
         self.profiles()
 def __init__(self, params):
     common.debug('Initializing directory builder: {}', params)
     self.params = params
     # After build url the param value is converted as string
     self.perpetual_range_start = None \
         if self.params.get('perpetual_range_start') == 'None' else self.params.get('perpetual_range_start')
     self.dir_update_listing = bool(self.perpetual_range_start)
     if self.perpetual_range_start == '0':
         # For cache identifier purpose
         self.perpetual_range_start = None
     if 'switch_profile_guid' in params:
         api.activate_profile(params['switch_profile_guid'])
 def __init__(self, params):
     common.debug('Initializing directory builder: {}'.format(params))
     self.params = params
     # After build url the param value is converted as string
     self.perpetual_range_start = None \
         if self.params.get('perpetual_range_start') == 'None' else self.params.get('perpetual_range_start')
     self.dir_update_listing = True if self.perpetual_range_start else False
     if self.perpetual_range_start == '0':
         # For cache identifier purpose
         self.perpetual_range_start = None
     profile_id = params.get('profile_id')
     if profile_id:
         api.activate_profile(profile_id)
Exemplo n.º 6
0
 def __init__(self, params):
     common.debug('Initializing hub browser: {}', params)
     self.params = params
     if 'profile_guid' in params:
         api.activate_profile(params['profile_guid'])
Exemplo n.º 7
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)