diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-01-19 18:31:36 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-01-19 18:31:36 +0100 |
commit | a74e31ef38eb7a14d630578a77d8d273b9a83626 (patch) | |
tree | 8058600fdee2158d37dc34e75f39a2fb37a96a19 | |
parent | ffa309ed1850cb0334e219162246c1868f1d43e1 (diff) |
implement episodes
-rwxr-xr-x | autonyaa.py | 12 | ||||
-rw-r--r-- | readme.md | 16 |
2 files changed, 24 insertions, 4 deletions
diff --git a/autonyaa.py b/autonyaa.py index 8890ac9..67160af 100755 --- a/autonyaa.py +++ b/autonyaa.py @@ -59,7 +59,8 @@ def parse_config_prop_destination(line): return line[12:].strip() def parse_config_prop_episodes(line): - return int(line[9:].strip()) + parsed = line[9:].strip().split(" ") + return { "var": parsed[0], "count": int(parsed[1]) } config_props = [ {"prop": "name", "parser": parse_config_prop_name}, @@ -77,7 +78,7 @@ def parse_config_section(section): "match-submitter": [], "match-name": None, "destination": "", - "episodes": 0, + "episodes": {"var": None, "count": 0}, } lines = section.split("\n") for line in lines: @@ -98,6 +99,9 @@ def parse_config_file(): return parsed_sections +def episode_limit_reached(section, vars): + return int(vars[section["episodes"]["var"]]) > section["episodes"]["count"] + def start_dl(result, section, vars): hash = result.findtext("nyaa:infoHash", None, {"nyaa": "https://nyaa.si/xmlns/nyaa"}) torrent = [t for t in torrents if t.hashString == hash] @@ -122,7 +126,9 @@ def main(): results = root[0].findall("item") for result in results: match = section["match-name"](result.findtext("title")) - if match[0]: start_dl(result, section, match[1]) + if not match[0]: continue + if episode_limit_reached(section, match[1]): continue + start_dl(result, section, match[1]) if __name__ == "__main__": main() @@ -87,9 +87,23 @@ destination <folder> destination folder +### episodes + +``` +episodes <var> <int> +``` + +limit episode download count using variable from [match-name](#match-name). + +example + +``` +episodes e 12 +``` + ## todo -- [ ] implement episode limit +- [x] implement episode limit - [x] implement match-submitter |