diff --git a/plugin.video.t0mm0.test/default.py b/plugin.video.t0mm0.test/default.py index 14422a1..2ef568e 100644 --- a/plugin.video.t0mm0.test/default.py +++ b/plugin.video.t0mm0.test/default.py @@ -46,6 +46,10 @@ urlresolver.display_settings() elif mode == 'test': + addon.add_video_item({'url': 'http://rapidvideo.com/view/hwksai28'}, + {'title': 'rapidvideo url'}) + addon.add_video_item({'host': 'rapidvideo', 'media_id': 'hwksai28'}, + {'title': 'rapidvideo media id'}) addon.add_video_item({'url': 'http://vidstream.us/video/7XK5WMYBAM5R/RAONE'}, {'title': 'vidstream url'}) addon.add_video_item({'host': 'vidstream', 'media_id': '7XK5WMYBAM5R/RAONE'}, diff --git a/script.module.urlresolver/lib/urlresolver/plugins/rapidvideo.py b/script.module.urlresolver/lib/urlresolver/plugins/rapidvideo.py new file mode 100644 index 0000000..8ed0a1e --- /dev/null +++ b/script.module.urlresolver/lib/urlresolver/plugins/rapidvideo.py @@ -0,0 +1,72 @@ +""" + urlresolver XBMC Addon + Copyright (C) 2011 t0mm0 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + +from t0mm0.common.net import Net +from urlresolver.plugnplay.interfaces import UrlResolver +from urlresolver.plugnplay.interfaces import PluginSettings +from urlresolver.plugnplay import Plugin +import urllib2 +from urlresolver import common + +# Custom imports +import re + + +class RapidvideoResolver(Plugin, UrlResolver, PluginSettings): + implements = [UrlResolver, PluginSettings] + name = "rapidvideo" + + def __init__(self): + p = self.get_setting('priority') or 100 + self.priority = int(p) + self.net = Net() + #e.g. http://rapidvideo.com/view/hwksai28 + self.pattern = 'http://((?:www.)?rapidvideo.com)/view/([0-9a-zA-Z]+)' + + + def get_media_url(self, host, media_id): + web_url = self.get_url(host, media_id) + + try: + html = self.net.http_GET(web_url).content + except urllib2.URLError, e: + common.addon.log_error(self.name + ': got http error %d fetching %s' % + (e.code, web_url)) + return False + + # get stream url + sPattern = "so.addVariable\(\s*'file'\s*,\s*'([^']+)'\s*\)" + r = re.search(sPattern, html) + if r: + return r.group(1) + + return False + + def get_url(self, host, media_id): + return 'http://rapidvideo.com/view/%s' % (media_id) + + def get_host_and_id(self, url): + r = re.search(self.pattern, url) + if r: + return r.groups() + else: + return False + + + def valid_url(self, url, host): + return re.match(self.pattern, url) or self.name in host \ No newline at end of file