Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/MusterGit/xbmc-urlresolver
Browse files Browse the repository at this point in the history
…into MusterGit-master

Conflicts:
	plugin.video.t0mm0.test/default.py
  • Loading branch information
t0mm0 committed Nov 3, 2011
2 parents 6d72c20 + 3dd06e4 commit 981ca0e
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugin.video.t0mm0.test/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
urlresolver.display_settings()

elif mode == 'test':
addon.add_video_item({'url': 'http://flashx.tv/player/embed_player.php?vid=1503&width=600&height=370&autoplay=no'},
{'title': 'flashx url'})
addon.add_video_item({'host': 'flashx','media_id': '1503'},
{'title': 'flashx media id'})
addon.add_video_item({'url': 'http://www.2gb-hosting.com/v/94fb733db6e9f984b07da3cb238eb277/2074fe10f41c7e1.flv.html'},
{'title': '2gbhosting url'})
addon.add_video_item({'host': '2gb-hosting.com', 'media_id': 'e1593e96e19f7ecced3778668e809c77/efc5d03968fbca6.avi.html'},
Expand Down Expand Up @@ -87,6 +91,10 @@
{'title': 'seeon.tv url'})
addon.add_video_item({'host': 'seeon.tv', 'media_id': '19412'},
{'title': 'seeon.tv media id'})
addon.add_video_item({'url': 'http://www.sharefiles4u.com/pknlizmgi6mw/contagion-md-dubbed-german.avi'},
{'title': 'sharefiles url'})
addon.add_video_item({'host': 'sharefiles','media_id': 'pknlizmgi6mw'},
{'title': 'sharefiles media id'})
addon.add_video_item({'url': 'http://skyload.net/File/a25454887fd8cce41bac2e316d9d0a51.flv'},
{'title': 'skyload url'})
addon.add_video_item({'host': 'skyload', 'media_id': 'a25454887fd8cce41bac2e316d9d0a51'},
Expand Down
73 changes: 73 additions & 0 deletions script.module.urlresolver/lib/urlresolver/plugins/flashx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""
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/>.
"""

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 FlashxResolver(Plugin, UrlResolver, PluginSettings):
implements = [UrlResolver, PluginSettings]
name = "flashx"

def __init__(self):
p = self.get_setting('priority') or 100
self.priority = int(p)
self.net = Net()
#e.g. http://flashx.tv/player/embed_player.php?vid=1503&width=600&height=370&autoplay=no
self.pattern = 'http://((?:www.)?flashx.tv)/player/embed_player.php\?vid=([0-9]+)'


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, api_url))
return False

#grab stream url
sPatternHQ = "var hq_video_file\s*=\s*'([^']+)'" # .mp4
sPatternLQ = "var normal_video_file\s*=\s*'([^']+)'" # .flv
r = re.search(sPatternLQ, html)
if r:
return r.group(1)

return False

def get_url(self, host, media_id):
return 'http://www.flashx.tv/player/embed_player.php?vid=%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
119 changes: 119 additions & 0 deletions script.module.urlresolver/lib/urlresolver/plugins/sharefiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"""
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/>.
"""

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 SharefilesResolver(Plugin, UrlResolver, PluginSettings):
implements = [UrlResolver, PluginSettings]
name = "sharefiles"

def __init__(self):
p = self.get_setting('priority') or 100
self.priority = int(p)
self.net = Net()
self.pattern = 'http://((?:www.)?sharefiles4u.com)/([0-9a-zA-Z]+)'

def unpackByString(self, sJavascript):
aSplit = sJavascript.split(";',")
p = str(aSplit[0])
aSplit = aSplit[1].split(",")
a = int(aSplit[0])
c = int(aSplit[1])
k = aSplit[2].split(".")[0].replace("'", '').split('|')
e = ''
d = ''
sUnpacked = str(self.__unpack(p, a, c, k, e, d))
return sUnpacked.replace('\\', '')

def __unpack(self, p, a, c, k, e, d):
while (c > 1):
c = c -1
if (k[c]):
p = re.sub('\\b' + str(self.__itoa(c, a)) +'\\b', k[c], p)
return p

def __itoa(self, num, radix):
result = ""
while num > 0:
result = "0123456789abcdefghijklmnopqrstuvwxyz"[num % radix] + result
num /= radix
return result

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

#send all form values
sPattern = '<input.*?name="([^"]+)".*?value=([^>]+)>'
r = re.findall(sPattern, html)
data = {}
if r:
for match in r:
name = match[0]
value = match[1].replace('"','')
data[name] = value

html = self.net.http_POST(web_url, data).content
else:
common.addon.log_error(self.name + ': no fields found')
return False

# get url from packed javascript
r = re.findall("<script type='text/javascript'>eval.*?return p}" +
"\((.*?)\)\s*</script>", html, re.DOTALL + re.IGNORECASE)
if r:
sJavascript = r[1]
sUnpacked = self.unpackByString(sJavascript)
sPattern = '<param name="src"0="(.*?)"'
r = re.search(sPattern, sUnpacked)
if r:
return r.group(1)


return False


def get_url(self, host, media_id):
return 'http://www.sharefiles4u.com/%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

0 comments on commit 981ca0e

Please sign in to comment.