mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-22 08:53:59 +01:00
Added Labeling based off of hash for utorrent and fixed a typo in postprocessor.py
This commit is contained in:
@@ -352,7 +352,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
|||||||
headphones.MOVE_FILES:
|
headphones.MOVE_FILES:
|
||||||
|
|
||||||
if not os.access(downloaded_track, os.W_OK):
|
if not os.access(downloaded_track, os.W_OK):
|
||||||
logger.error("Track file is not writeable, which is equired for some post processing steps: %s", downloaded_track.decode(headphones.SYS_ENCODING, 'replace'))
|
logger.error("Track file is not writeable, which is required for some post processing steps: %s", downloaded_track.decode(headphones.SYS_ENCODING, 'replace'))
|
||||||
return
|
return
|
||||||
|
|
||||||
#start encoding
|
#start encoding
|
||||||
|
|||||||
+22
-28
@@ -69,36 +69,30 @@ def addTorrent(link):
|
|||||||
logger.error("Error sending torrent to uTorrent")
|
logger.error("Error sending torrent to uTorrent")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Not really sure how to ID these? Title seems safest)
|
if link.startswith('magnet'):
|
||||||
# Also, not sure when the torrent will pop up in the list, so we'll make sure it exists and is 1% downloaded
|
tor_hash = re.findall('urn:btih:([\w]{32,40})', link)[0]
|
||||||
tries = 0
|
if len(tor_hash) == 32:
|
||||||
folder = None
|
tor_hash = b16encode(b32decode(tor_hash)).lower()
|
||||||
while tries < 10:
|
else:
|
||||||
|
info = bdecode(link.content)["info"]
|
||||||
|
tor_hash = sha1(bencode(info)).hexdigest()
|
||||||
|
|
||||||
|
params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label, 'token':token}
|
||||||
|
response = request.request_json(host, params=params, auth=auth, cookies=cookies)
|
||||||
|
if not response:
|
||||||
|
logger.error("Error setting torrent label in uTorrent")
|
||||||
|
return
|
||||||
|
|
||||||
# NOW WE WILL CHECK UTORRENT FOR THE FOLDER NAME & SET THE LABEL
|
# folder info can probably be cleaned up with getprops
|
||||||
params = {'list':'1', 'token':token}
|
folder = None
|
||||||
|
|
||||||
response = request.request_json(host, params=params, auth=auth, cookies=cookies)
|
params = {'list':'1', 'token':token}
|
||||||
|
response = request.request_json(host, params=params, auth=auth, cookies=cookies)
|
||||||
if not response:
|
if not response:
|
||||||
logger.error("Error getting torrent information from uTorrent")
|
logger.error("Error getting torrent information from uTorrent")
|
||||||
return
|
return
|
||||||
|
|
||||||
for torrent in response['torrents']:
|
for torrent in response['torrents']:
|
||||||
|
folder = os.path.basename(torrent[26])
|
||||||
|
|
||||||
if torrent[19] == link and torrent[4] > 1:
|
return folder
|
||||||
folder = os.path.basename(torrent[26])
|
|
||||||
tor_hash = torrent[0]
|
|
||||||
params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label, 'token':token}
|
|
||||||
response = request.request_json(host, params=params, auth=auth, cookies=cookies)
|
|
||||||
break
|
|
||||||
|
|
||||||
if folder:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
time.sleep(5)
|
|
||||||
tries += 1
|
|
||||||
|
|
||||||
return folder
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user