2 Translate www.katsomo.fi video webpages URLs to the corresponding
6 Copyright © 2009 the VideoLAN team
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 return vlc
.access
== "http"
26 and string.match( vlc
.path
, "^www%.katsomo%.fi/" )
27 and ( string.match( vlc
.path
, "treeId" ) or string.match( vlc
.path
, "progId" ) )
30 function find( haystack
, needle
)
31 local _
,_
,r
= string.find( haystack
, needle
)
38 if string.match( vlc
.path
, "progId" )
40 programid
= string.match( vlc
.path
, "progId=(%d+)")
41 path
= "http://www.katsomo.fi/metafile.asx?p="..programid
.."&bw=800"
42 table.insert(p
, { path
= path
; } )
46 arturl
="http://www.katsomo.fi/multimedia/template/logos/katsomo_logo_2.gif"
50 if not line
then break end
51 if string.match( line
, "<title>" )
53 title
= vlc
.strings
.decode_uri( find( line
, "<title>(.-)<" ) )
54 title
= vlc
.strings
.from_charset( "ISO_8859-1", title
)
56 if( find( line
, "img class=\"pngImg\" src=\"/multimedia/template/logos" ) )
58 arturl
= "http://www.katsomo.fi"..find( line
, " src=\"(.-)\" alt=" )
60 for treeid
,name
in string.gmatch( line
, '/%?treeId=(%d+)">([^<]+)</a') do
61 name
= vlc
.strings
.resolve_xml_special_chars( name
)
62 name
= vlc
.strings
.from_charset( "ISO_8859-1", name
)
63 path
= "http://www.katsomo.fi/?treeId="..treeid
64 table.insert( p
, { path
= path
; name
= name
; arturl
=arturl
; } )
66 for programid
in string.gmatch( line
, "<li class=\"program.*\" id=\"program(%d+)\" title=\".+\"" ) do
67 description
= vlc
.strings
.resolve_xml_special_chars( find( line
, "title=\"(.+)\"" ) )
68 description
= vlc
.strings
.from_charset( "ISO_8859-1", description
)
69 path
= "http://www.katsomo.fi/metafile.asx?p="..programid
.."&bw=800"
70 table.insert( p
, { path
= path
; name
= description
; arturl
=arturl
; } )