changed some logging stuff

This commit is contained in:
jblu 2022-07-14 21:37:45 -05:00
parent e624236586
commit 419358a090
2 changed files with 13 additions and 5 deletions

View File

@ -43,7 +43,10 @@ class Qbt:
self.tl.exception(e) self.tl.exception(e)
self.torrentlist = {} self.torrentlist = {}
self.torrentlist = self.qbt_client.torrents_info() self.torrentlist = self.qbt_client.torrents_info()
listqbitapiinfo(self)
listfirsttor(self)
buildtorlist(self) buildtorlist(self)
torrentcount(self)
torprocessor(self) torprocessor(self)
printprocessor(self) printprocessor(self)
tordelete(self) tordelete(self)

View File

@ -1,27 +1,28 @@
#The second file shall contain functions to build out a list of torrents. #The second file shall contain functions to build out a list of torrents.
def buildtorlist(self): def buildtorlist(self):
"""builds multiple lists of torrents to be sorted."""
self.protected_count = 0 self.protected_count = 0
self.nonprotected_count = 0 self.nonprotected_count = 0
while self.torrentlist: while self.torrentlist:
torrent = self.torrentlist.pop() torrent = self.torrentlist.pop()
self.tl.debug(torrent['tracker']) self.tl.debug(f'{torrent["name"]} {torrent["infohash_v1"]}')
if self.tracker_whitelist['iptorrents-empirehost'] in torrent['tracker']: if self.tracker_whitelist['iptorrents-empirehost'] in torrent['tracker']:
self.tl.debug(f'Protected torrent tracker: {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']:
self.tl.debug(f'Protected torrent tracker: {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']:
self.tl.debug(f'Protected torrent tracker: {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:
self.tl.debug(f'Non-protected tracker: {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'])
self.tracker_nonprotected_list.append(torrent) self.tracker_nonprotected_list.append(torrent)
@ -31,11 +32,15 @@ def writetor(self, filepath='./torrentinfo.txt'):
fp.write(str(self.torrentlist)) fp.write(str(self.torrentlist))
def listfirsttor(self, index=0): def listfirsttor(self, index=0):
"""Only lists the first torrent"""
self.tl.debug('First torrent in the list:')
torrent = self.torrentlist[index] torrent = self.torrentlist[index]
for k,v in torrent.items(): for k,v in torrent.items():
self.tl.debug(f'{k}: {v}') self.tl.debug(f'{k}: {v}')
self.tl.debug('\n')
def listqbitapiinfo(self): def listqbitapiinfo(self):
"""Writes torrent info to log file"""
self.tl.info(f'qBittorrent: {self.qbt_client.app.version}') self.tl.info(f'qBittorrent: {self.qbt_client.app.version}')
self.tl.info(f'qBittorrent Web API: {self.qbt_client.app.web_api_version}') self.tl.info(f'qBittorrent Web API: {self.qbt_client.app.web_api_version}')