AutoHotkey

. ; ; ; , ; .
www.autohotkey.com

“ ”, , .

IP-TV Player EPG

IP-TV Player. , « P », XMLTV/JTV . : , , , , . « [ » « ] » . IP-TV Player. , , , , , .
zip-.
: 8.60
: 2010-06-13
: 2285 ()
:
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
/*
XMLTV/JTV IP-TV Player
Big Digger

• Windows XP/Vista/7
• AutoHotkey v1.0.48.05 http://www.autohotkey.com/download/
• 7-Zip Command Line Version http://www.7-zip.org/download.html
• IP-TV Player v0.28.1 (build 8781) http://borpas.info/iptvplayer
*/

#NoEnv
#SingleInstance, Force
DetectHiddenWindows, On
SetTitleMatchMode, RegEx

;

SevenZipExe := A_ScriptDir . "\7za.exe" ; 7-Zip
DownloadPath := A_ScriptDir ;
DownloadFile := "stc.xml.zip" ;
UpdateOnReload := True ; () (True False)
UpdateInterval = 0 ; ( , 0 - )
DeleteOutdated := True ; XML (True False)
; / XML JTV:
XMLFilePattern := "stc-????????-????????.xml" ; ? - , * -
; ( , channel id XML JTV ):
CH1 := "stc.1.ru|0" ; 1: <channel id="stc.1.ru"> XML "stc.1.ru.ndx", 0
CH2 := "stc.2.ru|0"
CH3 := "stc.3.ru|0"
CH4 := "stc.4.ru|0"
CH5 := "stc.5.ru|0"
CH6 := "stc.6.ru|0"
CH7 := "stc.7.ru|0"
CH8 := "stc.8.ru|0"
CH9 := "stc.9.ru|0"
CH10 := "stc.10.ru|0"
CH11 := "stc.11.ru|0"
CH12 := "stc.12.ru|0"
CH13 := "stc.13.ru|0"
CH14 := "stc.15.ru|0"
CH15 := "stc.20.ru|0"
CH16 := "stc.21.ru|0"
CH17 := "stc.22.ru|0"
CH18 := "stc.23.ru|0"
CH19 := "stc.24.ru|0"
CH20 := "stc.26.ru|0"
CH21 := "stc.27.ru|0"
CH22 := "stc.28.ru|0"
CH23 := "stc.29.ru|0"
CH24 := "stc.30.ru|0"
CH25 := "stc.31.ru|0"
CH26 := "stc.32.ru|0"
CH27 := "stc.33.ru|0"
CH28 := "stc.34.ru|0"
CH29 := "stc.35.ru|0"
CH30 := "stc.36.ru|0"
CH31 := "stc.37.ru|0"
CH32 := "stc.38.ru|0"
CH33 := "stc.39.ru|0"
CH34 := "stc.40.ru|0"
CH35 := "stc.41.ru|0"
CH36 := "stc.42.ru|0"
CH37 := "stc.43.ru|0"
CH38 := "stc.44.ru|0"
CH39 := "stc.45.ru|0"
CH40 := "stc.46.ru|0"
CH41 := "stc.47.ru|0"
CH42 := "stc.48.ru|0"
CH43 := "stc.49.ru|0"
CH44 := "stc.50.ru|0"
CH45 := "stc.51.ru|0"
CH46 := "stc.52.ru|0"
CH47 := "stc.53.ru|0"
CH48 := "stc.54.ru|0"
CH49 := "stc.55.ru|0"
CH50 := "stc.58.ru|0"
CH51 := "stc.60.ru|0"
CH52 := "stc.65.ru|0"
CH53 := "stc.66.ru|0"
CH54 := "stc.68.ru|0"
CH55 := "stc.69.ru|0"
CH56 := "stc.73.ru|0"
CH57 := "stc.75.ru|0"
CH58 := "stc.76.ru|0"
CH59 := "stc.77.ru|0"
CH60 := "stc.78.ru|0"
CH61 := "stc.79.ru|0"
CH62 := "stc.80.ru|0"
CH63 := "stc.81.ru|0"
CH64 := "stc.82.ru|0"
CH65 := "stc.111.ru|0"
CH66 := "stc.112.ru|0"
CH67 := "stc.116.ru|0"
; :
EPGDelay = 5 ; ( )
EPGColor := "202020" ; (HTML- RGB-)
EPGTransColor := "202020" ; (HTML- RGB-)
EPGMargins = 15 ; ( )
EPGFontSize = 32 ; ( )
EPGFontColor := "EFEFEF" ; (HTML- RGB-)
EPGFontName := "Arial" ; ( )
EPGOutlineColor := "Black" ; (HTML- RGB-)
EPGTitleStyle := "bold" ; (bold, italic, strike, underline)
EPGDescStyle := "bold italic" ; (bold, italic, strike, underline)
EPGTitleRows = 2 ;
EPGDescRows = 2 ; (0 - )
EPGProgressColor := "66A6E6" ; (HTML- RGB-)
EPGProgressBackground := "EFEFEF" ; (HTML- RGB-)

; : , , !

;
Menu, Tray, Tip, IP-TV Player EPG

GroupAdd, IpTvPlayer, ^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass
GroupAdd, IpTvPlayer, ^IP-TV Player$ ahk_class IpTvPlayerMainWndClass

DownloadFilePath = %DownloadPath%\%DownloadFile%
If (UpdateInterval > 0 && UpdateInterval < 1192.8)
SetTimer, DownloadUpdate, % UpdateInterval*3600000
If (UpdateOnReload = True)
Gosub, DownloadUpdate

SetTimer, WindowSpy, 250
Gosub, WindowSpy

Return


#Include %A_ScriptDir%\Include\grep.ahk
#Include %A_ScriptDir%\Include\HttpQueryInfo.ahk

;
#IfWinActive, ahk_group IpTvPlayer
$RButton:: ;
Gosub, EPGHide ; EPG:
Send, {RButton}
Return
vkBFsc035:: ; Virtual Key Scan Code "/"
Gosub, EPGHide ; EPG:
PostMessage, 0x111, 4144, , , ^IP-TV Player$ ahk_class IpTvPlayerMainWndClass ; IP-TV Player: -> OSD
Return
vk50sc019:: ; Virtual Key Scan Code "P"
Program := "now" ; EPG:
Gosub, ChannelData
Return
#IfWinActive

#IfWinExist, ^IP-TV Player EPG$ ahk_class AutoHotkeyGUI
vkDBsc01A:: ; Virtual Key Scan Code "["
Program := "prev" ; EPG:
Gosub, ChannelData
Return
vkDDsc01B:: ; Virtual Key Scan Code "]"
Program := "next" ; EPG:
Gosub, ChannelData
Return
#IfWinExist

DownloadUpdate:
IfNotExist, %DownloadPath%
FileCreateDir, %DownloadPath%
FileGetTime, FileModified, %DownloadFilePath%, M
LastModified := HttpQueryInfo(DownloadLink, 11) ; HTTP_QUERY_LAST_MODIFIED
If StrToTimestamp(LastModified) > FileModified
{
UrlDownloadToFile, %DownloadLink%, %DownloadFilePath%
IfEqual, ErrorLevel, 1
MsgBox, 0, IP-TV Player EPG, :`r`n%DownloadLink%
Else
{
IfNotExist, %SevenZipExe%
{
RegRead, Path, HKEY_LOCAL_MACHINE, SOFTWARE\7-Zip, Path
IfEqual, ErrorLevel, 0
SevenZipExe := Path . "\7z.exe"
}
IfExist, %SevenZipExe%
RunWait, %SevenZipExe% e "%DownloadFilePath%" -y -o"%DownloadPath%", , Hide
Else
MsgBox, 0, IP-TV Player EPG, 7-Zip :`r`n%SevenZipExe%
}
}
Return

WindowSpy:
IfWinActive, ahk_group IpTvPlayer
{
ControlGet, SpyVLCHwnd, Hwnd, , VLC DirectX1, ^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass
SpyListBoxHwnd := GetListHwnd("obj_LISTBOX", "---", "^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass")
SendMessage, 0x188, 0, 0, , ahk_id %SpyListBoxHwnd% ; LB_GETCURSEL
SpyChannelNumber := (ErrorLevel = 4294967295) ? 0 : ErrorLevel+1
If ((SpyVLCHwnd != "" && SpyVLCHwnd != VLCHwnd) || SpyChannelNumber != ChannelNumber)
{
Program := "now"
Gosub, ChannelData
}
Else IfWinExist, ^IP-TV Player EPG$ ahk_class AutoHotkeyGUI
{
WinGetPos, SpyWinX, SpyWinY, SpyWinW, SpyWinH, ^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass
SpyWinPos = %SpyWinX% %SpyWinY% %SpyWinW% %SpyWinH%
ControlGet, SpyListBoxVis, Visible, , , ahk_id %SpyListBoxHwnd%
If (SpyWinPos != WinPos || SpyListBoxVis != ListBoxVis)
Gosub, EPGShow
WinSet, Topmost, On, ^IP-TV Player EPG$ ahk_class AutoHotkeyGUI
}
}
Else IfWinExist, ^IP-TV Player EPG$ ahk_class AutoHotkeyGUI
Gosub, EPGHide
Return

ChannelData:
ControlGet, VLCHwnd, Hwnd, , VLC DirectX1, ^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass
ListBoxHwnd := GetListHwnd("obj_LISTBOX", "---", "^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass")
SendMessage, 0x188, 0, 0, , ahk_id %ListBoxHwnd% ; LB_GETCURSEL
ChannelNumber := (ErrorLevel = 4294967295) ? 0 : ErrorLevel+1
ControlGet, ChannelsList, List, , obj_COMBOBOX1, ^IP-TV Player$ ahk_class IpTvPlayerMainWndClass
Loop, Parse, ChannelsList, `n
{
ChannelName := A_LoopField
If (ChannelNumber = A_Index-1)
Break
}
RegExMatch(CH%ChannelNumber%, "^(?P<ID>[^\|]+)(\|(?P<Delta>\x2D?\d+))?", Match)
ChannelID := RegExQuote(MatchID)
ChannelDelta := (MatchDelta = "") ? 0 : MatchDelta
If (Program = "now")
{
ProgramTitle := " "
ProgramStart := ""
ProgramStop := ""
ProgramProgress = 0
}
If (XMLFilePattern = "")
Gosub, JTVProgramData
Else
Gosub, XMLProgramData
Return

XMLProgramData:
Critical, On
xmlModified := ""
xmlFilePath := ""
Loop, %DownloadPath%\%XMLFilePattern%
{
IfGreater, A_LoopFileTimeModified, %xmlModified%
{
If (DeleteOutdated = True && xmlFilePath != "")
FileRecycle, %xmlFilePath%
xmlModified := A_LoopFileTimeModified
xmlFilePath := A_LoopFileLongPath
}
}
FileRead, xmlContents, %xmlFilePath%
If RegExMatch(xmlContents, "Si)<channel id=\x22" . ChannelID . "\x22>((\s|.)+?)</channel>", Match)
{
/*
If RegExMatch(Match1, "i)<display-name[^>]+?>\s*(?P<Name>[^<]+?)\s*</display-name>", Match)
ChannelName := XMLEntitiesDecode(MatchName)
If RegExMatch(Match1, "i)<icon src=\x22(?P<Icon>http://[^\x22]+?)\x22 />", Match)
ChannelIcon := MatchIcon
*/
Offsets := grep(xmlContents, "Si)<programme[^>]+channel=\x22" . ChannelID . "\x22((\s|.)+?)</programme>", Matches, 1, 0, "")
ProgramsCount = 0
Loop, Parse, Offsets,
ProgramsCount += 1
Loop, Parse, Matches,
{
RegExMatch(A_LoopField, "i)start=\x22(?P<Start>\d{14})", Match)
RegExMatch(A_LoopField, "i)stop=\x22(?P<Stop>\d{14})", Match)
MatchStart += %ChannelDelta%, Minutes
MatchStop += %ChannelDelta%, Minutes
Stop%A_Index% := MatchStop
If (Program = "now" && MatchStart <= A_Now && MatchStop > A_Now)
or (Program = "now" && A_Index = ProgramsCount)
or (Program = "prev" && MatchStop = PrevStop)
or (Program = "next" && MatchStart >= NextStart)
{
Index := A_Index-1
PrevStop := Stop%Index%
NextStart := MatchStop
If RegExMatch(A_LoopField, "i)<title[^>]+?>\s*(?P<Title>[^<]+?)\s*</title>", Match)
ProgramTitle := XMLEntitiesDecode(MatchTitle)
ProgramDesc := ""
If RegExMatch(A_LoopField, "i)<desc[^>]+?>\s*(?P<Desc>[^<]+?)\s*</desc>", Match)
ProgramDesc := XMLEntitiesDecode(MatchDesc)
FormatTime, ProgramStart, %MatchStart%, HH:mm
FormatTime, ProgramStop, %MatchStop%, HH:mm
ProgramLength := EnvSub(MatchStop, MatchStart, "Seconds")
ProgramElapsed := EnvSub(A_Now, MatchStart, "Seconds")
ProgramProgress := Ceil(ProgramElapsed / (ProgramLength*0.01))
ProgramProgress := (MatchStart > A_Now) ? 0 : ((MatchStop < A_Now) ? 100 : ProgramProgress)
Break
}
}
}
xmlContents =
Gosub, EPGShow
Return

JTVProgramData:
Critical, On
ndxFilePath = %DownloadPath%\%MatchID%.ndx
pdtFilePath = %DownloadPath%\%MatchID%.pdt
FileRead, ndxData, %ndxFilePath%
; FileGetSize, ndxSize, %ndxFilePath%
FileRead, pdtData, %pdtFilePath%
If GetText(pdtData) = "JTV 3.x TV Program Data"
{
ProgramsCount := GetInteger(ndxData, 0) ;
ndxOffset = 2
Loop, % ProgramsCount+1
{
IfLessOrEqual, A_Index, %ProgramsCount%
{
Timestamp%A_Index% := GetTimestamp(ndxData, ndxOffset+2) ; (Win32 FILETIME)
Timestamp%A_Index% += %ChannelDelta%, Minutes
pdtOffset := GetInteger(ndxData, ndxOffset+10) ; .pdt ( )
While, pdtOffset < pdtOffset%Index%
pdtOffset += 65536
pdtOffset%A_Index% := pdtOffset
ndxOffset += 12
}
IfEqual, A_Index, 1, Continue
Index := A_Index-1
MatchStart := Timestamp%Index%
MatchStop := (A_Index <= ProgramsCount) ? Timestamp%A_Index% : MatchStart
If (Program = "now" && MatchStart <= A_Now && MatchStop > A_Now)
or (Program = "now" && A_Index > ProgramsCount)
or (Program = "prev" && MatchStop = PrevStop)
or (Program = "next" && MatchStart = NextStart)
{
PrevStop := MatchStart
NextStart := MatchStop
TitleLength := GetInteger(pdtData, pdtOffset%Index%) ;
ProgramTitle := GetText(pdtData, pdtOffset%Index%+2, TitleLength) ; (ASCII)
ProgramDesc := ""
If RegExMatch(ProgramTitle, "^(?P<Title>[^\r\n]+)[\r\n]+(?P<Desc>.+)$", Match)
{
ProgramTitle := MatchTitle
ProgramDesc := MatchDesc
}
FormatTime, ProgramStart, %MatchStart%, HH:mm
FormatTime, ProgramStop, %MatchStop%, HH:mm
ProgramLength := EnvSub(MatchStop, MatchStart, "Seconds")
ProgramElapsed := EnvSub(A_Now, MatchStart, "Seconds")
ProgramProgress := Ceil(ProgramElapsed / (ProgramLength*0.01))
ProgramProgress := (MatchStart > A_Now) ? 0 : ((MatchStop < A_Now) ? 100 : ProgramProgress)
Break
}
}
}
While, pdtOffset%A_Index%
pdtOffset%A_Index% =
ndxData =
pdtData =
Gosub, EPGShow
Return

EPGShow:
SetTimer, EPGHide, Off
Gui, Destroy
ControlGet, StaticHwnd, Hwnd, , obj_STATIC4, ^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass
ControlGet, StaticVis, Visible, , , ahk_id %StaticHwnd%
If (StaticVis = 1)
Control, Hide, , , ahk_id %StaticHwnd%
WinGetPos, WinX, WinY, WinW, WinH, ^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass
WinPos = %WinX% %WinY% %WinW% %WinH%
ListBoxHwnd := GetListHwnd("obj_LISTBOX", "---", "^IP-TV Player$ ahk_class IpTvPlayerVideoWndClass")
ControlGet, ListBoxVis, Visible, , , ahk_id %ListBoxHwnd%
ControlGetPos, , , ListBoxW, , , ahk_id %ListBoxHwnd%
ListBoxW := (ListBoxVis = 0) ? 0 : ListBoxW
Margins := Ceil(WinW / (A_ScreenWidth/EPGMargins))
FontSize := Ceil(WinW / (A_ScreenWidth/EPGFontSize))
OutlinePos1 := (WinPos = "0 0 " . A_ScreenWidth . " " . A_ScreenHeight) ? 4 : 2
OutlinePos2 := OutlinePos1//2
OutlinePos = Section,xs+%OutlinePos2% ys,xs+%OutlinePos1% ys,xs+%OutlinePos1% ys+%OutlinePos2%,xs+%OutlinePos1% ys+%OutlinePos1%,xs+%OutlinePos2% ys+%OutlinePos1%,xs ys+%OutlinePos1%,xs ys+%OutlinePos2%,xs+%OutlinePos2% ys+%OutlinePos2%
TextW := WinW - ListBoxW - (Margins*2) - OutlinePos1
; :
Gui, Margin, %Margins%, %Margins%
Gui, Font, s%FontSize% %EPGTitleStyle%, %EPGFontName%
Gui, Add, Text, vTitle +0x80 w%TextW%, 00:00 (100`%) %ProgramTitle%
Gui, Font, norm %EPGDescStyle%
Gui, Add, Text, vDesc +0x80 w%TextW%, %ProgramDesc%
Gui, Font, norm bold
Gui, Add, Text, vPoint r1, I
; :
GuiControlGet, Title, Pos
GuiControlGet, Desc, Pos
GuiControlGet, Point, Pos
Gui, Destroy ;
TitleRows := (TitleH > (PointH*EPGTitleRows)) ? " r" . EPGTitleRows : ""
DescRows := (DescH > (PointH*EPGDescRows)) ? " r" . EPGDescRows : ""
; :
Gui, Color, %EPGColor%
Gui, +LastFound
WinSet, TransColor, %EPGTransColor%
WinSet, AlwaysOnTop, On
WinSet, Disable
Gui, +AlwaysOnTop -Caption +ToolWindow -Border
Gui, Margin, %Margins%, %Margins%
Gui, Font, s%FontSize% %EPGTitleStyle% c%EPGOutlineColor%, %EPGFontName%
ChannelText = %ChannelNumber%. %ChannelName%
Loop, Parse, OutlinePos, `,
Gui, Add, Text, % (A_Index = 9 ? "vChannelText c" . EPGFontColor . " " : "") . A_LoopField . " BackgroundTrans +0x80 w" . TextW . " r1", %ChannelText%
GuiControlGet, ChannelText, Pos
FormatTime, CurrentTime, , HH:mm
TitleText = %CurrentTime% (%ProgramProgress%`%) %ProgramTitle%
Loop, Parse, OutlinePos, `,
Gui, Add, Text, % (A_Index = 9 ? "vTitleText c" . EPGFontColor . " " : "") . A_LoopField . (A_Index = 1 ? " xs ys+" . ChannelTextH : "") . " BackgroundTrans +0x80 w" . TextW . TitleRows, %TitleText%
GuiControlGet, TitleText, Pos
DescTextH = 0
StartTextH = 0
If (ProgramStart != "" && ProgramStop != "")
{
If (ProgramDesc != "" && EPGDescRows > 0)
{
Gui, Font, norm %EPGDescStyle%
Loop, Parse, OutlinePos, `,
Gui, Add, Text, % (A_Index = 9 ? "vDescText c" . EPGFontColor . " " : "") . A_LoopField . (A_Index = 1 ? " xs ys+" . TitleTextH : "") . " BackgroundTrans +0x80 w" . TextW . DescRows, %ProgramDesc%
GuiControlGet, DescText, Pos
Gui, Font, norm %EPGTitleStyle%
Loop, Parse, OutlinePos, `,
Gui, Add, Text, % (A_Index = 9 ? "vStartText c" . EPGFontColor . " " : "") . A_LoopField . (A_Index = 1 ? " xs ys+" . DescTextH : "") . " BackgroundTrans r1", %ProgramStart%
}
Else
{
Loop, Parse, OutlinePos, `,
Gui, Add, Text, % (A_Index = 9 ? "vStartText c" . EPGFontColor . " " : "") . A_LoopField . (A_Index = 1 ? " xs ys+" . TitleTextH : "") . " BackgroundTrans r1", %ProgramStart%
}
GuiControlGet, StartText, Pos
ProgressBarW := TextW - (StartTextW*2) - (Margins*2) - (OutlinePos1*2)
ProgressBar := ""
Loop, % Floor(ProgressBarW/PointW)
ProgressBar .= "I"
ProgressW := ProgramProgress * (ProgressBarW*0.01)
Gui, Font, norm bold
Loop, Parse, OutlinePos, `,
{
Gui, Add, Text, % (A_Index = 9 ? "c" . EPGProgressBackground . " " : "") . A_LoopField . (A_Index = 1 ? " ys" : "") . " BackgroundTrans w" . ProgressBarW . " r1", %ProgressBar%
IfEqual, A_Index, 9
Gui, Add, Text, c%EPGProgressColor% %A_LoopField% BackgroundTrans w%ProgressW% r1, %ProgressBar%
}
Gui, Font, norm %EPGTitleStyle%
Loop, Parse, OutlinePos, `,
Gui, Add, Text, % (A_Index = 9 ? "vStopText c" . EPGFontColor . " " : "") . A_LoopField . (A_Index = 1 ? " ys" : "") . " BackgroundTrans r1", %ProgramStop%
}
Gui, Show
, % "x" . WinX
. " y" . (WinY + WinH - (Margins*2) - OutlinePos1 - ChannelTextH - TitleTextH - DescTextH - StartTextH)
. " NoActivate"
, IP-TV Player EPG
SetTimer, EPGHide, % EPGDelay*1000
Return

EPGHide:
SetTimer, EPGHide, Off
Gui, Destroy
Return

StrToTimestamp(Str)
{
RegExMatch(Str, "i)(\d{1,2}) ([a-z]{3}) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT", Match)
Months := "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
Loop, Parse, Months, `,
{
IfEqual, A_LoopField, %Match2%
{
Result := Match3 . ((A_Index < 10) ? "0" : "") . A_Index . Match1 . Match4 . Match5 . Match6
Break
}
}
UTCDelta -= %A_NowUTC%, Hours
Result += %UTCDelta%, Hours
Return, Result
}

RegExQuote(Str)
{
StringReplace, Str, Str, \, \\, All
StringReplace, Str, Str, ., \., All
StringReplace, Str, Str, *, \*, All
StringReplace, Str, Str, ?, \?, All
StringReplace, Str, Str, +, \+, All
StringReplace, Str, Str, [, \[, All
StringReplace, Str, Str, {, \{, All
StringReplace, Str, Str, |, \|, All
StringReplace, Str, Str, (, \(, All
StringReplace, Str, Str, ), \), All
StringReplace, Str, Str, ^, \^, All
StringReplace, Str, Str, $, \$, All
Return, Str
}

EnvSub(Var, Value, TimeUnits = "Minutes")
{
Result := Var
EnvSub, Result, %Value%, %TimeUnits%
Return, Result
}

XMLEntitiesDecode(Str)
{
Loop
{
If RegExMatch(Str, "S)&#(?P<Dec>\d+);", Match)
StringReplace, Str, Str, %Match%, % Chr(MatchDec), All
Else If RegExMatch(Str, "Si)&#x(?P<Hex>[\da-f]+);", Match)
StringReplace, Str, Str, %Match%, % Chr("0x" . MatchHex), All
Else
Break
}
StringReplace, Str, Str, &nbsp;, %A_Space%, All
StringReplace, Str, Str, &quot;, ", All
StringReplace, Str, Str, &apos;, ', All
StringReplace, Str, Str, &lt;, <, All
StringReplace, Str, Str, &gt;, >, All
StringReplace, Str, Str, &amp;, &, All
Return, Str
}

GetInteger(ByRef @Data, Offset = 0, Size = 2, Signed = False)
{
Loop, %Size%
Result += *(&@Data + Offset + A_Index-1) << 8*(A_Index-1)
If (!Signed || Size > 4 || Result < 0x80000000)
Return, Result
Return, -(0xFFFFFFFF - Result + 1)
}

GetTimestamp(ByRef @Data, Offset = 4)
{
VarSetCapacity(SystemTime, 16, 0)
DllCall("FileTimeToSystemTime", "UInt", &@Data + Offset, "UInt", &SystemTime)
Result .= NumGet(SystemTime, 0, "UShort")
Result .= StrLen(Word := NumGet(SystemTime, 2, "UShort")) == 1 ? ("0" . Word) : Word
Result .= StrLen(Word := NumGet(SystemTime, 6, "UShort")) == 1 ? ("0" . Word) : Word
Result .= StrLen(Word := NumGet(SystemTime, 8, "UShort")) == 1 ? ("0" . Word) : Word
Result .= StrLen(Word := NumGet(SystemTime, 10, "UShort")) == 1 ? ("0" . Word) : Word
Result .= StrLen(Word := NumGet(SystemTime, 12, "UShort")) == 1 ? ("0" . Word) : Word
Return, Result
}

GetText(ByRef @Data, Offset = 0, Length = 23)
{
Loop, %Length%
{
Result .= Chr( *(&@Data + Offset) )
Offset += 1
}
Return, Result
}

GetListHwnd(ControlName, Needle, WinTitle, WinText = "")
{
WinGet, UniqueID, ID, %WinTitle%, %WinText%
WinGet, Controls, ControlList, ahk_id %UniqueID%
Loop, Parse, Controls, `n
{
IfNotInString, A_LoopField, %ControlName%
Continue
ControlGet, Items, List, , %A_LoopField%, ahk_id %UniqueID%
IfInString, Items, %Needle%
{
ControlGet, Result, Hwnd, , %A_LoopField%, ahk_id %UniqueID%
Break
}
}
Return, Result
}

Copyleft 2009 Big Digger Valid XHTML 1.0 Transitional Valid CSS!