summaryrefslogtreecommitdiff
path: root/feed-transmission.py
blob: 07fb62099b82ca386c9739257fcf6316f8f57933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python

import feedparser
import re
import time
import subprocess

POLL_DELAY = 60 * 60

threads = [
    "Some thread",
]

downloadables = re.compile(r".*Thread: (?:%s)" % "|".join(threads))

def find_relavant():
    d = feedparser.parse('https://example.com/rss.php')
    found = []
    for i in d['items']:
        if not downloadables.match(i.title):
            continue
        found.append(i.link)
    return found
    
def main():
    downloaded = []
    while True:
        downloaded = downloaded[-100:]
        found = find_relavant()
        for i in found:
            if i in downloaded:
                continue
            downloaded.append(i)
            print i
            ret = subprocess.call("transmissioncli", "localhost", "-a", i)
            if ret:
                print "Error adding torrent"
        time.sleep(POLL_DELAY)

if __name__ == "__main__":
    main()