Esempio n. 1
0
    def play_playlist(self, items, clear=True, seektime=None, audio=None, subtitle=None):

        ''' Play a list of items. Creates a new playlist. Add additional items as plugin listing.
        '''
        item = items['Items'][0]
        playlist = self.get_playlist(item)
        player = xbmc.Player()

        # xbmc.executebuiltin("Playlist.Clear") # Clear playlist to remove the previous item from playlist position no.2

        if clear:
            if player.isPlaying():
                player.stop()

            xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
            index = 0
        else:
            index = max(playlist.getposition(), 0) + 1  # Can return -1

        listitem = xbmcgui.ListItem()
        LOG.info("[ playlist/%s ] %s", item['Id'], item['Name'])

        play = playutils.PlayUtils(item, False, self.server_id, self.server, self.api_client)
        source = play.select_source(play.get_sources())
        play.set_external_subs(source, listitem)

        item['PlaybackInfo']['AudioStreamIndex'] = audio or item['PlaybackInfo']['AudioStreamIndex']
        item['PlaybackInfo']['SubtitleStreamIndex'] = subtitle or item['PlaybackInfo'].get('SubtitleStreamIndex')

        self.set_listitem(item, listitem, None, True if seektime else False)
        listitem.setPath(item['PlaybackInfo']['Path'])
        playutils.set_properties(item, item['PlaybackInfo']['Method'], self.server_id)

        playlist.add(item['PlaybackInfo']['Path'], listitem, index)
        index += 1

        if clear:
            xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
            player.play(playlist)

        server_address = item['PlaybackInfo']['ServerAddress']
        token = item['PlaybackInfo']['Token']

        for item in items['Items'][1:]:
            listitem = xbmcgui.ListItem()
            LOG.info("[ playlist/%s ] %s", item['Id'], item['Name'])

            self.set_listitem(item, listitem, None, False)
            path = '{}/Audio/{}/stream.mp3?static=true&api_key={}'.format(
                server_address, item['Id'], token)
            listitem.setPath(path)

            play = playutils.PlayUtils(item, False, self.server_id, self.server, self.api_client)
            source = play.select_source(play.get_sources())
            play.set_external_subs(source, listitem)

            playutils.set_properties(item, item['PlaybackInfo']['Method'], self.server_id)

            playlist.add(path, listitem, index)
            index += 1
Esempio n. 2
0
    def _set_intros(self, item):

        ''' if we have any play them when the movie/show is not being resumed.
        '''
        intros = TheVoid('GetIntros', {'ServerId': self.server_id, 'Id': item['Id']}).get()

        if intros['Items']:
            enabled = True

            if settings('askCinema') == "true":

                resp = dialog("yesno", heading="{emby}", line1=_(33016))
                if not resp:

                    enabled = False
                    LOG.info("Skip trailers.")

            if enabled:
                for intro in intros['Items']:

                    listitem = xbmcgui.ListItem()
                    LOG.info("[ intro/%s ] %s", intro['Id'], intro['Name'])

                    play = playutils.PlayUtils(intro, False, self.server_id, self.server)
                    source = play.select_source(play.get_sources())
                    self.set_listitem(intro, listitem, intro=True)
                    listitem.setPath(intro['PlaybackInfo']['Path'])
                    playutils.set_properties(intro, intro['PlaybackInfo']['Method'], self.server_id)

                    self.stack.append([intro['PlaybackInfo']['Path'], listitem])

                window('emby.skip.%s' % intro['Id'], value="true")
Esempio n. 3
0
    def _set_intros(self, item):

        ''' if we have any play them when the movie/show is not being resumed.
        '''
        intros = self.api_client.get_intros(item['Id'])

        if intros['Items']:
            enabled = True

            if settings('askCinema') == "true":

                resp = dialog("yesno", "{jellyfin}", translate(33016))
                if not resp:

                    enabled = False
                    LOG.info("Skip trailers.")

            if enabled:
                for intro in intros['Items']:

                    listitem = xbmcgui.ListItem()
                    LOG.info("[ intro/%s ] %s", intro['Id'], intro['Name'])

                    play = playutils.PlayUtils(intro, False, self.server_id, self.server, self.api_client)
                    play.select_source(play.get_sources())
                    self.set_listitem(intro, listitem, intro=True)
                    listitem.setPath(intro['PlaybackInfo']['Path'])
                    playutils.set_properties(intro, intro['PlaybackInfo']['Method'], self.server_id)

                    self.stack.append([intro['PlaybackInfo']['Path'], listitem])

                window('jellyfin.skip.%s' % intro['Id'], value="true")
Esempio n. 4
0
    def play_playlist(self,
                      items,
                      clear=True,
                      seektime=None,
                      audio=None,
                      subtitle=None):
        ''' Play a list of items. Creates a new playlist. Add additional items as plugin listing.
        '''
        item = items[0]
        playlist = self.get_playlist(item)

        if clear:
            playlist.clear()
            index = 0
        else:
            index = max(playlist.getposition(), 0) + 1  # Can return -1

        listitem = xbmcgui.ListItem()
        LOG.info("[ playlist/%s ] %s", item['Id'], item['Name'])

        play = playutils.PlayUtils(item, False, self.server_id, self.server)
        source = play.select_source(play.get_sources())
        play.set_external_subs(source, listitem)

        item['PlaybackInfo']['AudioStreamIndex'] = audio or item[
            'PlaybackInfo']['AudioStreamIndex']
        item['PlaybackInfo']['SubtitleStreamIndex'] = subtitle or item[
            'PlaybackInfo'].get('SubtitleStreamIndex')

        self.set_listitem(item, listitem, None, True if seektime else False)
        listitem.setPath(item['PlaybackInfo']['Path'])
        playutils.set_properties(item, item['PlaybackInfo']['Method'],
                                 self.server_id)

        playlist.add(item['PlaybackInfo']['Path'], listitem, index)
        index += 1

        if clear:
            xbmc.Player().play(playlist)

        for item in items[1:]:
            listitem = xbmcgui.ListItem()
            LOG.info("[ playlist/%s ]", item)
            path = "plugin://plugin.video.emby/?mode=play&id=%s&playlist=true" % item

            listitem.setPath(path)
            playlist.add(path, listitem, index)
            index += 1
Esempio n. 5
0
    def play(self,
             item,
             db_id=None,
             transcode=False,
             playlist=False,
             *args,
             **kwargs):
        ''' Play item based on if playback started from widget ot not.
            To get everything to work together, play the first item in the stack with setResolvedUrl,
            add the rest to the regular playlist.
        '''
        listitem = xbmcgui.ListItem()
        LOG.info("[ play/%s ] %s", item['Id'], item['Name'])

        transcode = transcode or settings('playFromTranscode.bool')
        kodi_playlist = self.get_playlist(item)
        play = playutils.PlayUtils(item, transcode, self.server_id,
                                   self.server)
        source = play.select_source(play.get_sources())
        play.set_external_subs(source, listitem)

        self.set_playlist(item, listitem, db_id, transcode)
        index = max(kodi_playlist.getposition(), 0) + 1  # Can return -1
        force_play = False

        self.stack[0][1].setPath(self.stack[0][0])
        try:
            if not playlist and self.detect_widgets(item):
                LOG.info(" [ play/widget ]")

                raise IndexError

            xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, self.stack[0][1])
            self.stack.pop(0)
        except IndexError:
            force_play = True

        for stack in self.stack:

            kodi_playlist.add(url=stack[0], listitem=stack[1], index=index)
            index += 1

        if force_play:
            if len(sys.argv) > 1:
                xbmcplugin.setResolvedUrl(int(sys.argv[1]), False,
                                          self.stack[0][1])
            xbmc.Player().play(kodi_playlist, windowed=False)
Esempio n. 6
0
    def _set_additional_parts(self, item_id):

        ''' Create listitems and add them to the stack of playlist.
        '''
        parts = self.api_client.get_additional_parts(item_id)
        for part in parts['Items']:

            listitem = xbmcgui.ListItem()
            LOG.info("[ part/%s ] %s", part['Id'], part['Name'])

            play = playutils.PlayUtils(part, False, self.server_id, self.server, self.api_client)
            source = play.select_source(play.get_sources())
            play.set_external_subs(source, listitem)
            self.set_listitem(part, listitem)
            listitem.setPath(part['PlaybackInfo']['Path'])
            playutils.set_properties(part, part['PlaybackInfo']['Method'], self.server_id)

            self.stack.append([part['PlaybackInfo']['Path'], listitem])
Esempio n. 7
0
    def _set_additional_parts(self, item_id, *args, **kwargs):
        ''' Create listitems and add them to the stack of playlist.
        '''
        parts = TheVoid('GetAdditionalParts', {
            'ServerId': self.server_id,
            'Id': item_id
        }).get()

        for part in parts['Items']:

            listitem = xbmcgui.ListItem()
            LOG.info("[ part/%s ] %s", part['Id'], part['Name'])

            play = playutils.PlayUtils(part, False, self.server_id,
                                       self.server)
            source = play.select_source(play.get_sources())
            play.set_external_subs(source, listitem)
            self.set_listitem(part, listitem)
            listitem.setPath(part['PlaybackInfo']['Path'])
            playutils.set_properties(part, part['PlaybackInfo']['Method'],
                                     self.server_id)

            self.stack.append([part['PlaybackInfo']['Path'], listitem])