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 'master' of https://github.com/t0mm0/xbmc-urlresolver
Added plugins: FlashX, uFliq, Sharefiles, zShare
- Loading branch information
Showing
10 changed files
with
194 additions
and
124 deletions.
There are no files selected for viewing
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
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
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
45 changes: 45 additions & 0 deletions
45
script.module.urlresolver/lib/urlresolver/plugins/lib/jsunpack.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,45 @@ | ||
""" | ||
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 | ||
|
||
def unpack(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(__unpack(p, a, c, k, e, d)) | ||
return sUnpacked.replace('\\', '') | ||
|
||
def __unpack(p, a, c, k, e, d): | ||
while (c > 1): | ||
c = c -1 | ||
if (k[c]): | ||
p = re.sub('\\b' + str(__itoa(c, a)) +'\\b', k[c], p) | ||
return p | ||
|
||
def __itoa(num, radix): | ||
result = "" | ||
while num > 0: | ||
result = "0123456789abcdefghijklmnopqrstuvwxyz"[num % radix] + result | ||
num /= radix | ||
return result |
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
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
79 changes: 79 additions & 0 deletions
79
script.module.urlresolver/lib/urlresolver/plugins/ufliq.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,79 @@ | ||
""" | ||
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 | ||
from lib import jsunpack | ||
|
||
# Custom imports | ||
import re | ||
|
||
|
||
class UfliqResolver(Plugin, UrlResolver, PluginSettings): | ||
implements = [UrlResolver, PluginSettings] | ||
name = "ufliq" | ||
|
||
def __init__(self): | ||
p = self.get_setting('priority') or 100 | ||
self.priority = int(p) | ||
self.net = Net() | ||
#e.g. http://www.ufliq.com/embed-rw52re7f5aul.html | ||
self.pattern = 'http://((?:www.)?ufliq.com)/embed-([0-9a-zA-Z]+).html' | ||
|
||
|
||
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 | ||
|
||
# get url from packed javascript | ||
sPattern = "<script type='text/javascript'>eval.*?return p}\((.*?)\)\s*</script>" | ||
r = re.search(sPattern, html, re.DOTALL + re.IGNORECASE) | ||
if r: | ||
sJavascript = r.group(1) | ||
sUnpacked = jsunpack.unpack(sJavascript) | ||
print(sUnpacked) | ||
sPattern = ".addVariable\(\s*'file'\s*,\s*'([^']+)'\s*\)" | ||
r = re.search(sPattern, sUnpacked) | ||
if r: | ||
return r.group(1) | ||
|
||
return False | ||
|
||
def get_url(self, host, media_id): | ||
return 'http://www.ufliq.com/embed-%s.html' % (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 |
Oops, something went wrong.