adjusted log function to not be called if disabled
This commit is contained in:
parent
1889901f93
commit
1375bc36ce
@ -41,6 +41,7 @@ class Qbt:
|
|||||||
self.tracker_protected_tag = 'ipt'
|
self.tracker_protected_tag = 'ipt'
|
||||||
self.tracker_non_protected_tag = 'public'
|
self.tracker_non_protected_tag = 'public'
|
||||||
self.torrent_hash_delete_list = []
|
self.torrent_hash_delete_list = []
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(self.tracker_whitelist)
|
self.tl.debug(self.tracker_whitelist)
|
||||||
try:
|
try:
|
||||||
self.tl.info('Connecting to host.')
|
self.tl.info('Connecting to host.')
|
||||||
@ -51,11 +52,14 @@ class Qbt:
|
|||||||
self.poc.send_message(e, title="qbit-maid API ERROR")
|
self.poc.send_message(e, title="qbit-maid API ERROR")
|
||||||
self.torrentlist = {}
|
self.torrentlist = {}
|
||||||
self.torrentlist = self.qbt_client.torrents_info()
|
self.torrentlist = self.qbt_client.torrents_info()
|
||||||
|
if self.use_log:
|
||||||
listqbitapiinfo(self)
|
listqbitapiinfo(self)
|
||||||
#listfirsttor(self)
|
listfirsttor(self)
|
||||||
buildtorlist(self)
|
buildtorlist(self)
|
||||||
|
if self.use_log:
|
||||||
torrentcount(self)
|
torrentcount(self)
|
||||||
torprocessor(self)
|
torprocessor(self)
|
||||||
|
if self.use_log:
|
||||||
printprocessor(self)
|
printprocessor(self)
|
||||||
if self.use_pushover:
|
if self.use_pushover:
|
||||||
tornotifysummary(self)
|
tornotifysummary(self)
|
||||||
|
6
qlist.py
6
qlist.py
@ -5,26 +5,32 @@ def buildtorlist(self):
|
|||||||
self.nonprotected_count = 0
|
self.nonprotected_count = 0
|
||||||
while self.torrentlist:
|
while self.torrentlist:
|
||||||
torrent = self.torrentlist.pop()
|
torrent = self.torrentlist.pop()
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(f'{torrent["name"]} {torrent["infohash_v1"]}')
|
self.tl.debug(f'{torrent["name"]} {torrent["infohash_v1"]}')
|
||||||
if torrent['tracker'] == '':
|
if torrent['tracker'] == '':
|
||||||
|
if self.use_log:
|
||||||
self.tl.warning(f"Torrent doesn't have a tracker{torrent['name']} [{torrent['tracker']}]hash: {torrent['hash']}")
|
self.tl.warning(f"Torrent doesn't have a tracker{torrent['name']} [{torrent['tracker']}]hash: {torrent['hash']}")
|
||||||
break
|
break
|
||||||
if self.tracker_whitelist['iptorrents-empirehost'] in torrent['tracker']:
|
if self.tracker_whitelist['iptorrents-empirehost'] in torrent['tracker']:
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
||||||
self.protected_count += 1
|
self.protected_count += 1
|
||||||
self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
|
self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
|
||||||
self.tracker_protected_list.append(torrent)
|
self.tracker_protected_list.append(torrent)
|
||||||
elif self.tracker_whitelist["iptorrents-stackoverflow"] in torrent['tracker']:
|
elif self.tracker_whitelist["iptorrents-stackoverflow"] in torrent['tracker']:
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
||||||
self.protected_count += 1
|
self.protected_count += 1
|
||||||
self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
|
self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
|
||||||
self.tracker_protected_list.append(torrent)
|
self.tracker_protected_list.append(torrent)
|
||||||
elif self.tracker_whitelist["iptorrents-bgp"] in torrent['tracker']:
|
elif self.tracker_whitelist["iptorrents-bgp"] in torrent['tracker']:
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
||||||
self.protected_count += 1
|
self.protected_count += 1
|
||||||
self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
|
self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
|
||||||
self.tracker_protected_list.append(torrent)
|
self.tracker_protected_list.append(torrent)
|
||||||
else:
|
else:
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(f'Non-protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
self.tl.debug(f'Non-protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
||||||
self.nonprotected_count += 1
|
self.nonprotected_count += 1
|
||||||
self.qbt_client.torrents_add_tags(self.tracker_non_protected_tag,torrent['hash'])
|
self.qbt_client.torrents_add_tags(self.tracker_non_protected_tag,torrent['hash'])
|
||||||
|
10
qprocess.py
10
qprocess.py
@ -2,27 +2,36 @@
|
|||||||
def torprocessor(self):
|
def torprocessor(self):
|
||||||
for canidate in self.tracker_nonprotected_list:
|
for canidate in self.tracker_nonprotected_list:
|
||||||
if 'ipt' in canidate['tags']:
|
if 'ipt' in canidate['tags']:
|
||||||
|
if self.use_log:
|
||||||
self.tl.warning(f'{canidate["name"]} was in non-protected list.')
|
self.tl.warning(f'{canidate["name"]} was in non-protected list.')
|
||||||
break
|
break
|
||||||
if canidate['state'] == 'downloading':
|
if canidate['state'] == 'downloading':
|
||||||
|
if self.use_log:
|
||||||
self.tl.info(f'{canidate["name"]} is still downloading and will be skipped.')
|
self.tl.info(f'{canidate["name"]} is still downloading and will be skipped.')
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.torrent_hash_delete_list.append(canidate['infohash_v1'])
|
self.torrent_hash_delete_list.append(canidate['infohash_v1'])
|
||||||
|
if self.use_log:
|
||||||
self.tl.info(f'Submitted {canidate["name"]} for deletion.')
|
self.tl.info(f'Submitted {canidate["name"]} for deletion.')
|
||||||
for canidate in self.tracker_protected_list:
|
for canidate in self.tracker_protected_list:
|
||||||
if canidate['state'] == 'downloading':
|
if canidate['state'] == 'downloading':
|
||||||
|
if self.use_log:
|
||||||
self.tl.warning(f'{canidate["name"]} is still downloading and will be skipped.')
|
self.tl.warning(f'{canidate["name"]} is still downloading and will be skipped.')
|
||||||
break
|
break
|
||||||
if canidate['ratio'] < float(1.05):
|
if canidate['ratio'] < float(1.05):
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(f'{canidate["name"]} is below a 1.05 ratio({canidate["ratio"]})')
|
self.tl.debug(f'{canidate["name"]} is below a 1.05 ratio({canidate["ratio"]})')
|
||||||
if canidate['added_on'] + self.config["age"] <= self.t.time():
|
if canidate['added_on'] + self.config["age"] <= self.t.time():
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(f'{canidate["name"]} Seconds old: {self.t.time() - self.config["age"] - canidate["added_on"]}')
|
self.tl.debug(f'{canidate["name"]} Seconds old: {self.t.time() - self.config["age"] - canidate["added_on"]}')
|
||||||
self.torrent_hash_delete_list.append(canidate['infohash_v1'])
|
self.torrent_hash_delete_list.append(canidate['infohash_v1'])
|
||||||
|
if self.use_log:
|
||||||
self.tl.info(f'Submitted {canidate["name"]} for deletion from the protected list.')
|
self.tl.info(f'Submitted {canidate["name"]} for deletion from the protected list.')
|
||||||
if canidate['ratio'] >= float(1.05):
|
if canidate['ratio'] >= float(1.05):
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug(f'{canidate["name"]} is above a 1.05 ratio({canidate["ratio"]}).')
|
self.tl.debug(f'{canidate["name"]} is above a 1.05 ratio({canidate["ratio"]}).')
|
||||||
self.torrent_hash_delete_list.append(canidate['infohash_v1'])
|
self.torrent_hash_delete_list.append(canidate['infohash_v1'])
|
||||||
|
if self.use_log:
|
||||||
self.tl.info(f'Submitted {canidate["name"]} for deletion from the protected list.')
|
self.tl.info(f'Submitted {canidate["name"]} for deletion from the protected list.')
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -33,6 +42,7 @@ def printprocessor(self):
|
|||||||
self.tl.info(f'Total torrents set for deletion: {len(self.torrent_hash_delete_list)}')
|
self.tl.info(f'Total torrents set for deletion: {len(self.torrent_hash_delete_list)}')
|
||||||
|
|
||||||
def tordelete(self):
|
def tordelete(self):
|
||||||
|
if self.use_log:
|
||||||
self.tl.debug('Hash list submitted for deletion:')
|
self.tl.debug('Hash list submitted for deletion:')
|
||||||
self.tl.debug(self.torrent_hash_delete_list)
|
self.tl.debug(self.torrent_hash_delete_list)
|
||||||
self.qbt_client.torrents_delete(True, self.torrent_hash_delete_list)
|
self.qbt_client.torrents_delete(True, self.torrent_hash_delete_list)
|
Loading…
x
Reference in New Issue
Block a user