forked from jmcvige/lmwt-kiss.bundle
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved Unpacker code to shared code. Cleaned up WholeCloud code for later editing
- Loading branch information
Showing
6 changed files
with
166 additions
and
155 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
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,112 @@ | ||
#!/usr/bin/env python | ||
#################################################################################################### | ||
""" | ||
urlresolver XBMC Addon | ||
Copyright (C) 2013 Bstrdsmkr | ||
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/>. | ||
Adapted for use in xbmc from: | ||
https://github.com/einars/js-beautify/blob/master/python/jsbeautifier/unpackers/packer.py | ||
Unpacker for Dean Edward's p.a.c.k.e.r | ||
""" | ||
|
||
def unpack(source): | ||
"""Unpacks P.A.C.K.E.R. packed js code.""" | ||
payload, symtab, radix, count = filterargs(source) | ||
|
||
if count != len(symtab): | ||
raise UnpackingError('Malformed p.a.c.k.e.r. symtab.') | ||
|
||
try: | ||
unbase = Unbaser(radix) | ||
except TypeError: | ||
raise UnpackingError('Unknown p.a.c.k.e.r. encoding.') | ||
|
||
def lookup(match): | ||
"""Look up symbols in the synthetic symtab.""" | ||
word = match.group(0) | ||
return symtab[unbase(word)] or word | ||
|
||
source = Regex(r'\b\w+\b').sub(lookup, payload) | ||
return replacestrings(source) | ||
|
||
def filterargs(source): | ||
"""Juice from a source file the four args needed by decoder.""" | ||
argsregex = (r"}\('(.*)', *(\d+), *(\d+), *'(.*?)'\.split\('\|'\)") | ||
args = Regex(argsregex).search(source, Regex.DOTALL).groups() | ||
|
||
try: | ||
return args[0], args[3].split('|'), int(args[1]), int(args[2]) | ||
except ValueError: | ||
raise UnpackingError('Corrupted p.a.c.k.e.r. data.') | ||
|
||
def replacestrings(source): | ||
"""Strip string lookup table (list) and replace values in source.""" | ||
match = Regex(r'var *(_\w+)\=\["(.*?)"\];').search(source, Regex.DOTALL) | ||
|
||
if match: | ||
varname, strings = match.groups() | ||
startpoint = len(match.group(0)) | ||
lookup = strings.split('","') | ||
variable = '%s[%%d]' % varname | ||
for index, value in enumerate(lookup): | ||
source = source.replace(variable % index, '"%s"' % value) | ||
return source[startpoint:] | ||
return source | ||
|
||
class Unbaser(object): | ||
"""Functor for a given base. Will efficiently convert | ||
strings to natural numbers.""" | ||
ALPHABET = { | ||
64 : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/', | ||
95 : (' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||
'[\]^_`abcdefghijklmnopqrstuvwxyz{|}~') | ||
} | ||
|
||
def __init__(self, base): | ||
self.base = base | ||
|
||
# If base can be handled by int() builtin, let it do it for us | ||
if 2 <= base <= 36: | ||
self.unbase = lambda string: int(string, base) | ||
else: | ||
# Build conversion dictionary cache | ||
try: | ||
self.dictionary = dict((cipher, index) for | ||
index, cipher in enumerate(self.ALPHABET[base])) | ||
except KeyError: | ||
try: | ||
self.dictionary = dict((cipher, index) for | ||
index, cipher in enumerate(self.ALPHABET[64][:base])) | ||
except KeyError: | ||
raise TypeError('Unsupported base encoding.') | ||
|
||
self.unbase = self.dictunbaser | ||
|
||
def __call__(self, string): | ||
return self.unbase(string) | ||
|
||
def dictunbaser(self, string): | ||
"""Decodes a value to an integer.""" | ||
ret = 0 | ||
for index, cipher in enumerate(string[::-1]): | ||
ret += (self.base ** index) * self.dictionary[cipher] | ||
return ret | ||
|
||
class UnpackingError(Exception): | ||
"""Badly packed source or general error. Argument is a | ||
meaningful description.""" | ||
pass |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,67 @@ | ||
# WholeCloud | ||
# | ||
import time | ||
#!/usr/bin/env python | ||
|
||
"""WholeCloud Service Code""" | ||
|
||
from time import sleep | ||
|
||
#################################################################################################### | ||
def NormalizeURL(url): | ||
|
||
url = url.split('?')[0] | ||
url = url.replace('movshare.net', 'wholecloud.net').replace('novamov.com', 'auroravid.to') | ||
url = url.split('?')[0] | ||
url = url.replace('movshare.net', 'wholecloud.net').replace('novamov.com', 'auroravid.to') | ||
|
||
return url | ||
return url | ||
|
||
#################################################################################################### | ||
def MetadataObjectForURL(url): | ||
|
||
html = HTML.ElementFromURL(url) | ||
html = HTML.ElementFromURL(url) | ||
|
||
title = html.xpath('//meta[@property="og:title"]/@content')[0].split('Watch ')[-1].split(' online ')[0] | ||
thumb = html.xpath('//meta[@property="og:image"]/@content')[0] | ||
title = html.xpath('//meta[@property="og:title"]/@content')[0].split('Watch ')[-1].split(' online ')[0] | ||
thumb = html.xpath('//meta[@property="og:image"]/@content')[0] | ||
|
||
return VideoClipObject( | ||
title = title, | ||
thumb = thumb | ||
) | ||
return VideoClipObject( | ||
title = title, | ||
thumb = thumb | ||
) | ||
|
||
#################################################################################################### | ||
def MediaObjectsForURL(url): | ||
|
||
return [ | ||
MediaObject( | ||
video_resolution = 'sd', | ||
audio_channels = 2, | ||
optimized_for_streaming = False, | ||
parts = [ | ||
PartObject(key=Callback(PlayVideo, url=url)) | ||
] | ||
) | ||
] | ||
return [ | ||
MediaObject( | ||
video_resolution = 'sd', | ||
audio_channels = 2, | ||
optimized_for_streaming = False, | ||
parts = [ | ||
PartObject(key=Callback(PlayVideo, url=url)) | ||
] | ||
) | ||
] | ||
|
||
#################################################################################################### | ||
@indirect | ||
def PlayVideo(url): | ||
|
||
html = HTML.ElementFromURL(url) | ||
post_values = {} | ||
html = HTML.ElementFromURL(url) | ||
post_values = {} | ||
|
||
for item in html.xpath('//form[@method="post"]/input'): | ||
for item in html.xpath('//form[@method="post"]/input'): | ||
|
||
name = item.get('name') | ||
value = item.get('value') | ||
post_values[name] = value | ||
name = item.get('name') | ||
value = item.get('value') | ||
post_values[name] = value | ||
|
||
time.sleep(1) | ||
sleep(1) | ||
|
||
page = HTTP.Request(url, values=post_values, method='POST').content | ||
page = HTTP.Request(url, values=post_values, method='POST').content | ||
|
||
host = url.split('/')[2] | ||
filekey = Regex('flashvars\.filekey="([^"]+)";').search(page).group(1) | ||
file = Regex('flashvars\.file="([^"]+)";').search(page).group(1) | ||
host = url.split('/')[2] | ||
filekey = Regex('flashvars\.filekey="([^"]+)";').search(page).group(1).replace('.', '%2E') | ||
file = Regex('flashvars\.file="([^"]+)";').search(page).group(1) | ||
|
||
data = HTTP.Request('http://%s/api/player.api.php?key=%s&file=%s' % (host, filekey, file)).content | ||
video_url = data.split('url=')[1].split('&')[0] | ||
data = HTTP.Request('http://%s/api/player.api.php?key=%s&file=%s' % (host, filekey, file)).content | ||
video_url = data.split('url=')[1].split('&')[0] | ||
Log.Debug('* PlayVideo URL = %s' %video_url) | ||
|
||
return IndirectResponse(VideoClipObject, key=video_url) | ||
return IndirectResponse(VideoClipObject, key=video_url) |