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

Add PlexGuidProviderMbid provider #1866

Merged
merged 3 commits into from
Mar 17, 2024
Merged
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
3 changes: 3 additions & 0 deletions plextraktsync/plex/PlexGuidProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from plextraktsync.plex.PlexGuidProviderIMDB import PlexGuidProviderIMDB
from plextraktsync.plex.PlexGuidProviderLocal import PlexGuidProviderLocal
from plextraktsync.plex.PlexGuidProviderMbid import PlexGuidProviderMbid
from plextraktsync.plex.PlexGuidProviderTMDB import PlexGuidProviderTMDB
from plextraktsync.plex.PlexGuidProviderTVDB import PlexGuidProviderTVDB

Expand All @@ -20,6 +21,8 @@ def create(cls, guid: PlexGuid):
return PlexGuidProviderTMDB(guid)
if guid.provider == "tvdb":
return PlexGuidProviderTVDB(guid)
if guid.provider == "mbid":
return PlexGuidProviderMbid(guid)
if guid.provider in ["local", "none"]:
return PlexGuidProviderLocal(guid)

Expand Down
22 changes: 22 additions & 0 deletions plextraktsync/plex/PlexGuidProviderMbid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from plextraktsync.plex.PlexGuid import PlexGuid


class PlexGuidProviderMbid:
def __init__(self, guid: PlexGuid):
self.guid = guid

@property
def link(self):
if self.guid.type == "artist":
return f"https://musicbrainz.org/artist/{self.guid.id}"
if self.guid.type == "album":
return f"https://musicbrainz.org/release/{self.guid.id}"

@property
def title(self):
return f"{self.guid.provider}:{self.guid.type}:{self.guid.id}"
2 changes: 1 addition & 1 deletion plextraktsync/plex/PlexLibraryItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def title(self):
if self.type == "episode":
value = f"{self.item.grandparentTitle}/{self.item.seasonEpisode}/{value}"

if self.item.year:
if self.type != "artist" and self.item.year:
value = f"{value} ({self.item.year})"

return value
Expand Down
Loading