python-plexapi icon indicating copy to clipboard operation
python-plexapi copied to clipboard

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

Open glensc opened this issue 2 years ago • 7 comments

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

  • [x] Movie
  • [x] Episode
  • [ ] Track
  • [ ] Photo.

Type of change

Please delete options that are not relevant.

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

Checklist:

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

glensc avatar Jan 08 '24 02:01 glensc

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"
 ]

glensc avatar Jan 08 '24 02:01 glensc

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
  • https://github.com/pkkid/python-plexapi/actions/runs/7442362354/job/20245688665?pr=1335#step:12:793

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

  • https://github.com/pkkid/python-plexapi/pull/1185

glensc avatar Jan 08 '24 19:01 glensc

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?

JonnyWong16 avatar Jan 08 '24 22:01 JonnyWong16

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

glensc avatar Jan 09 '24 12:01 glensc

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.

JonnyWong16 avatar Jan 09 '24 18:01 JonnyWong16

Added to Track c4c2d03 and Photo b439ea8

glensc avatar Jan 14 '24 21:01 glensc

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

glensc avatar Jan 14 '24 21:01 glensc

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

References:

https://github.com/pkkid/python-plexapi/blob/b51aa1924b5b28ba61aefbb4162aff6e6864561b/plexapi/server.py#L172-L173

https://github.com/pkkid/python-plexapi/blob/b51aa1924b5b28ba61aefbb4162aff6e6864561b/plexapi/playqueue.py#L27

JonnyWong16 avatar Feb 10 '24 17:02 JonnyWong16

Updated: 3d7fd9e215861715d871c81cc80fca100be97462

glensc avatar Feb 11 '24 16:02 glensc

no longer breaking change label

glensc avatar Feb 11 '24 16:02 glensc