コード例 #1
0
ファイル: torrent.py プロジェクト: chakhdin/KODI-Popcorn-Time
    def playTorrentFile(self, mediaSettings, magnet, item, subtitleURL=None):
        with TorrentEngine(mediaSettings, magnet) as _TorrentEngine:
            # Loading
            log('(Torrent Player) Loading', LOGLEVEL.INFO)
            with closing(SafeDialogProgress()) as dialog:
                dialog.create(item['info']['title'])
                dialog.update(0, __addon__.getLocalizedString(30031), ' ', ' ')

                # Update progress dialog
                dialog.set_mentions((101+bool(subtitleURL)))
             
                def on_update(state, progressValue):
                    if state == Loader.PRELOADING:
                        dialog.update(progressValue, *self._get_status_lines(_TorrentEngine.status()))
                    elif state == Loader.CHECKING_DATA:
                        dialog.update(progressValue, __addon__.getLocalizedString(30037), ' ', ' ')
                    elif state == Loader.WAITING_FOR_PLAY_FILE:
                        dialog.update(progressValue, __addon__.getLocalizedString(30016), ' ', ' ')
                    elif state == Loader.DOWNLOADING_SUBTITLE:
                        dialog.update(progressValue, __addon__.getLocalizedString(30019), ' ', ' ')
                    elif state == Loader.FINISHED:
                        dialog.update(progressValue, __addon__.getLocalizedString(30020), ' ', ' ')

                with Loader(mediaSettings, _TorrentEngine, item, subtitleURL, on_update) as _loader:
                    while not _loader.is_done(0.100):
                        if xbmc.abortRequested or dialog.iscanceled():
                            raise Abort()

            # Starts the playback
            log('(Torrent Player) Start the playback', LOGLEVEL.INFO)
            self.play(Loader.url, ListItem.from_dict(**item).as_xbmc_listitem()) # https://github.com/Diblo/KODI-Popcorn-Time/issues/57

            # Waiting for playback to start
            log('(Torrent Player) Waiting for playback to start')
            for _ in xrange(300):
                if self.isPlaying():
                    break
                time.sleep(0.100)
            else:
                raise Error('Playback is terminated due to timeout', 30318)

            if Loader.subtitle:
                log('(Torrent Player) Add subtitle to the playback')
                self.setSubtitles(Loader.subtitle)

            with OverlayText() as self._overlay:
                while not xbmc.abortRequested and self.isPlaying():
                    if self._overlay.isShowing():
                        self._overlay.setText("\n".join(self._get_status_lines(_TorrentEngine.status())))
                        time.sleep(0.100)
                        continue
                    time.sleep(0.250)
                log('(Torrent Player) The playback has stop')
コード例 #2
0
ファイル: main.py プロジェクト: chakhdin/KODI-Popcorn-Time
    def addItem(self, mediaType, endpoint, params, isFolder=True, **item):
        log("(Main) Adding item '%s'" %item["label"])
        path = "%s?%s" %(settings.addon.base_url, urllib.urlencode(dict([('mediaType', mediaType), ('endpoint', endpoint)], **params)))

        if not isFolder:
            item["replace_context_menu"] = True
            item["context_menu"] = []
            for _q in settings.QUALITIES:
                if params.get(_q):
                    item["context_menu"] = item["context_menu"]+[('%s %s' %(__addon__.getLocalizedString(30009), _q), 'RunPlugin(%s&quality=%s)' %(path, _q))]
            item["context_menu"] = item["context_menu"]+[(__addon__.getLocalizedString(30010), 'RunPlugin(%s?cmd=True&endpoint=openSettings)' %settings.addon.base_url)]

        # Ensure fanart
        if not item.setdefault("properties", {}).get("fanart_image"):
            item["properties"]["fanart_image"] = settings.addon.fanart

        xbmcplugin.addDirectoryItem(settings.addon.handle, path, ListItem.from_dict(**item).as_xbmc_listitem(), isFolder)
コード例 #3
0
ファイル: main.py プロジェクト: chakhdin/KODI-Popcorn-Time
    def addNextButton(self, **kwargs):
        log("(Main) Adding item 'Show more'")

        item = {
            "label": __addon__.getLocalizedString(30000),
            "icon": os.path.join(settings.addon.resources_path, 'media', self.mediaSettings.mediaType, 'more.png'),
            "thumbnail": os.path.join(settings.addon.resources_path, 'media', self.mediaSettings.mediaType, 'more_thumbnail.png'),
            "properties": {
                "fanart_image": settings.addon.fanart
            }
        }
        item.setdefault('properties',  {}).update(dict((key, str(value)) for key, value in kwargs.items() if value))
        xbmcplugin.addDirectoryItem(settings.addon.handle, "%s?%s" %(settings.addon.base_url, settings.addon.cur_uri), ListItem.from_dict(**item).as_xbmc_listitem(), True)
コード例 #4
0
    def playTorrentFile(self, mediaSettings, magnet, item, subtitleURL=None):
        with TorrentEngine(mediaSettings, magnet) as _TorrentEngine:
            # Loading
            log('(Torrent Player) Loading', LOGLEVEL.INFO)
            with closing(SafeDialogProgress()) as dialog:
                dialog.create(item['info']['title'])
                dialog.update(0, __addon__.getLocalizedString(30031), ' ', ' ')

                # Update progress dialog
                dialog.set_mentions((101 + bool(subtitleURL)))

                def on_update(state, progressValue):
                    if state == Loader.PRELOADING:
                        dialog.update(
                            progressValue,
                            *self._get_status_lines(_TorrentEngine.status()))
                    elif state == Loader.CHECKING_DATA:
                        dialog.update(progressValue,
                                      __addon__.getLocalizedString(30037), ' ',
                                      ' ')
                    elif state == Loader.WAITING_FOR_PLAY_FILE:
                        dialog.update(progressValue,
                                      __addon__.getLocalizedString(30016), ' ',
                                      ' ')
                    elif state == Loader.DOWNLOADING_SUBTITLE:
                        dialog.update(progressValue,
                                      __addon__.getLocalizedString(30019), ' ',
                                      ' ')
                    elif state == Loader.FINISHED:
                        dialog.update(progressValue,
                                      __addon__.getLocalizedString(30020), ' ',
                                      ' ')

                with Loader(mediaSettings, _TorrentEngine, item, subtitleURL,
                            on_update) as _loader:
                    while not _loader.is_done(0.100):
                        if xbmc.abortRequested or dialog.iscanceled():
                            raise Abort()

            # Starts the playback
            log('(Torrent Player) Start the playback', LOGLEVEL.INFO)
            self.play(Loader.url,
                      ListItem.from_dict(**item).as_xbmc_listitem()
                      )  # https://github.com/Diblo/KODI-Popcorn-Time/issues/57

            # Waiting for playback to start
            log('(Torrent Player) Waiting for playback to start')
            for _ in xrange(300):
                if self.isPlaying():
                    break
                time.sleep(0.100)
            else:
                raise Error('Playback is terminated due to timeout', 30318)

            if Loader.subtitle:
                log('(Torrent Player) Add subtitle to the playback')
                self.setSubtitles(Loader.subtitle)

            with OverlayText() as self._overlay:
                while not xbmc.abortRequested and self.isPlaying():
                    if self._overlay.isShowing():
                        self._overlay.setText("\n".join(
                            self._get_status_lines(_TorrentEngine.status())))
                        time.sleep(0.100)
                        continue
                    time.sleep(0.250)
                log('(Torrent Player) The playback has stop')