Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuk committed May 5, 2018
2 parents 0659011 + 20c28f0 commit 457b060
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 55 deletions.
4 changes: 2 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.plex"
name="Plex"
version="0.1.4"
version="0.1.5"
provider-name="Plex">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
Expand All @@ -13,7 +13,7 @@
<extension point="xbmc.python.pluginsource" library="plugin.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.service" library="service.py" start="login"></extension>
<extension point="xbmc.service" library="service.py" start="startup"></extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Plex for Kodi</summary>
<summary lang="de">Plex für Kodi</summary>
Expand Down
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[- 0.1.5 -]

Allow direct playback of episodes and movies using the play button on hub screen (thanks to pannal)
In progress watched items had the 'Mark unwatched' option instead of 'Mark watched'
Fix an issue causing the home window to start slightly scrolled down if it was closed scolled down
Fix an issue causing an error when sort was sort was "BY UNWATCHED" and the filtering "UNWATCHED" (Issue #187)
Fix issue with letter shortcuts sometimes being shown/not shown incorrectly
Fix a bug causing crash and reboot on startup on Raspberry Pi (LibreElec specific?) - Reverts "Fix autostart to work with profiles"

[- 0.1.4 -]

Kodi v18: Fix skin compatability issues
Expand Down
6 changes: 5 additions & 1 deletion lib/_included_packages/plexnet/plexlibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ def jumpList(self, filter_=None, sort=None, unwatched=False, type_=None):
if args:
path += util.joinArgs(args)

return plexobjects.listItems(self.server, path, bytag=True)
try:
return plexobjects.listItems(self.server, path, bytag=True)
except exceptions.BadRequest:
util.ERROR('jumpList() request error for path: {0}'.format(repr(path)))
return None

@property
def onDeck(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/windows/episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def optionsButtonClicked(self, from_item=False):
if len(mli.dataSource.media) > 1:
options.append({'key': 'play_version', 'display': T(32451, 'Play Version...')})

if mli.dataSource.isWatched:
if mli.dataSource.isWatched and not mli.dataSource.viewOffset.asInt():
options.append({'key': 'mark_unwatched', 'display': T(32318, 'Mark Unwatched')})
else:
options.append({'key': 'mark_watched', 'display': T(32319, 'Mark Watched')})
Expand Down
14 changes: 10 additions & 4 deletions lib/windows/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ def __init__(self, *args, **kwargs):
self.updateHubs = {}
windowutils.HOME = self

util.setGlobalBoolProperty('off.sections', '')

def onFirstInit(self):
self.sectionList = kodigui.ManagedControlList(self, self.SECTION_LIST_ID, 7)
self.serverList = kodigui.ManagedControlList(self, self.SERVER_LIST_ID, 10)
Expand Down Expand Up @@ -420,8 +422,12 @@ def onAction(self, action):
self.setFocusId(self.SERVER_BUTTON_ID)
elif controlID == self.PLAYER_STATUS_BUTTON_ID and action == xbmcgui.ACTION_MOVE_RIGHT:
self.setFocusId(self.SERVER_BUTTON_ID)
elif 399 < controlID < 500 and action.getId() in MOVE_SET:
self.checkHubItem(controlID)
elif 399 < controlID < 500:
if action.getId() in MOVE_SET:
self.checkHubItem(controlID)
elif action.getId() == xbmcgui.ACTION_PLAYER_PLAY:
self.hubItemClicked(controlID, auto_play=True)
return

if action in(xbmcgui.ACTION_NAV_BACK, xbmcgui.ACTION_CONTEXT_MENU):
if not xbmc.getCondVisibility('ControlGroup({0}).HasFocus(0)'.format(self.OPTIONS_GROUP_ID)) and self.getProperty('off.sections'):
Expand Down Expand Up @@ -517,7 +523,7 @@ def serverRefresh(self):
self.showHubs(HomeSection)
return True

def hubItemClicked(self, hubControlID):
def hubItemClicked(self, hubControlID, auto_play=False):
control = self.hubControls[hubControlID - 400]
mli = control.getSelectedItem()
if not mli:
Expand All @@ -526,7 +532,7 @@ def hubItemClicked(self, hubControlID):
if mli.dataSource is None:
return

command = opener.open(mli.dataSource)
command = opener.open(mli.dataSource, auto_play=auto_play)

self.updateListItem(mli)

Expand Down
33 changes: 22 additions & 11 deletions lib/windows/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def __init__(self, *args, **kwargs):
self.lock = threading.Lock()

def reset(self):
util.setGlobalProperty('sort', '')
self.filterUnwatched = self.librarySettings.getSetting('filter.unwatched', False)
if ITEM_TYPE == 'episode':
self.sort = self.librarySettings.getSetting('sort', 'show.titleSort')
Expand Down Expand Up @@ -469,7 +470,7 @@ def onFirstInit(self):
self.keyListControl = kodigui.ManagedControlList(self, self.KEY_LIST_ID, 27)
self.setProperty('no.options', self.section.TYPE != 'photodirectory' and '1' or '')
self.setProperty('unwatched.hascount', self.section.TYPE == 'show' and '1' or '')
self.setProperty('sort', self.sort)
util.setGlobalProperty('sort', self.sort)
self.setProperty('filter1.display', self.filterUnwatched and T(32368, 'UNWATCHED') or T(32345, 'All'))
self.setProperty('sort.display', SORT_KEYS[self.section.TYPE].get(self.sort, SORT_KEYS['movie'].get(self.sort))['title'])
self.setProperty('media.type', TYPE_PLURAL.get(ITEM_TYPE or self.section.TYPE, self.section.TYPE))
Expand Down Expand Up @@ -648,7 +649,7 @@ def updateKey(self, mli=None):
self.lastItem = mli
self.onItemChanged(mli)

self.setProperty('key', mli.getProperty('key'))
util.setGlobalProperty('key', mli.getProperty('key'))

self.selectKey(mli)

Expand Down Expand Up @@ -810,7 +811,7 @@ def keyClicked(self):

self.showPanelControl.selectItem(pos)
self.setFocusId(self.POSTERS_PANEL_ID)
self.setProperty('key', li.dataSource)
util.setGlobalProperty('key', li.dataSource)

def playButtonClicked(self, shuffle=False):
filter_ = self.getFilterOpts()
Expand Down Expand Up @@ -955,20 +956,23 @@ def sortButtonClicked(self):

choice = result['type']

forceRefresh = False
if choice == self.sort:
self.sortDesc = not self.sortDesc
else:
self.sortDesc = False
if choice == 'titleSort':
forceRefresh = True

self.sort = choice

self.librarySettings.setSetting('sort', self.sort)
self.librarySettings.setSetting('sort.desc', self.sortDesc)

self.setProperty('sort', choice)
util.setGlobalProperty('sort', choice)
self.setProperty('sort.display', result['title'])

self.sortShowPanel(choice)
self.sortShowPanel(choice, forceRefresh)

def viewTypeButtonClicked(self):
with self.lock:
Expand All @@ -980,8 +984,8 @@ def viewTypeButtonClicked(self):
key = self.section.getLibrarySectionId()
util.setSetting('viewtype.{0}.{1}'.format(self.section.server.uuid, key), win.VIEWTYPE)

def sortShowPanel(self, choice):
if self.chunkMode:
def sortShowPanel(self, choice, force_refresh=False):
if force_refresh or self.chunkMode or self.showPanelControl.size() == 0:
self.fillShows()
return

Expand Down Expand Up @@ -1127,7 +1131,7 @@ def resetSort(self):
self.librarySettings.setSetting('sort', self.sort)
self.librarySettings.setSetting('sort.desc', self.sortDesc)

self.setProperty('sort', self.sort)
util.setGlobalProperty('sort', self.sort)
self.setProperty('sort.display', SORT_KEYS[self.section.TYPE].get(self.sort, SORT_KEYS['movie'].get(self.sort))['title'])

def updateFilterDisplay(self):
Expand Down Expand Up @@ -1261,7 +1265,7 @@ def fillShows(self):
idx = 0
fallback = 'script.plex/thumb_fallbacks/{0}.png'.format(TYPE_KEYS.get(self.section.type, TYPE_KEYS['movie'])['fallback'])

if self.filter:
if self.sort != 'titleSort':
sectionAll = self.section.all(0, 0, filter_=self.getFilterOpts(), sort=self.getSortOpts(), unwatched=self.filterUnwatched, type_=type_)
totalSize = sectionAll.totalSize.asInt()
if not self.chunkMode:
Expand All @@ -1274,10 +1278,17 @@ def fillShows(self):
jumpList = self.section.jumpList(filter_=self.getFilterOpts(), sort=self.getSortOpts(), unwatched=self.filterUnwatched, type_=type_)

if not jumpList:
self.showPanelControl.reset()
self.keyListControl.reset()

if self.filter or self.filterUnwatched:
self.setBoolProperty('no.content.filtered', True)
else:
self.setBoolProperty('no.content', True)

if jumpList is None:
util.messageDialog("Error", "There was an error.")

return

for kidx, ji in enumerate(jumpList):
Expand All @@ -1302,7 +1313,7 @@ def fillShows(self):
self.firstOfKeyItems[ji.key] = mli
idx += 1

self.setProperty('key', jumpList[0].key)
util.setGlobalProperty('key', jumpList[0].key)

if self.scrollBar:
self.scrollBar.setSizeAndCount(totalSize, 12)
Expand Down Expand Up @@ -1453,7 +1464,7 @@ def fillPhotos(self):
self.keyListControl.addItems(litems)

if keys:
self.setProperty('key', keys[0])
util.setGlobalProperty('key', keys[0])

def chunkCallback(self, items, start, clear=False):
if clear:
Expand Down
12 changes: 7 additions & 5 deletions lib/windows/opener.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from lib import util


def open(obj):
def open(obj, auto_play=False):
if isinstance(obj, playqueue.PlayQueue):
if busy.widthDialog(obj.waitForInitialization, None):
if obj.type == 'audio':
Expand All @@ -23,9 +23,11 @@ def open(obj):
key = '/library/metadata/{0}'.format(obj)
return open(plexapp.SERVERMANAGER.selectedServer.getObject(key))
elif obj.TYPE == 'episode':
return episodeClicked(obj)
if not auto_play:
return episodeClicked(obj)
return playableClicked(obj, auto_play=auto_play)
elif obj.TYPE == 'movie':
return playableClicked(obj)
return playableClicked(obj, auto_play=auto_play)
elif obj.TYPE in ('show'):
return showClicked(obj)
elif obj.TYPE in ('artist'):
Expand Down Expand Up @@ -67,9 +69,9 @@ def handleOpen(winclass, **kwargs):
return ''


def playableClicked(playable):
def playableClicked(playable, auto_play=False):
import preplay
return handleOpen(preplay.PrePlayWindow, video=playable)
return handleOpen(preplay.PrePlayWindow, video=playable, auto_play=auto_play)


def episodeClicked(episode):
Expand Down
7 changes: 6 additions & 1 deletion lib/windows/preplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class PrePlayWindow(kodigui.ControlledWindow, windowutils.UtilMixin):
def __init__(self, *args, **kwargs):
kodigui.ControlledWindow.__init__(self, *args, **kwargs)
self.video = kwargs.get('video')
self.auto_play = kwargs.get('auto_play')
self.parentList = kwargs.get('parent_list')
self.videos = None
self.exitCommand = None
Expand All @@ -71,6 +72,10 @@ def onFirstInit(self):
self.progressImageControl = self.getControl(self.PROGRESS_IMAGE_ID)
self.setup()

if self.auto_play:
self.auto_play = False
self.playVideo()

def onReInit(self):
self.video.reload()
self.refreshInfo()
Expand Down Expand Up @@ -178,7 +183,7 @@ def optionsButtonClicked(self):
if len(self.video.media) > 1:
options.append({'key': 'play_version', 'display': T(32451, 'Play Version...')})

if self.video.isWatched:
if self.video.isWatched and not self.video.viewOffset.asInt():
options.append({'key': 'mark_unwatched', 'display': T(32318, 'Mark Unwatched')})
else:
options.append({'key': 'mark_watched', 'display': T(32319, 'Mark Watched')})
Expand Down
10 changes: 5 additions & 5 deletions resources/skins/Main/1080i/script-plex-listview-16x9-chunked.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
</control>

<control type="group" id="150">
<visible>StringCompare(Window.Property(sort),titleSort) + Integer.IsGreater(Container(101).NumItems,0) + String.IsEmpty(Window.Property(drawing))</visible>
<visible>StringCompare(Window(10000).Property(script.plex.sort),titleSort) + Integer.IsGreater(Container(101).NumItems,0) + String.IsEmpty(Window.Property(drawing))</visible>
<defaultcontrol>151</defaultcontrol>
<posx>1830</posx>
<posy>150</posy>
Expand All @@ -492,7 +492,7 @@
<posx>0</posx>
<posy>0</posy>
<control type="label">
<visible>!StringCompare(Window.Property(key), ListItem.Property(letter))</visible>
<visible>!StringCompare(Window(10000).Property(script.plex.key), ListItem.Property(letter))</visible>
<posx>0</posx>
<posy>0</posy>
<width>34</width>
Expand All @@ -504,7 +504,7 @@
<label>$INFO[ListItem.Label]</label>
</control>
<control type="group">
<visible>StringCompare(Window.Property(key), ListItem.Property(key))</visible>
<visible>StringCompare(Window(10000).Property(script.plex.key), ListItem.Property(key))</visible>
<control type="image">
<posx>0</posx>
<posy>0</posy>
Expand Down Expand Up @@ -538,7 +538,7 @@
<posx>0</posx>
<posy>0</posy>
<control type="label">
<visible>!StringCompare(Window.Property(key), ListItem.Property(letter))</visible>
<visible>!StringCompare(Window(10000).Property(script.plex.key), ListItem.Property(letter))</visible>
<posx>0</posx>
<posy>0</posy>
<width>34</width>
Expand All @@ -550,7 +550,7 @@
<label>$INFO[ListItem.Label]</label>
</control>
<control type="group">
<visible>StringCompare(Window.Property(key), ListItem.Property(key))</visible>
<visible>StringCompare(Window(10000).Property(script.plex.key), ListItem.Property(key))</visible>
<control type="image">
<posx>0</posx>
<posy>0</posy>
Expand Down
10 changes: 5 additions & 5 deletions resources/skins/Main/1080i/script-plex-listview-16x9.xml
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
</control>

<control type="group" id="150">
<visible>StringCompare(Window.Property(sort),titleSort) + Integer.IsGreater(Container(101).NumItems,0) + String.IsEmpty(Window.Property(drawing))</visible>
<visible>StringCompare(Window(10000).Property(script.plex.sort),titleSort) + Integer.IsGreater(Container(101).NumItems,0) + String.IsEmpty(Window.Property(drawing))</visible>
<defaultcontrol>151</defaultcontrol>
<posx>1830</posx>
<posy>150</posy>
Expand All @@ -444,7 +444,7 @@
<posx>0</posx>
<posy>0</posy>
<control type="label">
<visible>!StringCompare(Window.Property(key), ListItem.Property(letter))</visible>
<visible>!StringCompare(Window(10000).Property(script.plex.key), ListItem.Property(letter))</visible>
<posx>0</posx>
<posy>0</posy>
<width>34</width>
Expand All @@ -456,7 +456,7 @@
<label>$INFO[ListItem.Label]</label>
</control>
<control type="group">
<visible>StringCompare(Window.Property(key), ListItem.Property(key))</visible>
<visible>StringCompare(Window(10000).Property(script.plex.key), ListItem.Property(key))</visible>
<control type="image">
<posx>0</posx>
<posy>0</posy>
Expand Down Expand Up @@ -490,7 +490,7 @@
<posx>0</posx>
<posy>0</posy>
<control type="label">
<visible>!StringCompare(Window.Property(key), ListItem.Property(letter))</visible>
<visible>!StringCompare(Window(10000).Property(script.plex.key), ListItem.Property(letter))</visible>
<posx>0</posx>
<posy>0</posy>
<width>34</width>
Expand All @@ -502,7 +502,7 @@
<label>$INFO[ListItem.Label]</label>
</control>
<control type="group">
<visible>StringCompare(Window.Property(key), ListItem.Property(key))</visible>
<visible>StringCompare(Window(10000).Property(script.plex.key), ListItem.Property(key))</visible>
<control type="image">
<posx>0</posx>
<posy>0</posy>
Expand Down
Loading

0 comments on commit 457b060

Please sign in to comment.