diff --git a/README.md b/README.md index b66adf8e..9ef65f2c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![stable version](https://img.shields.io/badge/stable_version-2.7.9-blue.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/stable/repository.plexkodiconnect/repository.plexkodiconnect-1.0.2.zip) -[![beta version](https://img.shields.io/badge/beta_version-2.7.9-red.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/beta/repository.plexkodiconnectbeta/repository.plexkodiconnectbeta-1.0.2.zip) +[![stable version](https://img.shields.io/badge/stable_version-2.7.10-blue.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/stable/repository.plexkodiconnect/repository.plexkodiconnect-1.0.2.zip) +[![beta version](https://img.shields.io/badge/beta_version-2.7.10-red.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/beta/repository.plexkodiconnectbeta/repository.plexkodiconnectbeta-1.0.2.zip) [![Installation](https://img.shields.io/badge/wiki-installation-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/Installation) [![FAQ](https://img.shields.io/badge/wiki-FAQ-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/faq) diff --git a/addon.xml b/addon.xml index 3d543290..9c9ad744 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -77,7 +77,13 @@ Нативна інтеграція Plex в Kodi Підключає Kodi до серверу Plex. Цей плагін передбачає, що ви керуєте всіма своїми відео за допомогою Plex (і ніяк не Kodi). Ви можете втратити дані, які вже зберігаються у відео та музичних БД Kodi (оскільки цей плагін безпосередньо їх змінює). Використовуйте на свій страх і ризик! Використовуйте на свій ризик - version 2.7.9: + version 2.7.10: +- Fix duplicate music entries for direct paths (you will need to manually reset the Kodi database +- Fix UnicodeEncodeError for Direct Paths and some PKC video nodes) +- Fix playback sometimes not being reported for direct paths +- Update translations + +version 2.7.9: - Wait for PKC to authorize before loading widgets - Fix UnicodeDecodeError for libraries with non-ASCII paths - Fix TypeError on Kodi start diff --git a/changelog.txt b/changelog.txt index e43ace09..7d2b621d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +version 2.7.10: +- Fix duplicate music entries for direct paths (you will need to manually reset the Kodi database +- Fix UnicodeEncodeError for Direct Paths and some PKC video nodes) +- Fix playback sometimes not being reported for direct paths +- Update translations + version 2.7.9: - Wait for PKC to authorize before loading widgets - Fix UnicodeDecodeError for libraries with non-ASCII paths diff --git a/resources/language/resource.language.cs_CZ/strings.po b/resources/language/resource.language.cs_CZ/strings.po index df1699db..c79b90b6 100644 --- a/resources/language/resource.language.cs_CZ/strings.po +++ b/resources/language/resource.language.cs_CZ/strings.po @@ -590,7 +590,7 @@ msgstr "" # PKC Settings - Sync Options msgctxt "#30524" msgid "Select Plex libraries to sync" -msgstr "" +msgstr "Zvolte knihovny Plexu k synchronizaci" # PKC Settings - Playback msgctxt "#30527" @@ -1249,7 +1249,7 @@ msgstr "Shlédnout později" # e.g. the PMS' name msgctxt "#39213" msgid "{0} offline" -msgstr "" +msgstr "{0} je offline" msgctxt "#39215" msgid "Enter your Plex Media Server's IP or URL, Examples are:" diff --git a/resources/lib/kodi_db/__init__.py b/resources/lib/kodi_db/__init__.py index 70e79bf9..052f7827 100644 --- a/resources/lib/kodi_db/__init__.py +++ b/resources/lib/kodi_db/__init__.py @@ -22,9 +22,14 @@ def kodiid_from_filename(path, kodi_type=None, db_type=None): """ kodi_id = None path = utils.try_decode(path) - path, filename = path_ops.path.split(path) # Make sure path ends in either '/' or '\' - path = path_ops.path.join(path, '') + # We CANNOT use path_ops.path.join as this can result in \ where we need / + try: + filename = path.rsplit('/', 1)[1] + path = path.rsplit('/', 1)[0] + '/' + except IndexError: + filename = path.rsplit('\\', 1)[1] + path = path.rsplit('\\', 1)[0] + '\\' if kodi_type == v.KODI_TYPE_SONG or db_type == 'music': with KodiMusicDB(lock=False) as kodidb: try: diff --git a/resources/lib/music.py b/resources/lib/music.py index 45b57001..ad102319 100644 --- a/resources/lib/music.py +++ b/resources/lib/music.py @@ -8,7 +8,7 @@ from . import utils from . import variables as v ############################################################################### -LOG = getLogger('PLEX.music') +LOG = getLogger('PLEX.music.py') ############################################################################### @@ -25,7 +25,7 @@ def excludefromscan_music_folders(sections): reboot = False api = API(item=None) for section in sections: - if section.plex_type != v.PLEX_TYPE_ARTIST: + if section.section_type != v.PLEX_TYPE_ARTIST: # Only look at music libraries continue if not section.sync_to_kodi: diff --git a/resources/lib/plex_api.py b/resources/lib/plex_api.py index 370a62ba..8d40824b 100644 --- a/resources/lib/plex_api.py +++ b/resources/lib/plex_api.py @@ -152,9 +152,9 @@ class API(object): def directory_path(self, section_id=None, plex_type=None, old_key=None, synched=True): - key = self.item.get('fastKey') + key = cast(unicode, self.item.get('fastKey')) if not key: - key = self.item.get('key') + key = cast(unicode, self.item.get('key')) if old_key: key = '%s/%s' % (old_key, key) elif not key.startswith('/'): @@ -169,10 +169,10 @@ class API(object): params['synched'] = 'false' if self.item.get('prompt'): # User input needed, e.g. search for a movie or episode - params['prompt'] = self.item.get('prompt') + params['prompt'] = cast(unicode, self.item.get('prompt')) if section_id: params['id'] = section_id - return 'plugin://%s/?%s' % (v.ADDON_ID, urlencode(params)) + return utils.extend_url('plugin://%s/' % v.ADDON_ID, params) def path_and_plex_id(self): """ diff --git a/resources/lib/utils.py b/resources/lib/utils.py index a54997bd..06c09229 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -9,6 +9,7 @@ from sqlite3 import connect, OperationalError from datetime import datetime from unicodedata import normalize from threading import Lock +import urllib # Originally tried faster cElementTree, but does NOT work reliably with Kodi import xml.etree.ElementTree as etree import defusedxml.ElementTree as defused_etree # etree parse unsafe @@ -269,26 +270,59 @@ def cast(func, value): func (func): Calback function to used cast to type (int, bool, float). value (any): value to be cast and returned. """ - if value is not None: - if func == bool: - return bool(int(value)) - elif func == unicode: - if isinstance(value, (int, long, float)): - return unicode(value) - else: - return value.decode('utf-8') - elif func == str: - if isinstance(value, (int, long, float)): - return str(value) - else: - return value.encode('utf-8') - elif func in (int, float): - try: - return func(value) - except ValueError: - return float('nan') - return func(value) - return value + if value is None: + return value + elif func == bool: + return bool(int(value)) + elif func == unicode: + if isinstance(value, (int, long, float)): + return unicode(value) + elif isinstance(value, unicode): + return value + else: + return value.decode('utf-8') + elif func == str: + if isinstance(value, (int, long, float)): + return str(value) + elif isinstance(value, str): + return value + else: + return value.encode('utf-8') + elif func in (int, float): + try: + return func(value) + except ValueError: + return float('nan') + return func(value) + + +def extend_url(url, params): + """ + Pass in an url [unicode] and params [dict]. Returns the extended url + '' + in unicode + """ + params = encode_dict(params) if params else {} + params = urllib.urlencode(params).decode('utf-8') + if '?' in url: + return '%s&%s' % (url, params) + else: + return '%s?%s' % (url, params) + + +def encode_dict(dictionary): + """ + Pass in a dict. Will return the same dict with all keys and values encoded + in utf-8 - as long as they are unicode. Ignores all non-unicode entries + + Useful for urllib.urlencode or urllib.(un)quote + """ + for key, value in dictionary.iteritems(): + if isinstance(key, unicode): + dictionary[key.encode('utf-8')] = dictionary.pop(key) + if isinstance(value, unicode): + dictionary[key] = value.encode('utf-8') + return dictionary def try_encode(input_str, encoding='utf-8'):