diff --git a/kodi-vk.inpos.ru/default.py b/kodi-vk.inpos.ru/default.py index 284c0b1..824d3ef 100644 --- a/kodi-vk.inpos.ru/default.py +++ b/kodi-vk.inpos.ru/default.py @@ -4,7 +4,7 @@ from math import ceil import xbmc, xbmcplugin, xbmcaddon, xbmcgui import urlparse import urllib2 -from urllib import urlencode +from urllib import urlencode, urlopen import re _VERSION = '0.0.1' @@ -18,12 +18,21 @@ _addon_path = _addon.getAddonInfo('path').decode('utf-8') _APP_ID = '4353740' _SCOPE = 'friends,photos,audio,video,groups,messages,offline' -_SETTINGS_TOKEN = 'vk_token' + +_SETTINGS_ID_TOKEN = 'vk_token' +_SETTINGS_ID_MAX_RES = 'video_resolution' +_SETTINGS_ID_VIDEO_SEARCH_SORT = 'v_search_sort' +_SETTINGS_ID_VIDEO_SEARCH_HD = 'search_hd_video' +_SETTINGS_ID_VIDEO_SEARCH_ADULT = 'search_adult_video' + +_SETTINGS_BOOL = {'true': 1, 'false': 0} +_SETTINGS_INV_BOOL = {'true': 0, 'false': 1} + _SETTINGS_PAGE_ITEMS = 20 -_SETTINGS_MAX_RES = 1080 -_SETTINGS_VIDEO_SEARCH_SORT = 2 -_SETTINGS_VIDEO_SEARCH_HD = 0 -_SETTINGS_VIDEO_SEARCH_ADULT = 0 +_SETTINGS_MAX_RES = int(_addon.getSetting(_SETTINGS_ID_MAX_RES)) +_SETTINGS_VIDEO_SEARCH_SORT = int(_addon.getSetting(_SETTINGS_ID_VIDEO_SEARCH_SORT)) +_SETTINGS_VIDEO_SEARCH_HD = _SETTINGS_BOOL[_addon.getSetting(_SETTINGS_ID_VIDEO_SEARCH_HD)] +_SETTINGS_VIDEO_SEARCH_ADULT = _SETTINGS_INV_BOOL[_addon.getSetting(_SETTINGS_ID_VIDEO_SEARCH_ADULT)] _FILE_VIDEO_SEARCH_HISTORY = _ADDON_NAME + '_vsh.pkl' @@ -865,7 +874,7 @@ class KodiVk: item = xbmcgui.ListItem(name) xbmcplugin.addDirectoryItem(_addon_id, url, item, isFolder = True) def __connect_(self): - token = _addon.getSetting(_SETTINGS_TOKEN) + token = _addon.getSetting(_SETTINGS_ID_TOKEN) conn = Connection(_APP_ID, access_token = token) if not conn.conn._session.access_token: token = None @@ -876,7 +885,7 @@ class KodiVk: try: conn = Connection(_APP_ID, login, password, scope = _SCOPE) token = conn.conn._session.access_token - _addon.setSetting(_SETTINGS_TOKEN, token) + _addon.setSetting(_SETTINGS_ID_TOKEN, token) except vk.api.VkAuthError: continue return conn diff --git a/kodi-vk.inpos.ru/resources/language/English/strings.po b/kodi-vk.inpos.ru/resources/language/English/strings.po index 866d607..bce167d 100644 --- a/kodi-vk.inpos.ru/resources/language/English/strings.po +++ b/kodi-vk.inpos.ru/resources/language/English/strings.po @@ -72,6 +72,34 @@ msgctxt "#400516" msgid "New Search" msgstr "[B]New Search[/B]" +msgctxt "#400517" +msgid "Max video res" +msgstr "Max video resolution" + +msgctxt "#400518" +msgid "Sort video search results by" +msgstr "Sort video search results by" + +msgctxt "#400519" +msgid "v_search_sort_by_u_date" +msgstr "Upload date" + +msgctxt "#400520" +msgid "v_search_sort_by_duration" +msgstr "Duration" + +msgctxt "#400521" +msgid "v_search_sort_by_relevance" +msgstr "Relevance" + +msgctxt "#400522" +msgid "Search only HD video" +msgstr "Search only HD video" + +msgctxt "#400523" +msgid "Safe video search" +msgstr "Safe video search" + msgctxt "#400601" msgid "Previous page" msgstr "[B]Previous page[/B]" diff --git a/kodi-vk.inpos.ru/resources/language/Russian/strings.po b/kodi-vk.inpos.ru/resources/language/Russian/strings.po index 32cc581..ff54816 100644 --- a/kodi-vk.inpos.ru/resources/language/Russian/strings.po +++ b/kodi-vk.inpos.ru/resources/language/Russian/strings.po @@ -72,6 +72,34 @@ msgctxt "#400516" msgid "New Search" msgstr "[B]Новый поиск[/B]" +msgctxt "#400517" +msgid "Max video res" +msgstr "Макс. разрешение видео" + +msgctxt "#400518" +msgid "Sort video search results by" +msgstr "Сортировать резултаты поиска видео по" + +msgctxt "#400519" +msgid "v_search_sort_by_u_date" +msgstr "Дате добавления" + +msgctxt "#400520" +msgid "v_search_sort_by_duration" +msgstr "Длительности" + +msgctxt "#400521" +msgid "v_search_sort_by_relevance" +msgstr "Релевантности" + +msgctxt "#400522" +msgid "Search only HD video" +msgstr "Искать только HD-видео" + +msgctxt "#400523" +msgid "Safe video search" +msgstr "Безопасный поиск видеозаписей" + msgctxt "#400601" msgid "Previous page" msgstr "[B]Предыдущая страница[/B]" diff --git a/kodi-vk.inpos.ru/resources/settings.xml b/kodi-vk.inpos.ru/resources/settings.xml index 205233c..8f121e7 100644 --- a/kodi-vk.inpos.ru/resources/settings.xml +++ b/kodi-vk.inpos.ru/resources/settings.xml @@ -1,4 +1,8 @@ - + + + + + \ No newline at end of file