From dc8ad10e73c9f923e91a734e2f5f14b47f4ebbaa Mon Sep 17 00:00:00 2001 From: jblu Date: Fri, 22 Jul 2022 23:45:57 -0500 Subject: [PATCH 1/4] #3 added cat whitelist and updated readme --- .gitignore | 2 +- README.md | 11 +++++++++++ category-whitelist.json.example | 3 +++ qlist.py | 8 ++++++-- qprocess.py | 2 +- ...r-whitelist.json => tracker-whitelist.json.example | 0 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 category-whitelist.json.example rename tracker-whitelist.json => tracker-whitelist.json.example (100%) diff --git a/.gitignore b/.gitignore index 86da721..af0d4f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -config.json *.log +*.json # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/README.md b/README.md index f0be0f5..29f03df 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,15 @@ Config.json "po_token": "" } ``` + +You will need a tracker-whitelist.json in the root directory +``` +{ + "example": "general" +} +``` + + | Key | Value | | --- | --- | | host | string, ip or hostname of qbittorrent server | @@ -51,6 +60,8 @@ Config.json | username | admin account for qbittorrent | | password | password for admin account | | loglevel | is what log messages are written to the log file. INFO or DEBUG are valid entries(case sensitive) | +| protected_tag | used to mark torrents to handle with care | +| non_protected_tag | we don't care about these torrents | | logpath | will write a log in root directory if left as is other wise specify other path using forward slashes | | age | number, seconds for how long we keep torrents from IPTORRENTS | | use_pushover | true or false to enable or disable pushover notification summary | diff --git a/category-whitelist.json.example b/category-whitelist.json.example new file mode 100644 index 0000000..5510278 --- /dev/null +++ b/category-whitelist.json.example @@ -0,0 +1,3 @@ +{ + "example": "general" +} \ No newline at end of file diff --git a/qlist.py b/qlist.py index 3bd0f98..6cb9cf8 100644 --- a/qlist.py +++ b/qlist.py @@ -10,7 +10,8 @@ def buildtorlist(self): torrent = self.torrentlist.pop() if self.use_log: self.tl.debug(f'["{torrent["name"][0:20]}..."] {torrent["infohash_v1"]}') - if torrent['category'] == 'tech': + if torrent['tags'] in self.cat_whitelist.values(): + self.tl.info(f'Ignored torrent:["{torrent["name"][0:20]}..."]') continue if torrent['tracker'] == '': if self.use_log: @@ -56,4 +57,7 @@ def torrentcount(self): def tordeletetags(self): tag_list = ['ipt','public','iptorrents'] - self.qbt_client.torrents_delete_tags(tag_list) \ No newline at end of file + self.qbt_client.torrents_delete_tags(tag_list) + +def torlisttags(self): + pass \ No newline at end of file diff --git a/qprocess.py b/qprocess.py index 1f629f2..4cbc570 100644 --- a/qprocess.py +++ b/qprocess.py @@ -3,7 +3,7 @@ def torprocessor(self): If torrent meets criteria for deletion, its infohash_v1 will be appended to self.torrent_hash_delete_list """ for canidate in self.tracker_nonprotected_list: - if 'ipt' in canidate['tags']: + if canidate['tags'] in self.cat_whitelist.values(): if self.use_log: self.tl.warning(f'["{canidate["name"][0:20]}..."] was in non-protected list.') continue diff --git a/tracker-whitelist.json b/tracker-whitelist.json.example similarity index 100% rename from tracker-whitelist.json rename to tracker-whitelist.json.example -- 2.45.2 From 31c953d6981ce24e974c53ecb8c57cf891eec3a4 Mon Sep 17 00:00:00 2001 From: jblu Date: Fri, 22 Jul 2022 23:46:48 -0500 Subject: [PATCH 2/4] tweaks to the main file --- qbit-maid.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qbit-maid.py b/qbit-maid.py index 84cdefb..293054c 100644 --- a/qbit-maid.py +++ b/qbit-maid.py @@ -14,6 +14,8 @@ class Qbt: # Open the config. Needs a json file with the data in config.json.example c = open('./config.json') self.config = load(c) + w = open('./config.json') + self.cat_whitelist = load(w) # Create the api object self.qbt_client = qbittorrentapi.Client( host=self.config["host"], @@ -69,7 +71,7 @@ class Qbt: printprocessor(self) if self.use_pushover: tornotifysummary(self) - #tordelete(self) + tordelete(self) # Run if __name__== "__main__": -- 2.45.2 From 27bc8e171b8356746e37eff0abfcbdd0725395f2 Mon Sep 17 00:00:00 2001 From: jblu Date: Fri, 22 Jul 2022 23:50:35 -0500 Subject: [PATCH 3/4] updated the readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 29f03df..d866bdd 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,11 @@ Config.json } ``` -You will need a tracker-whitelist.json in the root directory +You will need a category-whitelist.json in the root directory. This will ignore any of the categories found in the values of the entries. ``` { - "example": "general" + "example": "general", + "example2": "sonarr" } ``` -- 2.45.2 From 972e9bc517394a6ce3665f9442388fbe5d0ec1ca Mon Sep 17 00:00:00 2001 From: jblu Date: Sat, 23 Jul 2022 00:42:05 -0500 Subject: [PATCH 4/4] fixed reading cat file --- qbit-maid.py | 2 +- qlist.py | 8 ++------ qprocess.py | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/qbit-maid.py b/qbit-maid.py index 293054c..35a8906 100644 --- a/qbit-maid.py +++ b/qbit-maid.py @@ -14,7 +14,7 @@ class Qbt: # Open the config. Needs a json file with the data in config.json.example c = open('./config.json') self.config = load(c) - w = open('./config.json') + w = open('./category-whitelist.json') self.cat_whitelist = load(w) # Create the api object self.qbt_client = qbittorrentapi.Client( diff --git a/qlist.py b/qlist.py index 6cb9cf8..f4d3fb1 100644 --- a/qlist.py +++ b/qlist.py @@ -4,13 +4,11 @@ def buildtorlist(self): V2 will certainly be more performant. The reason two lists were used was so that torrents that are in public trackers woudln't be around as long as torrents from a private tracker. """ - self.protected_count = 0 - self.nonprotected_count = 0 while self.torrentlist: torrent = self.torrentlist.pop() if self.use_log: self.tl.debug(f'["{torrent["name"][0:20]}..."] {torrent["infohash_v1"]}') - if torrent['tags'] in self.cat_whitelist.values(): + if torrent['category'] in self.cat_whitelist.values(): self.tl.info(f'Ignored torrent:["{torrent["name"][0:20]}..."]') continue if torrent['tracker'] == '': @@ -20,13 +18,11 @@ def buildtorlist(self): if torrent['tracker'].split('/')[2] in self.tracker_whitelist.values(): if self.use_log: self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}') - self.protected_count += 1 self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash']) self.tracker_protected_list.append(torrent) - elif torrent['tracker'].split('/')[2] not in self.tracker_whitelist.values(): + if torrent['tracker'].split('/')[2] not in self.tracker_whitelist.values(): if self.use_log: self.tl.debug(f'Non-protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}') - self.nonprotected_count += 1 self.qbt_client.torrents_add_tags(self.tracker_non_protected_tag,torrent['hash']) self.tracker_nonprotected_list.append(torrent) diff --git a/qprocess.py b/qprocess.py index 4cbc570..0147b17 100644 --- a/qprocess.py +++ b/qprocess.py @@ -3,7 +3,7 @@ def torprocessor(self): If torrent meets criteria for deletion, its infohash_v1 will be appended to self.torrent_hash_delete_list """ for canidate in self.tracker_nonprotected_list: - if canidate['tags'] in self.cat_whitelist.values(): + if self.config["protected_tag"] in canidate['tags']: if self.use_log: self.tl.warning(f'["{canidate["name"][0:20]}..."] was in non-protected list.') continue -- 2.45.2