forked from DickyB/LANTV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showschedule
executable file
·230 lines (196 loc) · 5.51 KB
/
showschedule
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
#!/usr/bin/python
#
# showschedule: Dicky B ([email protected])
#
# writes the last few shows and next few shows to dyntext2, as
# defined in channel.conf in the channel subdirectory.
#
# Note: Episode numbers and movie titles may be wonky and require
# some tweaking to display correctly.
#
# Note: ffmpeg needs to have text overlay support for
# text overlays. Requires recompile, usually.
#
import datetime
import os
import sys
import func
#get basepath
basepath=os.path.dirname(os.path.realpath(__file__))+'/'
if len(sys.argv)!= 2:
print "Usage: showschedule <channel>"
exit()
#get current time
#DOW 0=Monday ... 6=Sunday
DOW=func.getDayOfWeek()
NowHour=func.getCurrentHour()
NowMinute=func.getCurrentMinute()
NowSecond=func.getCurrentSecond()
TODMin=func.getTODMin()
#this entire hunk sets up the config.
#there is cruft in this bit. Left it Just In Case for now.
channelPath=""
ffmpeg = ""
ffmpegpath = ""
logoimage=""
feedurl = ""
dyntext1=""
dyntext2=""
dyntext3=""
dynfont1 = ""
dynfont2 = ""
dynfont3 = ""
inphone = ""
inphonefont = ""
splashpath=""
splashname=""
splashext=""
savesched=""
name = sys.argv[1]
channelName=name
channelPath=basepath+channelName+'/'
progfile=channelPath+'schedule'
savesched=channelPath+'display.schedule'
idxpath=channelPath+'index/'
f = open(channelPath+'channel.conf')
lines=f.readlines()
f.close()
for b in lines:
c=b.strip()
line=c.split('=')
if line[0].strip() == 'ffmpeg':
ffmpegname=line[1].strip()
if line[0].strip() == 'ffmpegpath':
ffmpegpath=line[1].strip()
if line[0].strip() == 'channelfullname':
channelFullName=line[1].strip()
if line[0].strip() == 'showspath':
showspath=line[1].strip()
if line[0].strip() == 'feedurl':
feedurl=line[1].strip()
if line[0].strip() == 'splashpath':
splashpath=line[1].strip()
if line[0].strip() == 'splashname':
splashname=line[1].strip()
if line[0].strip() == 'splashext':
splashext=line[1].strip()
if line[0].strip() == 'dyntext1':
dyntext1=line[1].strip()
if line[0].strip() == 'dynfont1':
dynfont1=line[1].strip()
if line[0].strip() == 'dyntext2':
dyntext2=line[1].strip()
if line[0].strip() == 'dynfont2':
dynfont2=line[1].strip()
if line[0].strip() == 'dyntext3':
dyntext3=line[1].strip()
if line[0].strip() == 'dynfont3':
dynfont3=line[1].strip()
if line[0].strip() == 'inphone':
inphone=line[1].strip()
if line[0].strip() == 'phonefont':
inphonefont=line[1].strip()
if line[0].strip() == 'logoimage':
logoimage=line[1].strip()
ffmpegcmd = ffmpegpath+ffmpegname
fontpath = basepath+'Font/'
logopath = basepath+'Logo/'+logoimage
#end config init
todaysched=progfile+'.'+str(DOW)
if os.path.isfile(todaysched):
progfile=todaysched
#read program schedule
f = open(progfile,"r")
proglines = f.readlines()
f.close()
enablerollover=False
displaysched=[]
if NowHour > 17:
enablerollover=True
FirstHour = NowHour - 2
if FirstHour < 0:
FirstHour=FirstHour+24
for z in range(0,5):
for x in range(0,len(proglines)):
s = proglines[x].split(':')
if len(s)>3:
start1 = int(s[0])
startmins=int(s[1])+(int(s[0])*60)
dl=":"
cs = s[3]
cshow=cs
MovieName=False
if FirstHour == start1:
ext="am"
shower=str(FirstHour)
mower=int(s[1])
showmin=str(mower)
gg = s[4:]
fshow=dl.join(gg).strip()
if FirstHour > 11:
ext="pm"
shower=str(FirstHour-12)
if FirstHour == 12:
shower=str(12)
if FirstHour == 0:
shower=str(12)
if int(shower) < 10:
shower="0"+shower
if mower < 10:
showmin="0"+showmin
#get next episode
nextep="1"
if os.path.isfile(idxpath+cshow+".idx"):
f = open(idxpath+cshow+".idx","r")
tmp=f.readlines()
f.close()
nextep=tmp[0].strip()
#oops
ne=int(nextep)+1
nextep=str(ne)
if fshow[0]=='*':
if TODMin >= startmins:
ne=ne-1
sp = showspath+s[3]+'title'
sip = channelName
ifp = idxpath
bif= sp+' '+channelName+' '+basepath+' '+ifp+' '+str(ne)
os.system(bif)
MovieName=True
f = open(channelPath+'tmp.name','r')
tmps=f.readlines()
f.close()
fpa=tmps[0].strip()
tpa=os.path.basename(fpa)
eshow = tpa[:-4]
if len(fshow) < 2:
fshow = eshow
else:
fshow = fshow[1:]+': '+eshow
os.remove(channelPath+'tmp.name')
if MovieName:
displaysched.append(" "+shower+":"+showmin+ext+' '+fshow+'\n')
else:
displaysched.append(" "+shower+":"+showmin+ext+' '+fshow+' #'+nextep+'\n')
FirstHour=FirstHour+1
if FirstHour>23:
FirstHour=0
center=(38/2)-(len(channelFullName)/2)
cstring=""
for m in range(0,center):
cstring=cstring+" "
cstring="\n"+cstring
f = open(dyntext2,"r+")
f.seek(0)
f.truncate(0)
f.write(cstring+channelFullName+'\n')
f.write("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n")
f.writelines(displaysched)
f.write("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n")
f.close()
f = open(savesched,"w")
f.write(cstring+channelFullName+'\n')
f.write("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n")
f.writelines(displaysched)
f.write("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n")
f.close()