forked from t0mm0/xbmc-urlresolver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'videoid' of https://github.com/adq/xbmc-urlresolver int…
…o adq-videoid
- Loading branch information
Showing
2 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
script.module.urlresolver/lib/urlresolver/plugins/tedtalks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
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 <http://www.gnu.org/licenses/>. | ||
""" | ||
|
||
import re | ||
from t0mm0.common.net import Net | ||
import urllib | ||
import urllib2 | ||
from urlresolver import common | ||
from urlresolver.plugnplay.interfaces import UrlResolver | ||
from urlresolver.plugnplay.interfaces import PluginSettings | ||
from urlresolver.plugnplay import Plugin | ||
|
||
class TedTalksResolver(Plugin, UrlResolver, PluginSettings): | ||
implements = [UrlResolver, PluginSettings] | ||
name = "tedtalks" | ||
|
||
def __init__(self): | ||
p = self.get_setting('priority') or 100 | ||
self.priority = int(p) | ||
|
||
def get_media_url(self, host, media_id): | ||
plugin = 'plugin://plugin.video.ted.talks/?mode=playVideo&name=ted&icon=ted&url=' +\ | ||
urllib.quote_plus(media_id) | ||
return plugin | ||
|
||
|
||
def get_url(self, host, media_id): | ||
return media_id | ||
|
||
|
||
def get_host_and_id(self, url): | ||
return ('ted.com', url) | ||
|
||
|
||
def valid_url(self, url, host): | ||
return re.match('http://(www.)?ted.com/.+', url) | ||
|
||
def get_settings_xml(self): | ||
xml = PluginSettings.get_settings_xml(self) | ||
xml += '<setting label="This plugin calls the tedtalks addon - ' | ||
xml += 'change settings there." type="lsep" />\n' | ||
return xml |
65 changes: 65 additions & 0 deletions
65
script.module.urlresolver/lib/urlresolver/plugins/vimeo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
""" | ||
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 <http://www.gnu.org/licenses/>. | ||
""" | ||
|
||
import re | ||
from t0mm0.common.net import Net | ||
import urllib2 | ||
from urlresolver import common | ||
from urlresolver.plugnplay.interfaces import UrlResolver | ||
from urlresolver.plugnplay.interfaces import PluginSettings | ||
from urlresolver.plugnplay import Plugin | ||
|
||
class VimeoResolver(Plugin, UrlResolver, PluginSettings): | ||
implements = [UrlResolver, PluginSettings] | ||
name = "vimeo" | ||
|
||
def __init__(self): | ||
p = self.get_setting('priority') or 100 | ||
self.priority = int(p) | ||
|
||
def get_media_url(self, host, media_id): | ||
#just call vimeo addon | ||
plugin = 'plugin://plugin.video.vimeo/?action=play_video&videoid=' +\ | ||
media_id | ||
return plugin | ||
|
||
|
||
def get_url(self, host, media_id): | ||
return 'http://vimeo.com/%s' % media_id | ||
|
||
|
||
def get_host_and_id(self, url): | ||
r = re.findall('/([0-9]+)', url) | ||
if r: | ||
video_id = r[-1] | ||
if video_id: | ||
return ('vimeo.com', video_id) | ||
else: | ||
common.addon.log_error('vimeo: video id not found') | ||
return False | ||
|
||
|
||
def valid_url(self, url, host): | ||
return re.match('http://(www.)?vimeo.com/[0-9]+', | ||
url) | ||
|
||
def get_settings_xml(self): | ||
xml = PluginSettings.get_settings_xml(self) | ||
xml += '<setting label="This plugin calls the vimeo addon - ' | ||
xml += 'change settings there." type="lsep" />\n' | ||
return xml |