Easier to follow logic for uTorrent

This commit is contained in:
delphiactual
2014-05-11 21:26:58 -06:00
parent 62a6be26af
commit e972a86233

View File

@@ -136,16 +136,31 @@ class utorrentclient(object):
logger.debug('URL: ' + str(url))
logger.debug('uTorrent webUI raised the following error: ' + str(err))
def addTorrent(link, hash):
def labelTorrent(hash):
label = headphones.UTORRENT_LABEL
uTorrentClient = utorrentclient()
uTorrentClient.add_url(link)
time.sleep(1) #ensure file is loaded in uTorrent...
uTorrentClient.setprops(hash,'label',label)
settinglabel = True
while settinglabel:
torrentList = uTorrentClient.list()
for torrent in torrentList[1].get('torrents'):
if (torrent[0].lower() == hash):
uTorrentClient.setprops(hash,'label',label)
settinglabel = False
return True
def dirTorrent(hash):
uTorrentClient = utorrentclient()
torrentList = uTorrentClient.list()
for torrent in torrentList[1].get('torrents'):
if (torrent[0].lower()==hash):
if (torrent[0].lower() == hash):
return torrent[26]
return False
return False
def addTorrent(link, hash):
uTorrentClient = utorrentclient()
uTorrentClient.add_url(link)
labelTorrent(hash)
return dirTorrent(hash)