def getTorrentListByState(self, stateName): torrentInfoList = self.getTorrentList() resultTorrentInfoList = TorrentList() for torrentInfo in torrentInfoList: if torrentInfo.state == stateName: resultTorrentInfoList.append(torrentInfo) return resultTorrentInfoList
def getTorrentListByLabel(self, labelName): torrentInfoList = self.getTorrentList() resultTorrentInfoList = TorrentList() for torrentInfo in torrentInfoList: if torrentInfo.label == labelName: resultTorrentInfoList.append(torrentInfo) return resultTorrentInfoList
def getTorrentListByLabel(self, labelName): torrentInfoList = self.getTorrentList() resultTorrentInfoList = TorrentList() for torrentInfo in torrentInfoList: if torrentInfo.label == labelName: resultTorrentInfoList.append(torrentInfo) return resultTorrentInfoList
def getTorrentListByState(self, stateName): torrentInfoList = self.getTorrentList() resultTorrentInfoList = TorrentList() for torrentInfo in torrentInfoList: if torrentInfo.state == stateName: resultTorrentInfoList.append(torrentInfo) return resultTorrentInfoList
def getTorrentList(self): torrentList = TorrentList() jsonRes = self.updateUi() jdata = json.loads(jsonRes) for torrentId in jdata['result']['torrents']: torrentInfo = TorrentInfo() jsonTorrentInfo = jdata['result']['torrents'][torrentId] torrentInfo.torrentId = torrentId torrentInfo.state = jsonTorrentInfo['state'] torrentInfo.name = jsonTorrentInfo['name'].encode('utf8') torrentInfo.progress = int(jsonTorrentInfo['progress']) torrentInfo.totalSize = int(jsonTorrentInfo['total_size']) torrentInfo.uploadPayloadRate = round(float(jsonTorrentInfo['upload_payload_rate']) / (1024), 2) torrentInfo.downloadPayloadRate = round(float(jsonTorrentInfo['download_payload_rate']) / (1024), 2) torrentInfo.eta = int(jsonTorrentInfo['eta']) torrentInfo.label = jsonTorrentInfo['label'] torrentList.append(torrentInfo) return torrentList