예제 #1
0
파일: gui.py 프로젝트: TinyHTPC/xbmc-packs
    def updateTorrent(self):
        pbar = self.getControl(219)
        list = self.getControl(220)
        labelName = self.getControl(1)
        labelStatus = self.getControl(2)
        torrent = self.transmission.info()[self.torrent_id]
        files = self.transmission.get_files(self.torrent_id)[self.torrent_id]

        statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \
            {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \
            'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \
            'status': torrent.status}
        if torrent.status is 'downloading':
            statusline += " ETA: %(eta)s" % \
                    {'eta': torrent.eta}

        labelName.setLabel(torrent.name)
        labelStatus.setLabel(statusline)
        pbar.setPercent(torrent.progress)

        for i, file in files.iteritems():
            if i not in self.list:
                # Create a new list item
                l = xbmcgui.ListItem(label=file['name'])
                list.addItem(l)
                self.list[i] = l
            else:
                # Update existing list item
                l = self.list[i]
            l.setProperty('Progress', '[%3d%%]' % (file['completed'] * 100 / file['size']))
예제 #2
0
    def updateTorrents(self):
        list = self.getControl(20)
        torrents = self.transmission.info()
        for i, torrent in torrents.iteritems():
            statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \
                {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \
                'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \
                'status': torrent.status}
            if torrent.status is 'downloading':
                statusline += " ETA: %(eta)s" % \
                    {'eta': torrent.eta}
            if i not in self.list:
                # Create a new list item
                l = xbmcgui.ListItem(label=torrent.name, label2=statusline)
                list.addItem(l)
                self.list[i] = l
            else:
                # Update existing list item
                l = self.list[i]
            self.torrents = torrents
            l.setLabel(torrent.name)
            l.setLabel2(statusline)
            l.setProperty('TorrentID', str(i))
            l.setProperty('TorrentProgress', "%.2ff" % torrent.progress)
            l.setInfo('torrent', torrent.fields)
            l.setInfo('video', {'episode': int(torrent.progress)})

        removed = [id for id in self.list.keys() if id not in torrents.keys()]
        if len(removed) > 0:
            # Clear torrents from the list that have been removed
            for id in removed:
                del self.list[id]
            list.reset()
            for id, item in self.list.iteritems():
                list.addItem(item)
예제 #3
0
    def updateTorrent(self):
        pbar = self.getControl(219)
        list = self.getControl(220)
        labelName = self.getControl(1)
        labelDownload = self.getControl(2)
        labelUpload = self.getControl(5)
        labelETA = self.getControl(4)
        labelProgress = self.getControl(11)
        torrents = self.deluge.list()
        if torrents is not False:
            for torrent in torrents:
                if torrent['id'] == self.torrent_id: break
            self.torrent = torrent
            labelName.setLabel(torrent['name'])
            download_line = "Done %(down)s (%(pct).2f%%) | Speed %(dspeed)s/s"% \
                            {'down': Bytes.format(torrent['download']), 'pct': torrent['progress'],
                             'dspeed': Bytes.format(torrent['downspeed'])}
            labelDownload.setLabel(download_line)
            upload_line = "Sent %(up)s | Speed %(uspeed)s/s | Ratio: %(ratio).2f"% \
                          {'up': Bytes.format(torrent['upload']), 'uspeed': Bytes.format(torrent['upspeed']),
                           'ratio': torrent['ratio']}
            labelUpload.setLabel(upload_line)
            if torrent['status'] is 'downloading':
                eta_line = "%(eta)s"%{'eta': self.formatEta(int(torrent['eta']))}
            else:
                eta_line = "inf."
            labelETA.setLabel(eta_line)
            labelProgress.setLabel('%3d%%'%(torrent['progress']))
            pbar.setPercent(torrent['progress'])
            files = self.deluge.listfiles(self.torrent_id)  # [[path, percent, x['index'], size],...]
            if files is not None:
                for file in files:
                    if file[2] not in self.listItems.keys():
                        # Create a new list item
                        l = xbmcgui.ListItem(label=file[0])
                        list.addItem(l)
                        self.listItems[file[2]] = l
                    else:
                        # Update existing list item
                        l = self.listItems[file[2]]
                    l.setProperty('Progress', '[%3d%% of %s]'%(file[1], file[3]))

        # Update again, after an interval
        self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrent)
        self.timer.start()
예제 #4
0
    def updateTorrents(self):
        torrents = self.deluge.list()
        if torrents:
            self.torrents = torrents
            list = self.getControl(120)
            keys = []
            for torrent in self.torrents:
                keys.append(torrent['id'])
                statusline = "Down: %(down)s %(pct).2f%% %(dspeed)s/s | Up: %(up)s %(uspeed)s/s | Ratio: %(ratio).2f"% \
                             {'down': Bytes.format(torrent['download']), 'pct': torrent['progress'], \
                              'dspeed': Bytes.format(torrent['downspeed']), 'up': Bytes.format(torrent['upload']),
                              'uspeed': Bytes.format(torrent['upspeed']), 'ratio': torrent['ratio']}
                if torrent['progress'] == 100: torrent['status'] = 'fake_done'
                if torrent['id'] not in self.listItems:
                    # Create a new list item
                    l = xbmcgui.ListItem(label=torrent['name'], label2=statusline)
                    self.listItems[torrent['id']] = l
                    list.addItem(l)
                else:
                    # Update existing list item
                    l = self.listItems[torrent['id']]
                l.setLabel(torrent['name'])
                l.setLabel2(statusline)
                l.setProperty('TorrentID', str(torrent['id']))
                l.setProperty('TorrentStatusIcon', STATUS_ICONS.get(torrent['status'], 'status_paused.png'))
                l.setProperty('TorrentProgress', "%3d%%"%torrent['progress'])

            removed = [id for id in self.listItems.keys() if id not in keys]
            if len(removed) > 0:
                # Clear torrents from the list that have been removed
                for id in removed:
                    del self.listItems[id]
                list.reset()
                for id in self.listItems:
                    list.addItem(self.listItems[id])
            list.setEnabled(bool(self.torrents))

        # Update again, after an interval, but only if the timer has not been cancelled
        if self.timer:
            self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrents)
            self.timer.start()
예제 #5
0
    def updateTorrents(self):
        list = self.getControl(120)
        self.torrents = self.transmission.info()
        for i, torrent in self.torrents.iteritems():
            statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \
                {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \
                'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \
                'status': torrent.status}
            if i not in self.list:
                # Create a new list item
                l = xbmcgui.ListItem(label=torrent.name, label2=statusline)
                list.addItem(l)
                self.list[i] = l
            else:
                # Update existing list item
                l = self.list[i]
            l.setLabel(torrent.name)
            l.setLabel2(statusline)
            l.setProperty('TorrentStatusIcon',
                          STATUS_ICONS.get(torrent.status, 'pending.png'))
            l.setProperty('TorrentID', str(i))
            l.setProperty('TorrentProgress', "%3d%%" % torrent.progress)

        removed = [
            id for id in self.list.keys() if id not in self.torrents.keys()
        ]
        if len(removed) > 0:
            # Clear torrents from the list that have been removed
            for id in removed:
                del self.list[id]
            list.reset()
            for id, item in self.list.iteritems():
                list.addItem(item)
        list.setEnabled(bool(self.torrents))

        # Update again, after an interval, but only if the timer has not been cancelled
        if self.timer:
            self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrents)
            self.timer.start()
예제 #6
0
 def updateTorrents(self):
     list = self.getControl(120)
     torrents = self.transmission.get_torrents()
     for i in range(len(torrents)):
         torrent = torrents[i]
         #xbmc.log("i=%d id=%s" % (i,torrent.id))
         statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \
             {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \
             'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \
             'status': torrent.status}
         if torrent.id not in self.list:
             # Create a new list item
             l = xbmcgui.ListItem(label=torrent.name, label2=statusline)
             list.addItem(l)
             self.list[torrent.id] = l
         else:
             # Update existing list item
             l = self.list[torrent.id]
         self.torrents = torrents
         statusicons = {'stopped': 'pause.png',
                        'seeding': 'ok.png',
                        'downloading': 'down.png'}
         l.setLabel(torrent.name)
         l.setLabel2(statusline)
         l.setProperty('TorrentStatusIcon', statusicons[torrent.status])
         l.setProperty('TorrentID', str(i))
         l.setProperty('TorrentProgress', "%.2f" % torrent.progress)
         #l.setInfo('torrent', torrent.fields)
         l.setInfo('video', {'episode': int(torrent.progress)})
     torrents_keys = [torrent.id for torrent in torrents]
     removed = [id for id in self.list.keys() if id not in torrents_keys]
     if len(removed) > 0:
         # Clear torrents from the list that have been removed
         for id in removed:
             del self.list[id]
         list.reset()
         for id, item in self.list.iteritems():
             list.addItem(item)
     list.setEnabled(bool(torrents))
예제 #7
0
    def updateTorrents(self):
        list = self.getControl(120)
        self.torrents = self.transmission.info()
        for i, torrent in self.torrents.iteritems():
            statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \
                {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \
                'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \
                'status': torrent.status}
            if i not in self.list:
                # Create a new list item
                l = xbmcgui.ListItem(label=torrent.name, label2=statusline)
                list.addItem(l)
                self.list[i] = l
            else:
                # Update existing list item
                l = self.list[i]
            l.setLabel(torrent.name)
            l.setLabel2(statusline)
            l.setProperty('TorrentStatusIcon', STATUS_ICONS.get(torrent.status, 'pending.png'))
            l.setProperty('TorrentID', str(i))
            l.setProperty('TorrentProgress', "%3d%%" % torrent.progress)
            l.setInfo('torrent', torrent.fields)
            l.setInfo('video', {'episode': int(torrent.progress)})

        removed = [id for id in self.list.keys() if id not in self.torrents.keys()]
        if len(removed) > 0:
            # Clear torrents from the list that have been removed
            for id in removed:
                del self.list[id]
            list.reset()
            for id, item in self.list.iteritems():
                list.addItem(item)
        list.setEnabled(bool(self.torrents))

        # Update again, after an interval, but only if the timer has not been cancelled
        if self.timer:
          self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrents)
          self.timer.start()
예제 #8
0
    def updateTorrent(self):
        pbar = self.getControl(219)
        list = self.getControl(220)
        labelName = self.getControl(1)
        labelStatus = self.getControl(2)
        labelProgress = self.getControl(11)
        torrent = self.transmission.info()[self.torrent_id]
        files = self.transmission.get_files(self.torrent_id)[self.torrent_id]

        statusline = "[%(status)s] %(down)s down, %(up)s up (Ratio: %(ratio).2f)" % \
            {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \
            'up': Bytes.format(torrent.uploadedEver), 'ratio': torrent.ratio, \
            'status': torrent.status}
        if torrent.status is 'downloading':
            statusline += " ETA: %(eta)s" % \
                    {'eta': torrent.eta}

        labelName.setLabel(torrent.name)
        labelStatus.setLabel(statusline)
        labelProgress.setLabel('%3d%%' % (torrent.progress))
        pbar.setPercent(torrent.progress)

        for i, file in files.iteritems():
            if i not in self.list:
                # Create a new list item
                l = xbmcgui.ListItem(label=file['name'])
                list.addItem(l)
                self.list[i] = l
            else:
                # Update existing list item
                l = self.list[i]
            l.setProperty('Progress',
                          '[%3d%%]' % (file['completed'] * 100 / file['size']))

        # Update again, after an interval
        self.timer = threading.Timer(UPDATE_INTERVAL, self.updateTorrent)
        self.timer.start()