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
| ' ============================================================================
' DutchTV.vbs v1.5 Original by -NeM
' ============================================================================
' Retrieves TV listings from http://www.tvgids.nl/nustraks.php (Dutch TV
' listings)
' Made by request from the Samurize forums:
' http://www.samurize.com/forum/viewtopic.php?id=1426
' Edited bij Sassie @ GoT, updated to new tv-gids.nl layout (dd 14th Oct 2008)
' Caveat: this is just a workaround, so use at your own risk!
' ======
' USAGE:
' ======
' 1) Copy DutchTV.vbs to your Samurize/scripts folder
' 2) Add an ActiveScript meter to your Samurize config with this script
' selected and 'generateListing' selected as the Function.
' 3) Use TextFile meters to view the TV Listings. Each TV channel has 3
' lines of information and is listed in the following order:
' Nederland 1 (lines 1-3)
' Nederland 2 (lines 4-6)
' Nederland 3 (lines 7-9)
' RTL 4 (lines 10-12)
' RTL 5 (lines 13-15)
' SBS 6 (lines 16-18)
' Net 5 (lines 19-21)
' Veronica (lines 22-24)
' Yorin (lines 25-27)
' V8 (lines 28-30)
' VRT TV1 (lines 31-33)
' KETNET/Canvas (lines 34-36)
' VTM (lines 37-39)
' Kanaal 2 (lines 40-42)
' VT4 (lines 43-45)
' So, for example, to see the listings for V8, Add a TextFile meter, point
' it to the DutchTV.txt file, set the Read Line field to 43 and the Number
' of Lines field to 3.
' =============
' V1.5 CHANGES:
' =============
' - First version for new TVGids.nl layout
' =============
' V1.31 CHANGES:
' =============
' - fix for empty/weird strings
' - hyperlinks the tv program to the corresponding detail page at tvgids.nl
' =============
' V1.2 CHANGES:
' =============
' - fixed night listings bug
' - fixed bug with shows that had a range (xx:xx-yy:yy) for their listing time
' - support for more channels
' =============
' V1.1 CHANGES:
' =============
' - fixed bug where no listing is given for a particular channel
' ============================================================================
' USER SETTINGS
' ============================================================================
SHOW_STARTTIMES = True ' set to False if you don't want the start
' times displayed
' ============================================================================
FILE_NAME = "C:\Program Files\Samurize\DutchTV.txt"
NUM_CHANNELS = 83
Function generateListing()
Dim fs,f,htmlResult,textToWrite
htmlResult = ReturnHTML("http://www.tvgids.nl/nustraks/allezenders/")
If InStr(htmlResult, "<title>TVGids.nl - Nu & Straks</title>") = 0 Then
textToWrite = "Site format has changed." & vbCrlf & "Script has failed." & htmlResult
Else
For i=1 To NUM_CHANNELS
textToWrite = textToWrite & getListing(i, htmlResult) & vbCrlf
Next
End If
set fs=CreateObject("Scripting.FileSystemObject")
set f=fs.CreateTextFile(FILE_NAME,true)
f.write(textToWrite)
f.close
set f=nothing
set fs=nothing
End Function
Private Function getListing(Channel,htmlResult)
' first cut everything before <table width="100%">
strAllInfo = Mid(htmlResult, InStr(htmlResult, "<table class=""tableListing"" id=""nustraksListing"" border=""0"" cellspacing=""6"" cellpadding=""0"">"))
For i=1 to Channel
' skip to correct channel
strAllInfo = Mid(strAllInfo, InStr(strAllInfo, "</tr>")+5, Len(strAllInfo))
Next
' cut everything after the end of the listings for this channel
endChannelPos = InStr(strAllInfo, "</tr>")
strAllInfo = Mid(strAllInfo, 1, endChannelPos)
' getListing = "-->" & strAllInfo & VbCrLf & VbCrLf & VbCrLf
' get the channel name
startPos = InStr(strAllInfo, "<td class=""channel"">") + 20
endPos = InStr(strAllInfo, "</td>")
channelName = Mid(strAllInfo, startPos, (endPos-startPos))
channelName = ReplaceHTML(channelName)
'getListing = channel & " " & startPos & "-" & endPos & channelName
strAllInfo = Mid(strAllInfo, endPos+7)
' get start time of what's on now
startPos = InStr(strAllInfo, "<td class=""time"">") + 17
endPos = InStr(strAllInfo, "</td>")
startTime = Mid(strAllInfo, startPos, (endPos-startPos))
if Len(startTime) <=1 Then
' no listing
' strAllInfo = Mid(strAllInfo, InStr(strAllInfo, "32%"))
' startPos = InStr(strAllInfo, ">") + 5
' endPos = InStr(startPos, strAllInfo, "</td>") - 3
else
' listing
strAllInfo = Mid(strAllInfo, endPos+5)
' ' get what's on now
startPos = InStr(strAllInfo, "<td class=""title"">") + 18
endPos = InStr(startPos, strAllInfo, "</td>")
end if
If SHOW_STARTTIMES = True Then
if InStr(startTime, ":")<1 Then
nowShowing = ""
Else
nowShowing = TrimHTML(startTime) & " "
End if
End If
' next line added to support hyperlinks
strLinkprogramma = Mid(strAllInfo, InStr(strAllInfo, "?ID=")+4, 7)
' clean up the string
temp = Mid(strAllInfo, startPos, (endPos-startPos))
' next If-statement added to support hyperlinks
' If IsNumeric(strLinkprogramma) Then
' temp = temp & "%lhttp://www.tvgids.nl/programmadetail/?ID=" & strLinkprogramma
' End If
temp = replace(temp, vbCr, "")
temp = replace(temp, vbTab, "")
temp = replace(temp, vbLf, "")
temp = replace(temp, vbCrLf, "")
temp = Trim(TrimHTML(temp))
temp = ReplaceHTML(temp)
nowShowing = nowShowing & temp
strAllInfo = Mid(strAllInfo, endPos+5)
' get start time of what's on next
startPos = InStr(strAllInfo, "<td class=""time"">") + 17
endPos = InStr(strAllInfo, "</td>")
startTime = Mid(strAllInfo, startPos, 5)
'(endPos-startPos)
strAllInfo = Mid(strAllInfo, endPos+5)
' get what's on next
startPos = InStr(strAllInfo, "<td class=""title"">") + 18
endPos = InStr(startPos, strAllInfo, "</td>")
If SHOW_STARTTIMES = True Then
if InStr(startTime, ":")<1 Then
nextShowing = ""
Else
nextShowing = TrimHTML(startTime) & " "
End If
End If
' next line added to support hyperlinks
strLinkprogramma = Mid(strAllInfo, InStr(strAllInfo, "?ID=")+4, 7)
If startPos > 0 and endPos > 0 Then
' clean up the string
temp = Mid(strAllInfo, startPos, (endPos-startPos))
else
temp = ""
end if
' next If-statement added to support hyperlinks
' If IsNumeric(strLinkprogramma) Then
' temp = temp & "%lhttp://www.tvgids.nl/programmadetail/?ID=" & strLinkprogramma
' End If
temp = replace(temp, vbCr, "")
temp = replace(temp, vbTab, "")
temp = replace(temp, vbLf, "")
temp = replace(temp, vbCrLf, "")
temp = Trim(TrimHTML(temp))
temp = ReplaceHTML(temp)
nextShowing = nextShowing & temp
' return listing
getListing = channelName & vbCrlf & nowShowing & vbCrlf & nextShowing
End Function
Private Function ReturnHTML(sURL)
Dim objXMLHTTP,HTML
Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")
Randomize
sURL = sURL & "&" & Rnd
objXMLHTTP.Open "GET", sURL, False
objXMLHTTP.Send
HTML = objXMLHTTP.responseBody
Set objRS = CreateObject("ADODB.Recordset")
objRS.Fields.Append "txt", 200, 45000, &H00000080
objRS.Open
objRS.AddNew
objRS.Fields("txt").AppendChunk HTML
ReturnHTML = objRS("txt").Value
objRS.Close
Set objRS = Nothing
Set objXMLHTTP = Nothing
End Function
'very simple function that will remove all html tags
Private Function TrimHTML(str)
pos_deb = InStr(1, str, "<")
Do Until pos_deb = 0
pos_fin = InStr(pos_deb, str, ">")
part_d = Mid(str, 1, pos_deb - 1)
part_f = Mid(str, pos_fin + 1, Len(str) - pos_fin)
str = part_d & part_f
pos_deb = InStr(1, str, "<")
Loop
TrimHTML = Trim(str)
End Function
'ReplaceHTML (posted by Goodspeed)
'---------------------------------
Private Function ReplaceHTML(str)
str = replace(str, "ä", "ä")
str = replace(str, "ü", "ü")
str = replace(str, "ö", "ö")
str = replace(str, "Ä", "Ä")
str = replace(str, "Ü", "Ü")
str = replace(str, "Ö", "Ö")
str = replace(str, "ß", "ß")
str = replace(str, """, """")
str = replace(str, "€", "€")
str = replace(str, "£", "£")
str = replace(str, "¥", "¥")
str = replace(str, "&", "&")
str = replace(str, "<", "<")
str = replace(str, ">", ">")
str = replace(str, "¡", "¡")
str = replace(str, "¢", "¢")
str = replace(str, "¤", "¤")
str = replace(str, "¦", "¦")
str = replace(str, "§", "§")
str = replace(str, "¨", "¨")
str = replace(str, "©", "©")
str = replace(str, "ª", "ª")
str = replace(str, "«", "«")
str = replace(str, "¬", "¬")
str = replace(str, "­", "")
str = replace(str, "®", "®")
str = replace(str, "¯", "¯")
str = replace(str, "°", "°")
str = replace(str, "±", "±")
str = replace(str, "²", "²")
str = replace(str, "³", "³")
str = replace(str, "´", "´")
str = replace(str, "µ", "µ")
str = replace(str, "¶", "¶")
str = replace(str, "·", "·")
str = replace(str, "¸", "¸")
str = replace(str, "¹", "¹")
str = replace(str, "º", "º")
str = replace(str, "»", "»")
str = replace(str, "¼", "¼")
str = replace(str, "½", "½")
str = replace(str, "¾", "¾")
str = replace(str, "¿", "¿")
str = replace(str, "À", "À")
str = replace(str, "Á", "Á")
str = replace(str, "Â", "Â")
str = replace(str, "Ã", "Ã")
str = replace(str, "Å", "Å")
str = replace(str, "Æ", "Æ")
str = replace(str, "Ç", "Ç")
str = replace(str, "È", "È")
str = replace(str, "É", "É")
str = replace(str, "Ê", "Ê")
str = replace(str, "Ë", "Ë")
str = replace(str, "Ì", "Ì")
str = replace(str, "Í", "Í")
str = replace(str, "Î", "Î")
str = replace(str, "Ï", "Ï")
str = replace(str, "Ð", "Ð")
str = replace(str, "Ñ", "Ñ")
str = replace(str, "Ò", "Ò")
str = replace(str, "Ó", "Ó")
str = replace(str, "Ô", "Ô")
str = replace(str, "Õ", "Õ")
str = replace(str, "×", "×")
str = replace(str, "Ø", "Ø")
str = replace(str, "Ù", "Ù")
str = replace(str, "Ú", "Ú")
str = replace(str, "Û", "Û")
str = replace(str, "Ý", "Ý")
str = replace(str, "Þ", "Þ")
str = replace(str, "à", "à")
str = replace(str, "á", "á")
str = replace(str, "â", "â")
str = replace(str, "ã", "ã")
str = replace(str, "å", "å")
str = replace(str, "æ", "æ")
str = replace(str, "ç", "ç")
str = replace(str, "è", "è")
str = replace(str, "é", "é")
str = replace(str, "ê", "ê")
str = replace(str, "ë", "ë")
str = replace(str, "ì", "ì")
str = replace(str, "í", "í")
str = replace(str, "î", "î")
str = replace(str, "ï", "ï")
str = replace(str, "ð", "ð")
str = replace(str, "ñ", "ñ")
str = replace(str, "ò", "ò")
str = replace(str, "ó", "ó")
str = replace(str, "ô", "ô")
str = replace(str, "÷", "÷")
str = replace(str, "ø", "ø")
str = replace(str, "ù", "ù")
str = replace(str, "ú", "ú")
str = replace(str, "û", "û")
str = replace(str, "ý", "ý")
str = replace(str, "þ", "þ")
str = replace(str, "ÿ", "ÿ")
str = replace(str, " ", "")
ReplaceHTML = str
End Function |