Skip to content

Commit

Permalink
Merge pull request #1866 from glensc/PlexGuidProviderMbid
Browse files Browse the repository at this point in the history
Add PlexGuidProviderMbid provider
  • Loading branch information
glensc authored Mar 17, 2024
2 parents e606832 + 75d8e97 commit c10f3aa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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

0 comments on commit c10f3aa

Please sign in to comment.