-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection and folder #275
base: develop
Are you sure you want to change the base?
Conversation
Hey, I've been testing this PR; it seems to fail reproducably. When entering an empty folder (in my case a "subs" folder that doesn't return any children whatsoever) inside a valid folder, then going back up again until the main library view is hit, then opening any item results in an empty view. |
OK, this is a pretty easy fix:
|
ee3a788
to
21dfc28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks and works great, just some minor comments, and it needs the below fix as reloading folders seems to break them (and is unnecessary in any case).
diff --git a/lib/_included_packages/plexnet/plexobjects.py b/lib/_included_packages/plexnet/plexobjects.py
index 12eeb76..1011037 100644
--- a/lib/_included_packages/plexnet/plexobjects.py
+++ b/lib/_included_packages/plexnet/plexobjects.py
@@ -123,6 +123,9 @@ class Checks:
def isDirectory(self):
return self.name == "Directory" or self.name == "Playlist"
+ def isFolder(self):
+ return '/folder?' in self.key
+
def isPhotoOrDirectoryItem(self):
return self.type == "photoalbum" # or self.isPhotoItem()
@@ -215,6 +218,9 @@ class PlexObject(object, Checks):
if _soft and self._reloaded:
return self
+ if self.isFolder():
+ return self
+
try:
if self.get('ratingKey'):
data = self.server.query('/library/metadata/{0}'.format(self.ratingKey), params=kwargs)
@@ -763,6 +763,7 @@ | |||
<onright>210</onright> | |||
<ondown>50</ondown> | |||
<control type="button" id="311"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
@@ -779,6 +780,7 @@ | |||
<label>[UPPERCASE]$INFO[Window.Property(filter2.display)][/UPPERCASE]</label> | |||
</control> | |||
<control type="button" id="211"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
@@ -826,6 +828,7 @@ | |||
<label>[UPPERCASE]$INFO[Window.Property(media.type)][/UPPERCASE]</label> | |||
</control> | |||
<control type="button" id="210"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
@@ -715,6 +715,7 @@ | |||
<onright>210</onright> | |||
<ondown>50</ondown> | |||
<control type="button" id="311"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
@@ -731,6 +732,7 @@ | |||
<label>[UPPERCASE]$INFO[Window.Property(filter2.display)][/UPPERCASE]</label> | |||
</control> | |||
<control type="button" id="211"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
@@ -778,6 +780,7 @@ | |||
<label>[UPPERCASE]$INFO[Window.Property(media.type)][/UPPERCASE]</label> | |||
</control> | |||
<control type="button" id="210"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
@@ -669,6 +669,7 @@ | |||
<onright>210</onright> | |||
<ondown>50</ondown> | |||
<control type="button" id="311"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
@@ -685,6 +686,7 @@ | |||
<label>[UPPERCASE]$INFO[Window.Property(filter2.display)][/UPPERCASE]</label> | |||
</control> | |||
<control type="button" id="211"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
@@ -732,6 +734,7 @@ | |||
<label>[UPPERCASE]$INFO[Window.Property(media.type)][/UPPERCASE]</label> | |||
</control> | |||
<control type="button" id="210"> | |||
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> | |
<visible>!String.IsEqual(Window.Property(media.itemType),folder)</visible> |
if datasource.isDirectory(): | ||
cls = self.section.__class__ | ||
section = cls(self.section.data, self.section.initpath, self.section.server, self.section.container) | ||
sectionId = section.key | ||
if not sectionId.isdigit(): | ||
sectionId = section.getLibrarySectionId() | ||
|
||
section.set('librarySectionID', sectionId) | ||
section.key = datasource.key | ||
section.title = datasource.title | ||
|
||
self.processCommand(opener.handleOpen(LibraryWindow, windows=self._windows, default_window=self._next, section=section, filter_=self.filter, subDir=True)) | ||
self.librarySettings.setItemType(self.librarySettings.getItemType()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified as below - it seemed to work fine with the change:
if datasource.isDirectory(): | |
cls = self.section.__class__ | |
section = cls(self.section.data, self.section.initpath, self.section.server, self.section.container) | |
sectionId = section.key | |
if not sectionId.isdigit(): | |
sectionId = section.getLibrarySectionId() | |
section.set('librarySectionID', sectionId) | |
section.key = datasource.key | |
section.title = datasource.title | |
self.processCommand(opener.handleOpen(LibraryWindow, windows=self._windows, default_window=self._next, section=section, filter_=self.filter, subDir=True)) | |
self.librarySettings.setItemType(self.librarySettings.getItemType()) | |
if datasource.isDirectory(): | |
cls = self.section.__class__ | |
section = cls(datasource.data, datasource.key, self.section.server, datasource.container) | |
sectionId = section.key if section.key.isdigit() else section.getLibrarySectionId() | |
section.set('librarySectionID', sectionId) | |
self.processCommand(opener.handleOpen(LibraryWindow, windows=self._windows, default_window=self._next, section=section, subDir=True)) | |
self.librarySettings.setItemType(self.librarySettings.getItemType()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the above, the section
's key
and title
are no longer set. It's been a long time since I've looked at this code but I think this had to do with entering a directory that was contained within a directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean. When you pass datasource.data
to the LibrarySection
constructor, the key and title are set to the key and title of the datasource.data
(which is the raw data that initialized datasource
). I tested it with a directory within a directory and it seemed to work fine (once the other folder reloading fix was added).
GHI (If applicable): None
Description:
Allow browsing movies by collection and by folder. Useful for a large movie library and a library where there is no metadata and items are arranged on the server by folder.
Checklist: