This commit is contained in:
+58
-1
@@ -1,6 +1,7 @@
|
||||
---
|
||||
title: Qbitmaid
|
||||
date: '2024-11-3'
|
||||
lastmod: '2024-11-14'
|
||||
tags: ['python', 'projects', 'code']
|
||||
draft: true
|
||||
summary: How I used python to keep my torrents in check
|
||||
@@ -8,4 +9,60 @@ layout: PostBanner
|
||||
images: ['https://s3.jonb.io/cdn/projects/qbitmaid.jpg']
|
||||
---
|
||||
|
||||
[Source Code](https://git.jonb.io/jblu/qbit-maid)
|
||||
### qbit-maid
|
||||
Development [^1] of qbitmaid was over the course of several months. At first, the project was called qbit-clean and didn't have all the features the project has now. The issue was mainly with my download cache in unraid being filled with torrents I no longer needed to seed[^2]. When I would get a notification from the server that the download cache was 95% full I would have to manually go to [qbittorrent](https://www.qbittorrent.org/), sort the torrents by age and remove the ones older than two weeks avoiding torrents I wanted to keep.
|
||||
|
||||

|
||||
|
||||
This was tedious. Very tedious. So I went off to do more work just to avoid a little.
|
||||
|
||||
`qbitmaid.py`[^3]
|
||||
```python
|
||||
...
|
||||
class Qbt:
|
||||
def __init__(self):
|
||||
"""Main object, should be calling functions from qlist.py, qlogging.py and qprocess.py"""
|
||||
...
|
||||
#logging in
|
||||
try:
|
||||
self.tl.info('Connecting to host.')
|
||||
self.qbt_client.auth_log_in()
|
||||
self.tl.info('Connected.')
|
||||
except qbittorrentapi.APIError as e:
|
||||
self.tl.exception(e)
|
||||
self.po.send_message(e, title="qbit-maid API ERROR")
|
||||
# Pulling all torrent data
|
||||
self.torrent_list = self.qbt_client.torrents_info()
|
||||
#Main process block
|
||||
if self.use_log:
|
||||
list_qbit_api_info(self)
|
||||
list_first_tor(self)
|
||||
debug_torrent_list(self)
|
||||
build_tor_list(self)
|
||||
process_counts(self)
|
||||
if self.use_log:
|
||||
torrent_count(self)
|
||||
tor_processor(self)
|
||||
if self.use_log:
|
||||
print_processor(self)
|
||||
if self.delete_torrents:
|
||||
tor_delete(self)
|
||||
self.et = datetime.datetime.now()
|
||||
get_script_runtime(self)
|
||||
if self.use_pushover:
|
||||
tor_notify_summary(self)
|
||||
if self.use_apprise:
|
||||
tor_notify_apprise(self, r, apprise_notify)
|
||||
if self.use_healthcheck:
|
||||
send_ping(self, r, self.healthcheck_url)
|
||||
# Run
|
||||
if __name__== "__main__":
|
||||
Qbt()
|
||||
```
|
||||
|
||||
This is the main file that glues the project together. This was my first project where I heavily
|
||||
[^1]: The Source Code can be found [here][source-code].
|
||||
[^2]: Private trackers require you to seed a torrent for a period of time. In my case, I have to seed for about 2 weeks or to a ratio of 1.
|
||||
[^3]: Code has been removed for examples in this article.
|
||||
|
||||
[source-code]: https://git.jonb.io/jblu/qbit-maid
|
||||
Reference in New Issue
Block a user