-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron_rss.py
More file actions
82 lines (57 loc) · 1.81 KB
/
cron_rss.py
File metadata and controls
82 lines (57 loc) · 1.81 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
RSS Notipy
RSS Serach Cronjob file
use it with crontab or in a thread every ~ 2h (see config)
2020 maschhoff github.com/maschhoff
"""
import searchfile
import rssreader
import collections
from difflib import SequenceMatcher
import settings
import noti
import re
config=settings.loadConfig()
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
def run():
print("... Running Cron RSS ...")
search=searchfile.loadSearchfile()
#Load all entrys from rss resources
x_movies={}
rss=config["rss"]
for rel in rss:
x_movies.update(rssreader.getRSSTitles(rss[rel])) # Merge dicts
#Iterate search and rss results
for film in search:
#print("Suche nach: "+film["film"])
for movie, link in x_movies.items():
#print(movie+"\t"+link)
#Split on year
split=movie.split("20")
#to lowercase without special characters and spaces
lmovie=movie.lower()
lfilm=film["film"].lower()
lmovie = (" ".join(re.findall(r"[A-Za-z0-9]*", lmovie))).replace(" ","")
lfilm = (" ".join(re.findall(r"[A-Za-z0-9]*", lfilm))).replace(" ","")
#result
gefunden=False
#method1 - found by substring in string
if lfilm in lmovie and film["quality"] in movie and film["date"] in movie:
#print("METHOD1: "+lfilm+"\t"+lmovie)
gefunden=True
#method2 - found by similary in percent
if similar(film["film"],split[0]) > 0.8 and film["quality"] in movie and film["date"] in movie:
#print("METHOD2: "+movie)
gefunden=True
if gefunden:
#print("GEFUNDEN: "+movie+"\t"+link)
#Notify
if not film["listed"]:
noti.notifyAll(film["film"])
#Change and save
film["listed"]=True
if not link in film["urls"]:
film["urls"].append(link)
searchfile.writeSearchfile(search)
#run()