Skip to content

Commit

Permalink
Corrected Bookmark Class Error
Browse files Browse the repository at this point in the history
Moved Unpacker code to shared code. Cleaned up WholeCloud code for later editing
  • Loading branch information
Twoure committed Apr 8, 2016
1 parent 305d45e commit eae7bb3
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 155 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ChangeLog

##### 1.0.9
- _04/08/16_
- Fixed Bookmark class error
- Moved Unpacker code to shared code, can now be used with future service codes

##### 1.0.8
- _04/05/16_
- Fixed Bookmark caching error
Expand Down
2 changes: 1 addition & 1 deletion Contents/Code/bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Bookmark(object):

def __init__(self, title, prefix, bm_add_icon=None, bm_rm_icon=None):
def __init__(self, prefix, title, bm_add_icon=None, bm_rm_icon=None):
self.title = title
self.prefix = prefix
self.bm_add_icon = bm_add_icon
Expand Down
2 changes: 1 addition & 1 deletion Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleIdentifier</key>
<string>com.plexapp.plugins.lmwt.kiss</string>
<key>CFBundleVersion</key>
<string>1.0.8</string>
<string>1.0.9</string>
<key>PlexPluginVersionUrl</key>
<string>https://api.github.com/repos/Twoure/lmwt-kiss.bundle/releases/latest</string>
<key>PlexClientPlatforms</key>
Expand Down
112 changes: 112 additions & 0 deletions Contents/Services/Shared Code/unpacker.pys
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
122 changes: 6 additions & 116 deletions Contents/Services/URL/Vidzi/ServiceCode.pys
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env python

"""Vidzi.tv Service Code"""

from unpacker import unpack as Unpack

####################################################################################################
def NormalizeURL(url):

Expand Down Expand Up @@ -67,7 +72,7 @@ def PlayVideo(url, mp4, **kwargs):

if data:

data = unpack(data.group(1))
data = Unpack(data.group(1))
if mp4:
file = Regex('file:"([^"]+\.mp4)"').search(data)
if file:
Expand All @@ -83,118 +88,3 @@ def PlayVideo(url, mp4, **kwargs):
return IndirectResponse(VideoClipObject, key=file)

raise Ex.MediaNotAvailable



####################################################################################################
####################################################################################################
"""
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
78 changes: 41 additions & 37 deletions Contents/Services/URL/WholeCloud/ServiceCode.pys
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)

0 comments on commit eae7bb3

Please sign in to comment.