Skip to content

Commit

Permalink
make sharefiles plugin use jsunpack code from lib
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mm0 committed Nov 3, 2011
1 parent abaa40b commit fc2141e
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions script.module.urlresolver/lib/urlresolver/plugins/sharefiles.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 @@ -38,32 +39,6 @@ def __init__(self):
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)

Expand Down Expand Up @@ -94,7 +69,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 @@ -116,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

0 comments on commit fc2141e

Please sign in to comment.