-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathepg.py
293 lines (293 loc) · 14 KB
/
epg.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
import datetime
import string
import math
def ToDay():
global year
year = datetime.datetime.now().year
global month
month = '%02d' % datetime.datetime.now().month
global day
day = '%02d' % datetime.datetime.today().day
global hour
hour = '%02d' % datetime.datetime.now().hour
global minute
minute = '%02d' % datetime.datetime.now().minute
global second
second = '%02d' % datetime.datetime.now().second
global numbers
numbers = str(year) + str(month) + str(day) + str(day) + str(hour) + str(second) + "00"
ToDay()
StartYear = int(year)
StartMonth = int(month)
StartDay = int(day)
StartHour = int(hour)
StartMinute = int(minute)
StartSecond = int(second)
ToDay()
EndYear = int(year)
EndMonth = int(month)
EndDay = int(day)
EndHour = int(hour)
EndMinute = int(minute)
EndSecond = int(second)
MinuteLength = EndMinute - StartMinute
SecondLength = EndSecond - StartSecond
def DoubleDigit(Integer):
return "%02d"%Integer
def PlusOneDay():
global year
year = int(year)
global month
month = int(month)
global day
day = int(day)
global hour
hour = int(hour)
global minute
minute = int(minute)
global second
second = int(second)
global numbers
if day is 30:
day = DoubleDigit(0)
else:
day = DoubleDigit(day + 1)
month = DoubleDigit(month)
numbers = str(year) + str(month) + str(day) + str(day) + str(hour) + str(second) + "00"
def RetPlusOneDay():
global year
year = int(year)
global month
month = int(month)
global day
day = int(day)
global hour
hour = int(hour)
global minute
minute = int(minute)
global second
second = int(second)
global numbers
if day is 30:
day = DoubleDigit(0)
else:
day = DoubleDigit(day + 1)
month = DoubleDigit(month)
return str(year) + str(month) + str(day) + str(day) + str(hour) + str(second) + "00"
def RetPlusOneHour():
global year
year = int(year)
global month
month = int(month)
global day
day = int(day)
global hour
hour = int(hour)
if hour is 23:
hour = DoubleDigit(0)
else:
hour = hour + 1
hour = DoubleDigit(hour)
global minute
minute = int(minute)
global second
second = int(second)
global numbers
if day is 30:
day = DoubleDigit(0)
else:
day = DoubleDigit(day + 1)
if month is 11:
month = DoubleDigit(0)
year = year + 1
else:
month = DoubleDigit(month + 1)
return str(year) + str(month) + str(day) + str(day) + str(hour) + str(second) + "00"
print RetPlusOneHour()
DoubleDigit(8)
prompt = raw_input("Are you sure you want to run this program? Avg. run time: 1m 25s.")
if "yes" in prompt:
pass
elif "Yes" in prompt:
pass
elif "y" in prompt:
pass
elif "Y" in prompt:
pass
elif "yeah" in prompt:
pass
elif "Yeah" in prompt:
pass
elif "ok" in prompt:
pass
elif "OK" in prompt:
pass
elif "okay" in prompt:
pass
elif "Okay" in prompt:
pass
else:
exit()
def ABC1():
ToDay()
global year
year = int(year)
global month
month = int(month)
global day
day = int(day)
global hour
hour = int(hour)
global minute
minute = int(minute)
global second
second = int(second)
i = 0
Program = []
for i in range(0, 365):
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneHour() + '00 -0400" channel="ABCN1"><title lang="en">Now on ABC News</title><category lang="en">News</category></programme>')
i = i + 1
print str(round(float(i)/365*100, 1)) + "% of ABC News Digital 1 Schedule Complete."
return Program
ABC1 = ABC1()
def ABC2():
ToDay()
global year
year = int(year)
global month
month = int(month)
global day
day = int(day)
global hour
hour = int(hour)
global minute
minute = int(minute)
global second
second = int(second)
i = 0
Program = []
for i in range(0, 365):
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneDay() + '00 -0400" channel="ABCN2"><title lang="en">Regularly Scheduled Programming</title><category lang="en">News</category></programme>')
i = i + 1
print str(round(float(i)/365*100, 1)) + "% of ABC News Digital 2 Schedule Complete."
return Program
ABC2 = ABC2()
def ABC3():
ToDay()
global year
year = int(year)
global month
month = int(month)
global day
day = int(day)
global hour
hour = int(hour)
global minute
minute = int(minute)
global second
second = int(second)
i = 0
Program = []
for i in range(0, 365):
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneDay() + '00 -0400" channel="ABCN3"><title lang="en">Regularly Scheduled Programming</title><category lang="en">News</category></programme>')
i = i + 1
print str(round(float(i)/365*100, 1)) + "% of ABC News Digital 3 Schedule Complete."
return Program
ABC3 = ABC3()
def ABC4():
ToDay()
global year
year = int(year)
global month
month = int(month)
global day
day = int(day)
global hour
hour = int(hour)
global minute
minute = int(minute)
global second
second = int(second)
i = 0
Program = []
for i in range(0, 365):
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneDay() + '00 -0400" channel="ABCN4"><title lang="en">Regularly Scheduled Programming</title><category lang="en">News</category></programme>')
i = i + 1
print str(round(float(i)/365*100, 1)) + "% of ABC News Digital 4 Schedule Complete."
return Program
ABC4 = ABC4()
def ABC5():
ToDay()
global year
year = int(year)
global month
month = int(month)
global day
day = int(day)
global hour
hour = int(hour)
global minute
minute = int(minute)
global second
second = int(second)
i = 0
Program = []
for i in range(0, 365):
Program.append('<programme start="' + str(year) + str(month) + str(day) + str(hour) + str(second) + '00 -0400" stop="' + RetPlusOneDay() + '00 -0400" channel="ABCN5"><title lang="en">Regularly Scheduled Programming</title><category lang="en">News</category></programme>')
i = i + 1
print str(round(float(i)/365*100, 1)) + "% of ABC News Digital 5 Schedule Complete."
return Program
#File = open('workfile', 'w')
Filee = '<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE tv SYSTEM "http://www.teleguide.info/download/xmltv.dtd"><tv generator-info-name="LegalStream Python EPG Generator" generator-info-url=https://github.com/notanewbie/LegalStream/blob/master/epg.py"><channel id="300093"><display-name lang="en">France 24</display-name></channel><channel id="ABCN1"><display-name lang="en">ABC News Digital 1</display-name></channel><channel id="ABCN2"><display-name lang="en">ABC News Digital 2</display-name></channel><channel id="ABCN3"><display-name lang="en">ABC News Digital 3</display-name></channel><channel id="ABCN4"><display-name lang="en">ABC News Digital 4</display-name></channel><channel id="ABCN5"><display-name lang="en">ABC News Digital 5</display-name></channel>'
i = 0
for object in ABC1:
Filee = Filee + ABC1[i]
i = i + 1
i = 0
for object in ABC2:
Filee = Filee + ABC2[i]
i = i + 1
i = 0
for object in ABC3:
Filee = Filee + ABC3[i]
i = i + 1
i = 0
for object in ABC4:
Filee = Filee + ABC4[i]
i = i + 1
file_ = open('output.xml', 'w')
file_.write(Filee + "</tv>")
file_.close()
ToDay()
EndYear = int(year)
EndMonth = int(month)
EndDay = int(day)
EndHour = int(hour)
EndMinute = int(minute)
EndSecond = int(second)
MinuteLength = EndMinute - StartMinute
SecondLength = EndSecond - StartSecond
print "Generating EPG data took " + str(MinuteLength) + "m and " + str(SecondLength) + "s."