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 __rich__ method to PlexLibraryItem #660

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions plextraktsync/plex_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ def __repr__(self):
except IndexError:
return f"<{self.item}>"

def __rich__(self) -> str:
guid = self.guids[0]
url = self.plex.media_url(self)

return f"<[link={url}]{guid.provider}:{guid.id}:{self.item}[/link]>"

def to_json(self):
metadata = {
"collected_at": timestamp(self.collected_at),
Expand Down Expand Up @@ -431,7 +437,7 @@ def movie_sections(self, library=None):
continue
if library and section.title != library:
continue
result.append(PlexLibrarySection(section))
result.append(PlexLibrarySection(section, plex=self))

return result

Expand All @@ -442,7 +448,7 @@ def show_sections(self, library=None):
continue
if library and section.title != library:
continue
result.append(PlexLibrarySection(section))
result.append(PlexLibrarySection(section, plex=self))

return result

Expand Down
4 changes: 2 additions & 2 deletions plextraktsync/walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def get_plex_episodes(self, episodes):
show = self.mf.resolve_guid(guid)
if not show:
continue
me = self.mf.resolve_any(PlexLibraryItem(pe), show.trakt)
me = self.mf.resolve_any(PlexLibraryItem(pe, plex=self.plex), show.trakt)
if not me:
continue

Expand All @@ -275,7 +275,7 @@ def media_from_sections(self, sections: List[PlexLibrarySection], titles: List[s
def media_from_items(self, libtype: str, items: List):
it = self.progressbar(items, desc=f"Processing {libtype}s")
for m in it:
yield PlexLibraryItem(m)
yield PlexLibraryItem(m, plex=self.plex)

@deprecated("No longer used")
def media_from_titles(self, libtype: str, titles: List[str]):
Expand Down