2 Gets metas for tv episode using tvrage.
5 Copyright © 2007 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(vlc.item)
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 local page = fd:read( 65653 )
51 _, _, showid = string.find( page, "<showid>(.-)</showid>" )
56 fd = vlc.stream("http://services.tvrage.com/feeds/full_show_info.php?sid=" .. showid)
57 page = fd:read( 65653 )
59 _, _, season = string.find(page, "<Season no=\""..seasonNumber.."\">(.-)</Season>")
64 _, _, episode = string.find(season, "<episode>(.-<seasonnum>"..episodeNumber.."</seasonnum>.-)</episode>")
69 _, _, title, artwork = string.find(episode, "<title>(.-)</title><screencap>(.-)</screencap>")
74 vlc.item.set_meta(vlc.item, "title", showName.. " S"..seasonNumber.."E"..episodeNumber.." - ".. title)
75 vlc.item.set_meta(vlc.item, "artwork_url", artwork)
76 vlc.item.set_meta(vlc.item, "episodeName", title)