-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeedsUpdate.py
More file actions
33 lines (30 loc) · 1.09 KB
/
FeedsUpdate.py
File metadata and controls
33 lines (30 loc) · 1.09 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
import pickle
import git_code
import os
from datetime import datetime
with open('feeds.p', 'rb') as f:
feeds = pickle.load(f)
# call the refresh of each feed and then write the rss feed
with open('update.log', 'a') as log:
for feed in feeds:
try:
ep = feed.refresh()
except:
log.write(str(datetime.now()))
log.write(f':\texception updating {feed.feed_title}\n')
if ep is None:
log.write(str(datetime.now()))
log.write(f':\tNo new show for {feed.feed_title}\n')
else:
log.write(str(datetime.now()))
log.write(f':\t{ep.title} added to {feed.feed_title}\n')
# write out the rss file if there is an episode added
os.chdir(r'.\docs')
feed.write_rss(feed.self_link.split(r'/')[-1])
os.chdir(r'..')
# the refresh wil download any flagged as such.
# re-pickle the feeds file:
with open('feeds.p', 'wb') as file:
pickle.dump(feeds, file)
# commit the project folder and push to github
git_code.git_push('script update ' + str(datetime.today()))