-
Notifications
You must be signed in to change notification settings - Fork 0
/
amazonEC2.py
executable file
·40 lines (34 loc) · 1.43 KB
/
amazonEC2.py
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
#!/usr/bin/python2.7
import TheTvDbEpisode
import nextEpisode
import sys
import json
from datetime import datetime
sendMessage = "Here are the series airing today (ET).\n"
episodeToday = False
errorPresent = False
myFavouries = TheTvDbEpisode.getMyFavorites()
token = TheTvDbEpisode.authenticate()
todaysDate = datetime.now().date()
for series in myFavouries:
try:
seriesName, seriesTime = TheTvDbEpisode.getSeriesNameTime(series)
seriesNameFormatted = nextEpisode.tvShowURL(seriesName)
latestEpisodes = nextEpisode.previousNext(seriesNameFormatted)
later = latestEpisodes["nextEpisode"]
nextAirDate = later["airDate"]
if nextAirDate:
nextAirDateFormatted = datetime.strptime(nextAirDate[0], '%a %b %d, %Y').date()
if nextAirDateFormatted == todaysDate:
episodeToday = True
sendMessage += "%s airs at %s in %s\n" % (str(seriesName), str(seriesTime), str(later["countDown"][0]))
except Exception as err:
print "Exception occured for %s: %s" % (seriesName, err)
errorPresent = True
print "CRON job date: " + str(todaysDate)
if episodeToday:
if errorPresent:
sendMessage += str("\nAn error occured while retrieving the data")
TheTvDbEpisode.sendSMS(sendMessage)
else:
TheTvDbEpisode.sendSMS("No series airing today.\nAn error occured while retrieving the data") if errorPresent else TheTvDbEpisode.sendSMS("No series airing today")