From f5ea8cc3ec8086ceaceca0d7fa8269af11d828e6 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 4 Aug 2018 15:11:21 +0200 Subject: [PATCH 1/2] Choose trailer if several are present (DB reset required) - Fixes #515 --- default.py | 12 +++++++++++- resources/lib/itemtypes.py | 6 +----- resources/lib/plex_api.py | 18 +++++++++++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/default.py b/default.py index 0539a838..e6c3e85d 100644 --- a/default.py +++ b/default.py @@ -6,7 +6,7 @@ import logging from sys import argv from urlparse import parse_qsl from xbmc import sleep, executebuiltin -from xbmcgui import ListItem +from xbmcgui import ListItem, getCurrentWindowId from xbmcplugin import setResolvedUrl from resources.lib import entrypoint, utils, pickler, pkc_listitem, \ @@ -69,6 +69,16 @@ class Main(): elif mode == 'channels': entrypoint.channels() + elif mode == 'route_to_extras': + # Hack so we can store this path in the Kodi DB + handle = ('plugin://%s?mode=extras&plex_id=%s' + % (v.ADDON_ID, params.get('plex_id'))) + if getCurrentWindowId() == 10025: + # Video Window + executebuiltin('Container.Update(\"%s\")' % handle) + else: + executebuiltin('ActivateWindow(videos, \"%s\")' % handle) + elif mode == 'extras': entrypoint.extras(plex_id=params.get('plex_id')) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 85867c68..17beb66f 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -207,11 +207,7 @@ class Movies(Items): studio = studios[0] except IndexError: studio = None - - trailer = api.trailer_id() - if trailer: - trailer = ('plugin://%s.movies/?plex_id=%s&plex_type=%s&mode=play' - % (v.ADDON_ID, trailer, v.PLEX_TYPE_CLIP)) + trailer = api.trailers() # GET THE FILE AND PATH ##### do_indirect = not state.DIRECT_PATHS diff --git a/resources/lib/plex_api.py b/resources/lib/plex_api.py index 0b4e6adf..e04d8ed7 100644 --- a/resources/lib/plex_api.py +++ b/resources/lib/plex_api.py @@ -728,10 +728,13 @@ class API(object): answ.append(extra) return answ - def trailer_id(self): + def trailers(self): """ - Returns the ratingKey (plex_id) of the trailer or None + Returns the URL for a single trailer, an addon path for extras + (route_to_extras) if several trailers are present. Or None """ + url = None + number = 0 for extras in self.item.iterfind('Extras'): for extra in extras: try: @@ -740,7 +743,16 @@ class API(object): typus = None if typus != 1: continue - return extra.get('ratingKey') + number += 1 + url = extra.get('ratingKey') + if number > 1: + # Several trailers present. Hence let the user choose + url = ('plugin://%s?mode=route_to_extras&plex_id=%s' + % (v.ADDON_ID, self.plex_id())) + elif url: + url = ('plugin://%s.movies/?plex_id=%s&plex_type=%s&mode=play' + % (v.ADDON_ID, url, v.PLEX_TYPE_CLIP)) + return url def mediastreams(self): """ From a46fc22fb2586c96ce163e991f86cf839a918830 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 4 Aug 2018 15:13:18 +0200 Subject: [PATCH 2/2] Beta and stable version bump 2.3.3 --- README.md | 4 ++-- addon.xml | 7 +++++-- changelog.txt | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6fa9d204..3d3d613a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![stable version](https://img.shields.io/badge/stable_version-2.3.2-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.3.2-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.3.3-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.3.3-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 453a4b36..dfd805b7 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -73,7 +73,10 @@ Нативна інтеграція Plex в Kodi Підключає Kodi до серверу Plex. Цей плагін передбачає, що ви керуєте всіма своїми відео за допомогою Plex (і ніяк не Kodi). Ви можете втратити дані, які вже зберігаються у відео та музичних БД Kodi (оскільки цей плагін безпосередньо їх змінює). Використовуйте на свій страх і ризик! Використовуйте на свій ризик - version 2.3.2: + version 2.3.3: +- Choose trailer if several are present (DB reset required) + +version 2.3.2: - Fix casting to PKC failing version 2.3.1: diff --git a/changelog.txt b/changelog.txt index 552a0c8c..a60abe8f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +version 2.3.3: +- Choose trailer if several are present (DB reset required) + version 2.3.2: - Fix casting to PKC failing