diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-01-18 14:40:02 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-01-18 14:40:02 +0100 |
commit | 71edd1fa62fc48a8c37e26a22078258b3d25a58a (patch) | |
tree | e419aad7a361c93cc1574ad5688a95e6f79361fd | |
parent | 041483f26e7e4b1982b28723a9d1c25f751d7359 (diff) |
changed config stuff
-rwxr-xr-x | autonyaa.py | 31 | ||||
-rw-r--r-- | readme.md | 5 | ||||
-rw-r--r-- | transmission.json | 6 |
3 files changed, 22 insertions, 20 deletions
diff --git a/autonyaa.py b/autonyaa.py index c888e47..e4cc144 100755 --- a/autonyaa.py +++ b/autonyaa.py @@ -1,5 +1,12 @@ #!/bin/python3 -import urllib, sys, re, requests, xml.etree.ElementTree as et +import urllib, sys, re, requests, xml.etree.ElementTree as et, transmission_rpc, os, json + +current_path = os.path.dirname(__file__) +config_file = open(current_path + "/configuration.an", "r") +transmission_rpc_file = open(current_path + "/transmission.json", "r") +transmission_rpc_config = json.loads(transmission_rpc_file.read()) + +transmission_client = transmission_rpc.Client(host='localhost', port=9091,) def generate_url(query): return "https://nyaa.si/?" + urllib.parse.urlencode({"q": query, "page": "rss"}) @@ -69,17 +76,15 @@ def parse_config_section(section): props[p["prop"]] = p["parser"](line) return props -def parse_config_file(location): +def parse_config_file(): parsed_sections = [] + contents = config_file.read() + sections = [x.strip() for x in contents.split("\n\n")] + while "" in sections: + sections.remove("") - with open(location, 'r') as file: - contents = file.read() - sections = [x.strip() for x in contents.split("\n\n")] - while "" in sections: - sections.remove("") - - for section in sections: - parsed_sections.append(parse_config_section(section)) + for section in sections: + parsed_sections.append(parse_config_section(section)) return parsed_sections @@ -87,11 +92,7 @@ def start_dl(result, section): print(result, section) def main(): - config_file = sys.argv[1] - if not config_file: - print("usage: ./autonyaa.py [config_file]") - exit(1) - sections = parse_config_file(config_file) + sections = parse_config_file() for section in sections: response = requests.get(generate_url(section["name"])).text root = et.fromstring(response) @@ -3,8 +3,3 @@ script that automatically adds new anime episodes from nyaa.si to a transmission daemon, and symlinks them once they're done downloading -## todo: - -https://pypi.org/project/transmission-rpc/ -https://transmission-rpc.readthedocs.io/en/v3.3.0/ - diff --git a/transmission.json b/transmission.json new file mode 100644 index 0000000..4f4bd31 --- /dev/null +++ b/transmission.json @@ -0,0 +1,6 @@ +{ + "host": "localhost", + "port": 9091, + "username": "transmission", + "password": "haha no" +} |