Ejemplo n.º 1
0
def toggle_language_invoker():
    import xml.etree.ElementTree as ET
    from modules.utils import gen_file_hash
    kodi_utils.close_all_dialog()
    kodi_utils.sleep(100)
    addon_dir = kodi_utils.translate_path(
        'special://home/addons/plugin.video.fen')
    addon_xml = os.path.join(addon_dir, 'addon.xml')
    tree = ET.parse(addon_xml)
    root = tree.getroot()
    try:
        current_value = [
            str(i.text) for i in root.iter('reuselanguageinvoker')
        ][0]
    except:
        return
    current_setting = get_setting('reuse_language_invoker')
    new_value = 'false' if current_value == 'true' else 'true'
    if not kodi_utils.confirm_dialog(
            text=ls(33018) % (current_value.upper(), new_value.upper())):
        return
    if new_value == 'true':
        if not kodi_utils.confirm_dialog(text=33019, top_space=True): return
    for item in root.iter('reuselanguageinvoker'):
        item.text = new_value
        hash_start = gen_file_hash(addon_xml)
        tree.write(addon_xml)
        hash_end = gen_file_hash(addon_xml)
        if hash_start != hash_end:
            set_setting('reuse_language_invoker', new_value)
        else:
            return kodi_utils.ok_dialog(text=32574, top_space=True)
    kodi_utils.ok_dialog(text=33020, top_space=True)
    kodi_utils.execute_builtin('LoadProfile(%s)' %
                               kodi_utils.get_infolabel('system.profilename'))
Ejemplo n.º 2
0
def get_search_term(params):
    kodi_utils.close_all_dialog()
    db_type = params.get('db_type', '')
    query = params.get('query')
    search_type = params.get('search_type', 'media_title')
    if not query:
        from urllib.parse import unquote
        query = kodi_utils.dialog.input('Fen')
        if not query: return
        query = unquote(query)
    if search_type == 'media_title':
        mode, action = ('build_movie_list',
                        'tmdb_movies_search') if db_type == 'movie' else (
                            'build_tvshow_list', 'tmdb_tv_search')
        url = {'mode': mode, 'action': action, 'query': query}
    elif search_type == 'imdb_keyword':
        url = {
            'mode': 'imdb_build_keyword_results',
            'db_type': db_type,
            'query': query
        }
    if kodi_utils.external_browse():
        return kodi_utils.execute_builtin('ActivateWindow(10025,%s,return)' %
                                          kodi_utils.build_url(url))
    return kodi_utils.execute_builtin('Container.Update(%s)' %
                                      kodi_utils.build_url(url))
Ejemplo n.º 3
0
 def _kill_progress_dialog(self):
     try:
         self.progress_dialog.close()
     except:
         kodi_utils.close_all_dialog()
     try:
         del self.progress_dialog
     except:
         pass
     self.progress_dialog = None
Ejemplo n.º 4
0
def clear_all_trakt_cache_data(silent=False, confirm=True):
    def _process():
        dbcon = _cache.connect_database()
        dbcur = dbcon.cursor()
        for table in ('trakt_data', 'progress', 'watched_status'):
            dbcur.execute(BASE_DELETE % table)
            dbcon.commit()
        dbcur.execute('VACUUM')
        dbcon.close()

    if silent:
        return _process()
    else:
        if confirm:
            if not confirm_dialog(): return False
        from apis.trakt_api import trakt_sync_activities
        close_all_dialog()
        sleep(200)
        try:
            _process()
            trakt_sync_activities()
            return True
        except:
            return False
Ejemplo n.º 5
0
def clean_settings():
    import xml.etree.ElementTree as ET

    def _make_content(dict_object):
        content = '<settings version="2">'
        for item in dict_object:
            _id = item['id']
            if _id in active_settings:
                if 'default' in item and 'value' in item:
                    content += '\n    <setting id="%s" default="%s">%s</setting>' % (
                        _id, item['default'], item['value'])
                elif 'default' in item:
                    content += '\n    <setting id="%s" default="%s"></setting>' % (
                        _id, item['default'])
                elif 'value' in item:
                    content += '\n    <setting id="%s">%s</setting>' % (
                        _id, item['value'])
                else:
                    content += '\n    <setting id="%s"></setting>'
            else:
                removed_append(item)
        content += '\n</settings>'
        return content

    kodi_utils.close_all_dialog()
    kodi_utils.sleep(200)
    kodi_utils.progressDialog.create(ls(32577), '')
    kodi_utils.progressDialog.update(0)
    addon_ids = [
        'plugin.video.fen', 'script.module.fenomscrapers',
        'script.module.myaccounts'
    ]
    addon_names = [
        kodi_utils.ext_addon(i).getAddonInfo('name') for i in addon_ids
    ]
    addon_dirs = [
        kodi_utils.translate_path(
            kodi_utils.ext_addon(i).getAddonInfo('path')) for i in addon_ids
    ]
    profile_dirs = [
        kodi_utils.translate_path(
            kodi_utils.ext_addon(i).getAddonInfo('profile')) for i in addon_ids
    ]
    active_settings_xmls = [
        os.path.join(
            kodi_utils.translate_path(
                kodi_utils.ext_addon(i).getAddonInfo('path')), 'resources',
            'settings.xml') for i in addon_ids
    ]
    params = list(zip(addon_names, profile_dirs, active_settings_xmls))
    for addon in params:
        try:
            try:
                if kodi_utils.progressDialog.iscanceled(): break
            except:
                pass
            current_progress = params.index(addon) + 1
            removed_settings = []
            active_settings = []
            current_user_settings = []
            removed_append = removed_settings.append
            active_append = active_settings.append
            current_append = current_user_settings.append
            root = ET.parse(addon[2]).getroot()
            for item in root.findall('./category/setting'):
                setting_id = item.get('id')
                if setting_id: active_append(setting_id)
            settings_xml = os.path.join(addon[1], 'settings.xml')
            root = ET.parse(settings_xml).getroot()
            for item in root:
                dict_item = {}
                setting_id = item.get('id')
                setting_default = item.get('default')
                setting_value = item.text
                dict_item['id'] = setting_id
                if setting_value: dict_item['value'] = setting_value
                if setting_default: dict_item['default'] = setting_default
                current_append(dict_item)
            new_content = _make_content(current_user_settings)
            xml_file = kodi_utils.open_file(settings_xml, 'w')
            xml_file.write(new_content)
            xml_file.close()
            percent = int((current_progress / float(len(params))) * 100)
            line2 = ls(32812) % addon[0]
            line3 = ls(32813) % len(removed_settings)
            kodi_utils.progressDialog.update(percent,
                                             '[CR]%s[CR]%s' % (line2, line3))
        except:
            kodi_utils.notification(32574, 2000)
        kodi_utils.sleep(800)
    try:
        kodi_utils.progressDialog.close()
    except:
        pass
    kodi_utils.ok_dialog(text=32576, top_space=True)