2 Gets metas for tv episode using tvrage.
5 Copyright © 2010 the VideoLAN team
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 -- Replace non alphanumeric char by +
23 function get_query( title )
24 -- If we have a .EXT remove the extension.
25 str = string.gsub( title, "(.*)%....$", "%1" )
26 return string.gsub( str, "([^%w ])",
27 function (c) return string.format ("%%%02X", string.byte(c)) end)
31 local metas = vlc.item:metas()
33 local showName = metas["showName"]
38 local seasonNumber = metas["seasonNumber"];
39 if not seasonNumber then
43 local episodeNumber = metas["episodeNumber"];
44 if not episodeNumber then
48 local fd = vlc.stream("http://services.tvrage.com/feeds/search.php?show=" .. get_query(showName))
49 if not fd then return nil end
50 local page = fd:read( 65653 )
52 _, _, showid = string.find( page, "<showid>(.-)</showid>" )
57 fd = vlc.stream("http://services.tvrage.com/feeds/full_show_info.php?sid=" .. showid)
58 if not fd then return nil end
59 page = fd:read( 65653 )
61 _, _, season = string.find(page, "<Season no=\""..seasonNumber.."\">(.-)</Season>")
66 _, _, episode = string.find(season, "<episode>(.-<seasonnum>"..episodeNumber.."</seasonnum>.-)</episode>")
71 _, _, title, artwork = string.find(episode, "<title>(.-)</title><screencap>(.-)</screencap>")
76 vlc.item:set_meta("title", showName.. " S"..seasonNumber.."E"..episodeNumber.." - ".. title)
77 vlc.item:set_meta("artwork_url", artwork)
78 vlc.item:set_meta("episodeName", title)