mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-31 10:09:28 +01:00
Easier to follow logic for uTorrent
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user