Skip to content
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

Feature: Add source property to playlist items to support remote playlist entries #1335

Merged
merged 11 commits into from
Feb 17, 2024

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Jan 8, 2024

Description

A Playlist entry if added a remote server item has field "source" initialized with value like server://<server_id>/com.plexapp.plugins.library

The source attribute should be on

  • Movie
  • Episode
  • Track
  • Photo.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring for new or existing methods
  • I have added tests when applicable

A Playlist entry if added a remote server item has field "source" initialized with value like `server://<server_id>/com.plexapp.plugins.library`
@glensc
Copy link
Contributor Author

glensc commented Jan 8, 2024

here's diff of keys local vs remote playlist entries. i guess some fields like titleSort rather vary on whether item has sort title set.

--- pl-local-keys.json    2024-01-08 03:38:13
+++ pl-remote-keys.json    2024-01-08 03:38:28
@@ -6,17 +6,17 @@
   "duration",
   "guid",
   "key",
-  "librarySectionID", // local
-  "librarySectionKey", // local
-  "librarySectionTitle", // local
+  "originalTitle", // remote
   "originallyAvailableAt",
   "playlistItemID",
   "ratingKey",
+  "source", // remote
   "studio",
   "summary",
+  "tagline", // remote
   "thumb",
   "title",
+  "titleSort", // remote
   "type",
-  "updatedAt", // local
   "year"
 ]

E261 at least two spaces before inline comment
@glensc glensc changed the title Feature: Add source property to Video Feature: Add source property to Video/Episode Jan 8, 2024
@glensc glensc changed the title Feature: Add source property to Video/Episode Feature: Add source property to Video/Episode to support remote playlist entries Jan 8, 2024
@glensc
Copy link
Contributor Author

glensc commented Jan 8, 2024

This is unforunate, this seems to conflict with History object:

  File "/home/runner/work/python-plexapi/python-plexapi/tests/test_history.py", line 93, in test_history_PlexHistory
    assert hist.source() == movie
TypeError: 'NoneType' object is not callable

as apparently History extends from Movie object (class MovieHistory(PlexHistory, Movie):

@glensc glensc marked this pull request as draft January 8, 2024 19:30
@glensc glensc mentioned this pull request Jan 8, 2024
7 tasks
@JonnyWong16
Copy link
Collaborator

What is a "remote playlist entry"? Do you mean on someone else's server? What is the Plex URL endpoint where we can see this source attribute?

@glensc
Copy link
Contributor Author

glensc commented Jan 9, 2024

Remote playlist is when you add item to playlist, but choose different server.

image

This seems to be available only when I'm on server that I don't own, and have at least one server that I own.

the source attribute is seen with the existing get playlist api call:

        p = server.playlist("Playlist Name")
        source = p._data.attrib.get("source")

so, http://localhost:32400/playlists/<ratingKey>/items

@JonnyWong16
Copy link
Collaborator

The source attribute should be on Movie, Episode, Track, and Photo.

I need to think about what to do about the conflicting PlexSession.source() and PlexHistory.source() methods.

@glensc glensc changed the title Feature: Add source property to Video/Episode to support remote playlist entries Feature: Add source property to playlist items to support remote playlist entries Jan 9, 2024
@glensc
Copy link
Contributor Author

glensc commented Jan 14, 2024

Added to Track c4c2d03 and Photo b439ea8

@glensc
Copy link
Contributor Author

glensc commented Jan 14, 2024

maybe add this new property with the name "remote_source"?

@JonnyWong16
Copy link
Collaborator

I think we name the attribute sourceURI and don't change the methods.

References:

def _uriRoot(self):
return f'server://{self.machineIdentifier}/com.plexapp.plugins.library'

playQueueSourceURI (str): Original URI used to create the PlayQueue.

@glensc
Copy link
Contributor Author

glensc commented Feb 11, 2024

Updated: 3d7fd9e

@glensc glensc marked this pull request as ready for review February 11, 2024 16:23
plexapi/audio.py Outdated Show resolved Hide resolved
plexapi/photo.py Outdated Show resolved Hide resolved
plexapi/video.py Outdated Show resolved Hide resolved
plexapi/video.py Outdated Show resolved Hide resolved
glensc and others added 4 commits February 11, 2024 18:55
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
@glensc
Copy link
Contributor Author

glensc commented Feb 11, 2024

no longer breaking change label

@JonnyWong16 JonnyWong16 merged commit 9d9dca8 into pkkid:master Feb 17, 2024
5 checks passed
@glensc glensc deleted the patch-3 branch February 18, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants