Skip to content

Commit

Permalink
Merge pull request #72 from StuffAnThings/develop
Browse files Browse the repository at this point in the history
v3.1.2
  • Loading branch information
bobokun committed Dec 29, 2021
2 parents d13f14c + d0dbbaa commit 062b32a
Show file tree
Hide file tree
Showing 12 changed files with 756 additions and 567 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ venv
.idea
.venv
test.py
!config/config.yml.sample
!config/config.yml.sample
.flake8
11 changes: 11 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[flake8]
ignore =
E226, # E226 Missing whitespace around arithmetic operator
#E302, # E302 Expected 2 blank lines, found 0
E401, # E401 Multiple imports on one line
E701, # E701 Multiple statements on one line (colon)
E241, # E241 Multiple spaces after ','
E272, # E272 Multiple spaces before keyword
C901 # C901 Function is too complex
E722 # E722 Do not use bare except, specify exception instead
max-line-length = 200
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.1
3.1.2
13 changes: 10 additions & 3 deletions config/config.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ qbt:
user: "username"
pass: "password"

settings:
force_auto_tmm: False # Will force qBittorrent to enable Automatic Torrent Management for each torrent.

directory:
# Do not remove these
# Cross-seed var: </your/path/here/> # Output directory of cross-seed
Expand All @@ -19,12 +22,12 @@ directory:

# Category & Path Parameters
cat:
# <Category Name> : <save_path> # Path of your save directory. Can be a keyword or full path
# <Category Name> : <save_path> # Path of your save directory.
movies: "/data/torrents/Movies"
tv: "TV"
tv: "/data/torrents/TV"

# Tag Parameters
tags:
tracker:
# <Tracker URL Keyword>: # <MANDATORY> This is the keyword in the tracker url
# <MANDATORY> Set tag name
# tag: <Tag Name>
Expand Down Expand Up @@ -170,3 +173,7 @@ webhooks:
rem_orphaned: notifiarr
tag_nohardlinks: notifiarr
empty_recyclebin: notifiarr

# BHD Integration used for checking unregistered torrents
bhd:
apikey:
5 changes: 2 additions & 3 deletions modules/apprise.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import logging

from modules.util import Failed

logger = logging.getLogger("qBit Manage")


class Apprise:
def __init__(self, config, params):
self.config = config
self.api_url = params["api_url"]
self.notify_url = ",".join(params["notify_url"])
response = self.config.get(self.api_url)
if response.status_code != 200:
raise Failed(f"Apprise Error: Unable to connect to Apprise using {self.api_url}")
raise Failed(f"Apprise Error: Unable to connect to Apprise using {self.api_url}")
33 changes: 33 additions & 0 deletions modules/bhd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging
from modules.util import Failed
from json import JSONDecodeError

logger = logging.getLogger("qBit Manage")
base_url = "https://beyond-hd.me/api/"


class BeyondHD:
def __init__(self, config, params):
self.config = config
self.apikey = params["apikey"]
json = {"search": "test"}
self.search(json)

def search(self, json, path="torrents/"):
url = f"{base_url}{path}{self.apikey}"
json["action"] = "search"
if self.config.trace_mode:
logger.debug(url.replace(self.apikey, "APIKEY"))
logger.debug(f"JSON: {json}")
try:
response = self.config.post(url, json=json)
response_json = response.json()
except JSONDecodeError as e:
if response.status_code >= 400:
raise Failed(e)
if response.status_code >= 400:
logger.debug(f"Response: {response_json}")
raise Failed(f"({response.status_code} [{response.reason}]) {response_json}")
if not response_json["success"]:
raise Failed(f"BHD Error: {response_json['status_message']}")
return response.json()
273 changes: 151 additions & 122 deletions modules/config.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions modules/notifiarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, config, params):
except JSONDecodeError as e:
if response.status_code >= 400:
if response.status_code == 525:
raise Failed(f"Notifiarr Error (Response: 525): SSL handshake between Cloudflare and the origin web server failed.")
raise Failed("Notifiarr Error (Response: 525): SSL handshake between Cloudflare and the origin web server failed.")
else:
raise Failed(e)
if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"):
Expand All @@ -37,7 +37,7 @@ def get_url(self, path):
if self.config.trace_mode:
logger.debug(url.replace(self.apikey, "APIKEY"))
if self.test:
params = {"event": f"qbitManage-{self.apikey[:5]}", "qbit_client":self.config.data["qbt"]["host"], "instance":self.instance}
params = {"event": f"qbitManage-{self.apikey[:5]}", "qbit_client": self.config.data["qbt"]["host"], "instance": self.instance}
else:
params = {"qbit_client":self.config.data["qbt"]["host"], "instance":self.instance}
return url, params
params = {"qbit_client": self.config.data["qbt"]["host"], "instance": self.instance}
return url, params
Loading

0 comments on commit 062b32a

Please sign in to comment.