Category whitelist #10
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
config.json
|
||||
*.log
|
||||
*.json
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
12
README.md
12
README.md
@ -44,6 +44,16 @@ Config.json
|
||||
"po_token": ""
|
||||
}
|
||||
```
|
||||
|
||||
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",
|
||||
"example2": "sonarr"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
| Key | Value |
|
||||
| --- | --- |
|
||||
| host | string, ip or hostname of qbittorrent server |
|
||||
@ -51,6 +61,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 |
|
||||
|
3
category-whitelist.json.example
Normal file
3
category-whitelist.json.example
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"example": "general"
|
||||
}
|
@ -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('./category-whitelist.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__":
|
||||
|
14
qlist.py
14
qlist.py
@ -4,13 +4,12 @@ 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['category'] == 'tech':
|
||||
if torrent['category'] in self.cat_whitelist.values():
|
||||
self.tl.info(f'Ignored torrent:["{torrent["name"][0:20]}..."]')
|
||||
continue
|
||||
if torrent['tracker'] == '':
|
||||
if self.use_log:
|
||||
@ -19,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)
|
||||
|
||||
@ -56,4 +53,7 @@ def torrentcount(self):
|
||||
|
||||
def tordeletetags(self):
|
||||
tag_list = ['ipt','public','iptorrents']
|
||||
self.qbt_client.torrents_delete_tags(tag_list)
|
||||
self.qbt_client.torrents_delete_tags(tag_list)
|
||||
|
||||
def torlisttags(self):
|
||||
pass
|
@ -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 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user