From 65fd18f65492acd166447874ed9c1ecd5af64025 Mon Sep 17 00:00:00 2001 From: Vladimir Maksimenko Date: Mon, 31 May 2021 03:41:03 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=BE=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D1=81=D1=82=D1=8C=20=D1=81=20Kodi=2019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 181 ++++++++++++++---- .../context_search.py | 3 +- plugin.video.united.search/default.py | 2 +- .../resources/lib/unitedsearch.py | 51 +++-- 4 files changed, 183 insertions(+), 54 deletions(-) diff --git a/.gitignore b/.gitignore index 21f214f..f37a204 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -# ========================================== -# Eclipse -# ========================================== +# Created by https://www.gitignore.io/api/pydev,python,pycharm,windows,eclipse +# Edit at https://www.gitignore.io/?templates=pydev,python,pycharm,windows,eclipse + +### Eclipse ### .metadata bin/ tmp/ @@ -13,7 +14,6 @@ local.properties .settings/ .loadpath .recommenders -.project # External tool builders .externalToolBuilders/ @@ -59,10 +59,111 @@ local.properties .scala_dependencies .worksheet -# ========================================== -# Python -# ========================================== +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Annotation Processing +.apt_generated + +.sts4-cache/ + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr +.idea/ + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/**/sonarlint/ + +# SonarQube Plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator/ + +### pydev ### +.pydevproject + +### Python ### # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -85,6 +186,7 @@ parts/ sdist/ var/ wheels/ +pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg @@ -118,15 +220,6 @@ coverage.xml *.mo *.pot -# Django stuff: -*.log -local_settings.py -db.sqlite3 - -# Flask stuff: -instance/ -.webassets-cache - # Scrapy stuff: .scrapy @@ -136,31 +229,22 @@ docs/_build/ # PyBuilder target/ -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - # pyenv .python-version +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - # Spyder project settings .spyderproject .spyproject @@ -168,6 +252,9 @@ venv.bak/ # Rope project settings .ropeproject +# Mr Developer +.mr.developer.cfg + # mkdocs documentation /site @@ -178,4 +265,32 @@ dmypy.json # Pyre type checker .pyre/ -script.module.simplemedia/ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/pydev,python,pycharm,windows,eclipse + diff --git a/context.united.search.search/context_search.py b/context.united.search.search/context_search.py index 58ef452..3b6a398 100644 --- a/context.united.search.search/context_search.py +++ b/context.united.search.search/context_search.py @@ -42,8 +42,9 @@ def main(): else: keyword = '' + cont_edit_keyword = plugin.get_setting('cont_edit_keyword') - if keyword and plugin.cont_edit_keyword: + if keyword and cont_edit_keyword: kbd = xbmc.Keyboard() kbd.setDefault(keyword) kbd.setHeading(_('Search')) diff --git a/plugin.video.united.search/default.py b/plugin.video.united.search/default.py index 6d19bb0..0829f98 100644 --- a/plugin.video.united.search/default.py +++ b/plugin.video.united.search/default.py @@ -11,7 +11,7 @@ @plugin.action() def root( params ): - return plugin.create_listing(__list_root(), content='files') + plugin.create_directory(__list_root(), content='files') def __list_root(): items = [ {'action': 'search', 'label': _('New Search'), 'is_folder': False}, diff --git a/plugin.video.united.search/resources/lib/unitedsearch.py b/plugin.video.united.search/resources/lib/unitedsearch.py index 41aef57..dd0be62 100644 --- a/plugin.video.united.search/resources/lib/unitedsearch.py +++ b/plugin.video.united.search/resources/lib/unitedsearch.py @@ -1,18 +1,24 @@ # -*- coding: utf-8 -*- # License: GPL v.3 https://www.gnu.org/copyleft/gpl.html +from __future__ import unicode_literals +from future.utils import PY2, PY3 + import xbmc import xbmcgui import xbmcaddon import xbmcplugin -import urllib import json import pyxbmct import threading -import gui +if PY3: + from urllib.parse import quote +else: + from future.backports.urllib.parse import quote + -from simpleplugin import Plugin +from simplemedia import Plugin, py2_decode, py2_encode plugin = Plugin('plugin.video.united.search') _ = plugin.initialize_gettext() @@ -38,6 +44,8 @@ def search( self, params ): kbd.doModal() if kbd.isConfirmed(): keyword = kbd.getText() + else: + keyword = py2_encode(keyword) if keyword: succeeded = True @@ -46,11 +54,10 @@ def search( self, params ): enabled_addons = self.__get_enabled_addons() total_addons = len(enabled_addons) - progress = xbmcgui.DialogProgress() - progress.create(_('Search'), _('Please wait. Searching...')) + progress = plugin.dialog_progress_create(_('Search'), _('Please wait. Searching...')) for i, addon in enumerate(enabled_addons): result_string = '%s: %d' % (_('Search results'), len(listing)) - progress.update(100 * i / total_addons, line2=addon['name'], line3=result_string) + plugin.dialog_progress_update(progress,int(100 * i / total_addons), line2=addon['name'], line3=result_string) if (progress.iscanceled()): #succeeded = False return @@ -65,7 +72,7 @@ def search( self, params ): else: path_tpl = 'plugin://{0}/?{1}{2}&usearch=True' - directory = path_tpl.format(addon['id'], us_command, urllib.quote(keyword)) + directory = path_tpl.format(addon['id'], us_command, quote(keyword)) directory_list = self.get_directory(directory) @@ -77,13 +84,15 @@ def search( self, params ): progress.close() if succeeded: + history_length = plugin.get_setting('history_length') + with plugin.get_storage('__history__.pcl') as storage: history = storage.get('history', []) - item_content = {'keyword': keyword.decode('utf-8'), 'listing': listing} + item_content = {'keyword': py2_decode(keyword), 'listing': listing} history.insert(0, item_content) - if len(history) > plugin.history_length: + if len(history) > history_length: history.pop(-1) storage['history'] = history @@ -141,11 +150,11 @@ def search_results( self, params ): listing = [] keyword = '' - return plugin.create_listing(self.__list_serach_result(keyword, listing), content='movies', update_listing=update_listing, sort_methods=[27], category=keyword) + plugin.create_directory(self.__list_serach_result(keyword, listing), content='movies', update_listing=update_listing, sort_methods=[27], category=keyword) def __list_serach_result( self, keyword, video_list ): if keyword: - url = plugin.get_url(action='search', update_listing=True, keyword=keyword.encode('utf-8')) + url = plugin.get_url(action='search', update_listing=True, keyword=keyword) list_item = {'label': _('Repeat Search'), 'info': { 'video': {'sorttitle': '!*_repeat_search'} }, 'is_folder': False, @@ -174,15 +183,19 @@ def __make_item( self, video_item, addon_name, keyword ): if keyword and (keyword.lower() in sorttitle.lower() or originaltitle and keyword.lower() in originaltitle.lower()): sorttitle = '*' + sorttitle + add_name_lable = plugin.get_setting('add_name_lable') + add_name_lable_position = plugin.get_setting('add_name_lable_position') + add_name_plot = plugin.get_setting('add_name_plot') + label = video_item['label'].strip() - if plugin.add_name_lable: - if plugin.add_name_lable_position == 0: + if add_name_lable: + if add_name_lable_position == 0: label = '[%s] %s' % (addon_name, label) else: label = '%s [%s]' % (label, addon_name) plot = video_item.get('plot') - if plugin.add_name_plot: + if add_name_plot: if plot: plot = '[B]%s[/B]\n\n%s' % (addon_name, plot) else: @@ -207,10 +220,10 @@ def __make_item( self, video_item, addon_name, keyword ): return item_info def search_history( self, params ): - return plugin.create_listing(self.__list_search_history(), content='files', category=_('Search History')) + plugin.create_directory(self.__list_search_history(), content='files', category=_('Search History')) def __list_search_history( self ): - history_length = plugin.history_length + history_length = plugin.get_setting('history_length') with plugin.get_storage('__history__.pcl') as storage: history = storage.get('history', []) @@ -230,7 +243,7 @@ def __show_notification( self, text ): xbmcgui.Dialog().notification(plugin.addon.getAddonInfo('name'), text) def __load_supported_addons( self ): - del_unified_name = plugin.del_unified_name + del_unified_name = plugin.get_setting('del_unified_name') self.__supported_addons = [] @@ -302,7 +315,7 @@ def add_learned_addon( self, path ): plugin.log_error(united_search) if united_search in ['true','false']: self.__show_notification(_('Addon has native support')) - elif self.__sheck_learned_directory(path): + elif self.__check_learned_directory(path): addon_object.setSetting('united_search_learned', 'true') addon_object.setSetting('usl_command', path) self.__show_notification(_('Added search support')) @@ -348,7 +361,7 @@ def __wait_keyboard(self, params): return not wait_keyboard - def __sheck_learned_directory( self, directory ): + def __check_learned_directory( self, directory ): t = threading.Thread(target=_get_directory_threaded, args = (self, directory)) t.start() From 869ab0b30c176e6d3f607cdfae1de731d0fbb1cd Mon Sep 17 00:00:00 2001 From: Vladimir Maksimenko Date: Mon, 31 May 2021 03:44:13 +0300 Subject: [PATCH 2/2] version bump --- context.united.search.search/addon.xml | 2 +- plugin.video.united.search/addon.xml | 4 ++-- plugin.video.united.search/changelog.txt | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/context.united.search.search/addon.xml b/context.united.search.search/addon.xml index 6183445..af1b4e9 100644 --- a/context.united.search.search/addon.xml +++ b/context.united.search.search/addon.xml @@ -1,5 +1,5 @@  - + diff --git a/plugin.video.united.search/addon.xml b/plugin.video.united.search/addon.xml index 5d6806c..baa2509 100644 --- a/plugin.video.united.search/addon.xml +++ b/plugin.video.united.search/addon.xml @@ -1,5 +1,5 @@ - + @@ -22,7 +22,7 @@ http://xbmc.ru/forum/showthread.php?t=14278 vl.maksime@gmail.com https://github.com/vlmaksime/plugin.video.united.search - v0.2.5 (2019-08-09)[CR]- Добавлена поддержка "красивых ссылок"[CR][CR]v0.2.4 (2018-10-21)[CR]- Исправлены выявленные ошибки[CR][CR]v0.2.3 (2018-10-07)[CR]- Пункты контекстного меню вынесены в отдельные дополнения[CR][CR]v0.2.2 (2017-07-02)[CR]- Доработан механизм обучения и поиска в дополнениях без встроенной поддержки + v0.3.1 (2021-05-31)[CR]- Добавлена совместимость с Kodi 19 icon.png resources\media\screenshot-01.jpg diff --git a/plugin.video.united.search/changelog.txt b/plugin.video.united.search/changelog.txt index 06fcd6f..c629eb2 100644 --- a/plugin.video.united.search/changelog.txt +++ b/plugin.video.united.search/changelog.txt @@ -1,3 +1,6 @@ +v0.3.1 (2021-05-31) +- Добавлена совместимость с Kodi 19 + v0.2.5 (2019-08-09) - Добавлена поддержка "красивых ссылок"