Plex searcher extended to include also audio tracks

This commit is contained in:
Fabio Manganiello 2021-12-04 00:08:47 +01:00
parent 46d8d575ba
commit 2560bfa03f
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -349,6 +349,7 @@ class MediaPlexPlugin(Plugin):
return self.client(client).pageUp() return self.client(client).pageUp()
def _flatten_item(self, item): def _flatten_item(self, item):
from plexapi.audio import Track
from plexapi.video import Movie, Show from plexapi.video import Movie, Show
_item = { _item = {
@ -383,6 +384,7 @@ class MediaPlexPlugin(Plugin):
'parts': [ 'parts': [
{ {
'file': part.file, 'file': part.file,
'size': part.size,
'duration': (part.duration or 0) / 1000, 'duration': (part.duration or 0) / 1000,
'url': self.plex.url(part.key) + '?' + urllib.parse.urlencode({ 'url': self.plex.url(part.key) + '?' + urllib.parse.urlencode({
'X-Plex-Token': self.plex._token, 'X-Plex-Token': self.plex._token,
@ -423,6 +425,7 @@ class MediaPlexPlugin(Plugin):
'parts': [ 'parts': [
{ {
'file': part.file, 'file': part.file,
'size': part.size,
'duration': part.duration / 1000, 'duration': part.duration / 1000,
'url': self.plex.url(part.key) + '?' + urllib.parse.urlencode({ 'url': self.plex.url(part.key) + '?' + urllib.parse.urlencode({
'X-Plex-Token': self.plex._token, 'X-Plex-Token': self.plex._token,
@ -436,6 +439,44 @@ class MediaPlexPlugin(Plugin):
} for season in item.seasons() } for season in item.seasons()
] ]
elif isinstance(item, Track):
_item.update({
'artist': item.grandparentTitle,
'album': item.parentTitle,
'title': item.title,
'name': item.title,
'duration': item.duration / 1000.,
'index': item.index,
'track_number': item.trackNumber,
'year': item.year,
'locations': [item.locations],
})
_item['media'] = [
{
'title': media.title,
'duration': media.duration / 1000.,
'bitrate': media.bitrate,
'width': media.width,
'height': media.height,
'audio_channels': media.audioChannels,
'audio_codec': media.audioCodec,
'video_codec': media.videoCodec,
'video_resolution': media.videoResolution,
'video_frame_rate': media.videoFrameRate,
'parts': [
{
'file': part.file,
'duration': part.duration / 1000,
'size': part.size,
'url': self.plex.url(part.key) + '?' + urllib.parse.urlencode({
'X-Plex-Token': self.plex._token,
}),
} for part in media.parts
]
} for media in item.media
]
return _item return _item