コード例 #1
0
ファイル: plugin.py プロジェクト: secustor/plex-for-kodi
def playTrack(track):
    track.reload()
    apobj = plexplayer.PlexAudioPlayer(track)
    url = apobj.build()['url']
    url = util.addURLParams(
        url, {
            'X-Plex-Client-Profile-Name':
            'Chrome',
            'X-Plex-Client-Identifier':
            plexapp.util.INTERFACE.getGlobal('clientIdentifier')
        })
    LOG('Playing URL: {0}'.format(url))

    return xbmcgui.ListItem(path=url)
コード例 #2
0
ファイル: player.py プロジェクト: plexinc/plex-for-kodi
    def extractTrackInfo(self):
        if not self.player.isPlayingAudio():
            return

        plexID = None
        for x in range(
                10):  # Wait a sec (if necessary) for this to become available
            try:
                item = kodijsonrpc.rpc.Player.GetItem(playerid=0,
                                                      properties=['comment'
                                                                  ])['item']
                plexID = item['comment']
            except:
                util.ERROR()

            if plexID:
                break
            xbmc.sleep(100)

        if not plexID:
            return

        if not plexID.startswith('PLEX-'):
            return

        util.DEBUG_LOG('Extracting track info from comment')
        try:
            data = plexID.split(':', 1)[-1]
            from plexnet import plexobjects
            track = plexobjects.PlexObject.deSerialize(
                base64.urlsafe_b64decode(data.encode('utf-8')))
            track.softReload()
            self.media = track
            pobj = plexplayer.PlexAudioPlayer(track)
            self.player.playerObject = pobj
            self.updatePlayQueueTrack(track)
            util.setGlobalProperty(
                'track.ID', track.ratingKey
            )  # This is used in the skins to match a listitem
        except:
            util.ERROR()