Skip to content

Commit

Permalink
Merge pull request #1700 from glensc/urls
Browse files Browse the repository at this point in the history
Refactor: Add web_url, discover_url properties to PlexLibraryItem
  • Loading branch information
glensc authored Jan 6, 2024
2 parents 698d76d + 4c827fd commit 6f3e0c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 3 additions & 6 deletions plextraktsync/commands/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ def inspect_media(plex_id: PlexId):
if pm.library:
print(f"Library: {pm.library.title}")

url = plex.media_url(pm)
print(f"Plex Web URL: {url}")

if not pm.is_discover and not pm.is_legacy_agent:
url = plex.media_url(pm, discover=True)
print(f"Discover URL: {url}")
print(f"Plex Web URL: {pm.web_url}")
if pm.discover_url:
print(f"Discover URL: {pm.discover_url}")

media = pm.item
print(f"Title: {media.title}")
Expand Down
11 changes: 11 additions & 0 deletions plextraktsync/plex/PlexLibraryItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ def is_discover(self):
# https://github.com/pkkid/python-plexapi/pull/1093
return self.item.__dict__["librarySectionID"] is None

@property
def web_url(self):
return self.plex.media_url(self)

@property
def discover_url(self):
if not self.is_discover and not self.is_legacy_agent:
return self.plex.media_url(self, discover=True)

return None

@retry()
def get_guids(self):
return self.item.guids
Expand Down

0 comments on commit 6f3e0c6

Please sign in to comment.