aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xautonyaa.py12
-rw-r--r--readme.md16
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()
diff --git a/readme.md b/readme.md
index 66b7e90..def9204 100644
--- a/readme.md
+++ b/readme.md
@@ -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