From f2bc4a6724c7fa0c2b174e578a3ed96fb2a57da9 Mon Sep 17 00:00:00 2001 From: KOL Date: Wed, 11 Mar 2015 01:27:14 +0300 Subject: [PATCH] - Fix DLNA Music container --- Contents/Code/__init__.py | 27 ++++++++++++++++++++++++++- Contents/Info.plist | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 0f07ba1..61bb792 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -375,6 +375,20 @@ def MusicList(uid, title, album_id=None, offset=0): return oc +@route(PREFIX_M + '/play') +def MusicPlay(info): + + item = JSON.ObjectFromString(info) + + if not item: + raise Ex.MediaNotAvailable + + return ObjectContainer( + objects=[GetTrackObject(item)], + content=ContainerContent.Tracks + ) + + def AddMusicAlbums(oc, uid, offset=0): albums = ApiRequest('audio.getAlbums', { @@ -426,9 +440,10 @@ def AddMusicAlbums(oc, uid, offset=0): return oc + def GetTrackObject(item): return TrackObject( - key=item['url'], + key=Callback(MusicPlay, info=JSON.StringFromObject(item)), # rating_key='%s.%s' % (Plugin.Identifier, item['id']), # Rating key must be integer because PHT and PlexConnect # does not support playing queue with string rating key @@ -436,6 +451,16 @@ def GetTrackObject(item): title=u'%s' % item['title'], artist=u'%s' % item['artist'], duration=int(item['duration'])*1000, + items=[ + MediaObject( + parts=[PartObject(key=item['url'])], + container=Container.MP3, + audio_codec=AudioCodec.MP3, + audio_channels=2, + video_codec='', # Crutch for disable generate parts, + optimized_for_streaming=True, + ) + ] ) diff --git a/Contents/Info.plist b/Contents/Info.plist index 29182a5..cd64d1a 100644 --- a/Contents/Info.plist +++ b/Contents/Info.plist @@ -14,7 +14,7 @@ CFBundleSignature hook CFBundleVersion - 2.3 + 2.4 PlexClientPlatforms *