Skip to content

Commit

Permalink
split out jsunpack stuff and some small tidying of new plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mm0 committed Oct 31, 2011
1 parent ab16933 commit 7ac2892
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 68 deletions.
13 changes: 13 additions & 0 deletions plugin.video.t0mm0.test/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
{'title': 'tubeplus url'})
addon.add_video_item({'host': 'tubeplus.me', 'media_id': '1962655'},
{'title': 'tubeplus media id'})
addon.add_video_item({'url': 'http://www.uploadc.com/wheon4xa0sh6'},
{'title': 'uploadc url'})
addon.add_video_item({'host': 'uploadc.com', 'media_id': 'wheon4xa0sh6'},
{'title': 'uploadc media id'})
addon.add_video_item({'url': 'http://videobb.com/video/8FvAG6AQpHi8'},
{'title': 'videobb url'})
addon.add_video_item({'host': 'videobb.com', 'media_id': '8FvAG6AQpHi8'},
Expand All @@ -107,6 +111,10 @@
{'title': 'videoweed url'})
addon.add_video_item({'host': 'videoweed.com', 'media_id': 'crirmdz3tj116'},
{'title': 'videoweed media id'})
addon.add_video_item({'url': 'http://www.videozer.com/video/3LsT'},
{'title': 'videozer url'})
addon.add_video_item({'host': 'videozer', 'media_id': '3LsT'},
{'title': 'videozer media id'})
addon.add_video_item({'url': 'http://www.vidxden.com/rn3h4gbh5se7/kdshn-4x4_watchseries-online.dot.com.avi.html'},
{'title': 'vidxden url'})
addon.add_video_item({'host': 'vidxden.com', 'media_id': 'rn3h4gbh5se7'},
Expand All @@ -115,10 +123,15 @@
{'title': 'vimeo url'})
addon.add_video_item({'host': 'vimeo.com', 'media_id': '30081785'},
{'title': 'vimeo media id'})
addon.add_video_item({'url': 'http://xvidstage.com/v9t09l63m9vn'},
{'title': 'xvidstage url'})
addon.add_video_item({'host': 'xvidstage', 'media_id': 'v9t09l63m9vn'},
{'title': 'xvidstage media id'})
addon.add_video_item({'url': 'http://www.youtube.com/watch?v=Q3VJOl_XeGs'},
{'title': 'youtube url'})
addon.add_video_item({'host': 'youtube.com', 'media_id': 'Q3VJOl_XeGs'},
{'title': 'youtube media id'})

elif mode == 'tv':
browse = addon.queries.get('browse', False)
if browse == 'alpha':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_media_url(self, host, media_id):
html = self.net.http_GET(sNextUrl).content
except urllib2.URLError, e:
common.addon.log_error(self.name + ': got http error %d fetching %s' %
(e.code, web_url))
(e.code, sNextUrl))
return False

sPattern = '<param name="flashvars" value="file=(.*?)&'
Expand All @@ -91,4 +91,4 @@ def get_host_and_id(self, url):


def valid_url(self, url, host):
return re.match(self.pattern, url) or self.name in host
return re.match(self.pattern, url) or self.name in host
45 changes: 45 additions & 0 deletions script.module.urlresolver/lib/urlresolver/plugins/lib/jsunpack.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_media_url(self, host, media_id):
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))
(e.code, web_url))
sPattern = "<file>(.*?)</file>"

# get stream url
Expand Down
33 changes: 3 additions & 30 deletions script.module.urlresolver/lib/urlresolver/plugins/uploadc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from urlresolver.plugnplay import Plugin
import urllib2
from urlresolver import common
from lib import jsunpack

# Custom imports
import re
Expand All @@ -37,34 +38,6 @@ def __init__(self):
self.net = Net()
self.pattern = 'http://((?:www.)?uploadc.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)

Expand Down Expand Up @@ -95,7 +68,7 @@ def get_media_url(self, host, media_id):
"\((.*?)\)\s*</script>", html, re.DOTALL + re.IGNORECASE)
if r:
sJavascript = r[1]
sUnpacked = self.unpackByString(sJavascript)
sUnpacked = jsunpack.unpack(sJavascript)
sPattern = '<param name="src"0="(.*?)"'
r = re.search(sPattern, sUnpacked)
if r:
Expand All @@ -115,4 +88,4 @@ def get_host_and_id(self, url):


def valid_url(self, url, host):
return re.match(self.pattern, url) or self.name in host
return re.match(self.pattern, url) or self.name in host
8 changes: 4 additions & 4 deletions script.module.urlresolver/lib/urlresolver/plugins/videozer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def __init__(self):
def get_media_url(self, host, media_id):

#grab url for this video
SETTINGS_URL = "http://www.videozer.com/" + \
settings_url = "http://www.videozer.com/" + \
"player_control/settings.php?v=%s" % media_id

try:
html = self.net.http_GET(SETTINGS_URL).content
html = self.net.http_GET(settings_url).content
except urllib2.URLError, e:
common.addon.log_error(self.name + ': got http error %d fetching %s' %
(e.code, api_url))
(e.code, settings_url))
return False

# Try to load the datas from html. This data should be json styled.
Expand All @@ -77,4 +77,4 @@ def get_host_and_id(self, url):


def valid_url(self, url, host):
return re.match(self.pattern, url) or self.name in host
return re.match(self.pattern, url) or self.name in host
32 changes: 3 additions & 29 deletions script.module.urlresolver/lib/urlresolver/plugins/xvidstage.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import re
import urllib2
from urlresolver import common
from lib import jsunpack

class XvidstageResolver(Plugin, UrlResolver, PluginSettings):
implements = [UrlResolver, PluginSettings]
Expand All @@ -34,48 +35,21 @@ def __init__(self):
self.net = Net()
self.pattern ='http://((?:www.)?xvidstage.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, api_url))
(e.code, web_url))
sPattern = "<div id=\"player_code\"><script type='text/javascript'>eval.*?return p}\((.*?)</script>"

# get url from packed javascript
r = re.search(sPattern, html, re.DOTALL + re.IGNORECASE)
if r:
sJavascript = r.group(1)
sUnpacked = self.unpackByString(sJavascript)
sUnpacked = jsunpack.unpack(sJavascript)
sPattern = '<param name="src"0="(.*?)"'
r = re.search(sPattern, sUnpacked)
if r:
Expand Down
6 changes: 4 additions & 2 deletions script.module.urlresolver/lib/urlresolver/plugins/zshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ def get_media_url(self, host, media_id):
stream_url = ''
sPattern = 'file: "([^"]+)"'
r = re.search(sPattern, html, re.DOTALL + re.IGNORECASE)
print r
if r:
stream_url = r.group(1) + "?start=0" + '|user-agent=Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.109 Safari/535.1'
print stream_url


''' download url not working for now....
# get download url
download_url = ''
# emulate download button click
Expand All @@ -89,7 +91,7 @@ def get_media_url(self, host, media_id):
r = re.search(sPattern, html, re.DOTALL + re.IGNORECASE)
if r:
download_url = r.group(1).replace("'","").replace(",","")

'''

return stream_url

Expand Down

0 comments on commit 7ac2892

Please sign in to comment.