I have some code which I would like to be decoded but not having much luck in guessing what the codepage is, if any is being used. Any help would be much appreciated.
<If you cut out the uncoded data and just decode the coded string you will get the following but Lord knows what it is or means.
import base64
coded_data = "Just the coded data part............"
decoded_data = base64.b64decode(coded_data)
print (decoded_data)
Starts with the following output:
92 21,94,14,c,117,11,106,3a,2f,4f,8e
ef e2.13d.bd 92 a0
ef c9 92 73
3e = '104.84.115'
19 = 94.a0(e9=3e)
dd = a0(3e, 2f.1b)
c7 = 21.67(106.e8.e6('a3://ec/c1/' + 3e , 'c7.108'))
98 = 21.67(106.e8.e6('a3://ec/c1/' + 3e, '98.e0'))
aa = 'f4://91.7b.138/bb/70.b9'
74 = 19.2c('cf')
38 = 19.2c('c0')
63 = dd.fd.146('63', '')
ab = 19.2c('c5')
bc ='72://91.81.4e/13/13a/105?159='
ba ='&d0=153&f1=ae&155=121&10f=41&60=84&7f=50'
f0 = '72://91.81.4e/13/13a/b2?f1=ae&ca='
de = '&7f=50&10f=40'
Note that, as pointed out in the comments, if you simply want to see the resulting script you can replace the second exec
with print
, so going from e.g.:
exec("import re;import base64");exec((lambda p,y: ...
to:
exec("import re;import base64");print((lambda p,y: ...
# ^^^^^
and run the result. If you want to understand a bit more about how it works, see below.
You have two inputs, one which is just pipe-separated data (pipestr
) and the other of which is the structure of the program to assemble based on that data, encoded in base 64 (b64str
). Factoring out those two string literals (plus the unnecessary '0x'
), you're left with:
data = pipestr.split("|")
code = re.sub(
r"([0-9a-f]+)", # find all hexadecimals
lambda match: data[int(match.group(1), 16)], # replace them by indexing the data
base64.b64decode(b64str) # insert into the structure
)
Here is the decoded structure:
92 21,94,14,c,117,11,106,3a,2f,4f,8e
ef e2.13d.bd 92 a0
ef c9 92 73
3e = '104.84.115'
19 = 94.a0(e9=3e)
dd = a0(3e, 2f.1b)
c7 = 21.67(106.e8.e6('a3://ec/c1/' + 3e , 'c7.108'))
98 = 21.67(106.e8.e6('a3://ec/c1/' + 3e, '98.e0'))
aa = 'f4://91.7b.138/bb/70.b9'
74 = 19.2c('cf')
38 = 19.2c('c0')
63 = dd.fd.146('63', '')
ab = 19.2c('c5')
bc ='72://91.81.4e/13/13a/105?159='
ba ='&d0=153&f1=ae&155=121&10f=41&60=84&7f=50'
f0 = '72://91.81.4e/13/13a/b2?f1=ae&ca='
de = '&7f=50&10f=40'
3f 70():
14a=52(aa)
17=3a.25('f3="(.+?)".+?48="(.+?)".+?101="(.+?)"',3a.5a).24(14a)
44 f3,48,63 23 17:
16 c2 'be' 23 f3:
20(f3,48,1,63,c7)
16 'be' 23 f3:
16 74 == '9e':
16 38 == '':
78 = 14.bf()
b4 = 78.d8('d7 a5', '148 139 122 111 12f cf 64','','b8 118 a c0 111 ff da 112','b5','129 14c')
16 b4 == 1:
56 = 21.9f('', '113 99')
56.ad()
16 (56.7a()):
8a = 56.a7()
19.d9('c0',8a)
20(f3,48,1,63,c7)
16 74 == '9e':
16 38 <> '':
20(f3,48,1,63,c7)
3c('152 137 f9 136','48',2,'f4://91.7b.138/bb/102/fe.108',c7)
21.f('154.2a(141)')
3f 77(48):
16 '70' 23 48:
9c(48)
16 'be' 23 48:
16 38 <> '':
78 = 14.bf()
b4 = 78.d8('d7 a5', 'b8 11f 10a c0 14b 118','111 f2','','b5','12c 14f 10a 123')
16 b4 == 1:
58:
56 = 21.9f('', '113 99')
56.ad()
16 (56.7a()):
8a = 56.a7()
16 8a == 38:
26 = 62(48)
44 68 23 26:
3c(68["f3"],68["48"],3,63,c7)
1e:45
16 'b6' 23 48:
26 = 62(48)
10e = 65(26)
44 68 23 26:
7c(68["f3"],68["48"],3,63,10e,18=6f)
a9('b6', '127')
16 '70' 23 48:
21.f('154.2a(50)')
57 'be' c2 23 48:
128 = 48
26 = 62(48)
44 68 23 26:
16 '13.4e/7d?33=' 23 68["48"]:
20(68["f3"],68["48"],3,63,c7)
57 '13.4e/54?5f=' 23 68["48"]:
20(68["f3"],68["48"],3,63,c7)
55:
16 'b9' 23 68["48"]:
20(68["f3"],68["48"],3,63,c7)
55:
3c(68["f3"],68["48"],3,63,c7)
21.f('154.2a(50)')
3f 9c(48):
14a=52(48)
17=3a.25('f3="(.+?)".+?48="(.+?)".+?101="(.+?)"',3a.5a).24(14a)
44 f3,48,63 23 17:
16 '13.4e/54?5f=' 23 48:
20(f3,48,3,63,c7)
57 '13.4e/7d?33=' 23 48:
20(f3,48,3,63,c7)
55:
20(f3,48,1,63,c7)
21.f('154.2a(50)')
3f 62(48):
14a=52(48)
61=3a.25('^#.+?:-?[0-9]*(.*?),(.*?)\fc(.*?)$',3a.158+3a.14d+3a.fb+3a.151).24(14a)
10b = []
44 15a, f3, 48 23 61:
36 = {"15a": 15a, "f3": f3, "48": 48}
10b.8f(36)
5f = []
44 68 23 10b:
36 = {"f3": 68["f3"], "48": 68["48"]}
61=3a.25(' (.+?)="(.+?)"',3a.158+3a.14d+3a.fb+3a.151).24(68["15a"])
44 d1, d6 23 61:
36[d1.cc().11e().4('-', '15c')] = d6.cc()
5f.8f(36)
1f 5f
3f 97(48,f3):
29 48
16 'b9' 23 48:
29 '124 b9'
77(48)
55:
16 '13.4e/7d?33=' 23 48:
29 'ac 107'
3d = 48.80('33=')[1]
82 = bc + 3d + ba
37 = 11.4a(82)
37.2e('89-6c', '4c/5.0 (157; fb; 157 ce 5.1; dc-cb; d5:1.9.0.3) 6d/2d 4b/3.0.3')
7 = 11.49(37)
14a=7.85()
7.6b()
14a = 14a.4('\147','').4('\fc','').4(' ','')
17=3a.25('"a2": "(.+?)".+?"87": "(.+?)"',3a.5a).24(14a)
29 17
44 9d,f3 23 17:
48 = '72://91.13.4e/db?14e='+9d
3c(f3,48,3,63,c7)
57 '13.4e/54?5f=' 23 48:
29 'ac f6'
3d = 48.80('54?5f=')[1]
82 = f0 + 3d + de
37 = 11.4a(82)
37.2e('89-6c', '4c/5.0 (157; fb; 157 ce 5.1; dc-cb; d5:1.9.0.3) 6d/2d 4b/3.0.3')
7 = 11.49(37)
14a=7.85()
7.6b()
14a = 14a.4('\147','').4('\fc','').4(' ','')
17=3a.25('"87": "(.+?)".+?"a2": "(.+?)"',3a.5a).24(14a)
44 f3,9d 23 17:
48 = '72://91.13.4e/db?14e='+9d
3c(f3,48,3,63,c7)
57 'c6' 23 48:
29 'c8'
48 = 48.4('84','11c/84')
37 = 11.4a(48)
37.2e('89-6c', '4c/5.0 (157; fb; 157 ce 5.1; dc-cb; d5:1.9.0.3) 6d/2d 4b/3.0.3')
7 = 11.49(37)
14a=7.85()
7.6b()
17=3a.25('149","48"\:"(.+?)"').24(14a)[0]
1a=17.4('\/','/')
43=53
13b=14.31(f3, 2b=63,e=63); 13b.3b( 60="5d", 22={ "71": f3 } )
43=c.13e(47=66(2f.1b[1]),48=1a,34=13b)
58:
21.b7 ().f5(1a, 13b, 6f)
1f 43
1e:
45
55:
29 '116 132'
16 4f.5b(48).e1():
1a = 4f.5b(48).144()
55: 1a=48
43=53
13b=14.31(f3, 2b=63,e=63); 13b.3b( 60="5d", 22={ "71": f3 } )
43=c.13e(47=66(2f.1b[1]),48=1a,34=13b)
58:
21.b7 ().f5(1a, 13b, 6f)
1f 43
1e:
45
3f a8():
76 = ''
e5 = '72://10c.114.4e/10d/150/4d-8b/130?96'
37 = 11.4a(e5)
37.2e('89-6c', '4c/5.0 (157; fb; 157 ce 5.1; dc-cb; d5:1.9.0.3) 6d/2d 4b/3.0.3')
7 = 11.49(37)
14a=7.85()
7.6b()
14a = 14a.4('/fc','')
14a = 14a.90('df-8').103('df-8').4(''','\'').4(' ',' - ').4('w','')
17=3a.25("<87>(.+?)</87>.+?<a4>(.+?)</a4>",3a.5a).24(14a)[1:]
44 30, 95 23 17:
58:
30 = 30.90('11b', 'b3')
1e:
30 = 30.90('df-8','b3')
95 = 95[:-15]
30 = 30.4('&143;','')
95 = '[6e f7][b]'+95+'[/b][/6e]'
76 = 76+95+'\fc'+30+'\fc'+'\fc'
9b('[6e f7][b]@fa[/b][/6e]', 76)
3f 9b(a6, 76):
e9 = 125
21.f('af(%d)' % e9)
21.d2(100)
e3 = 14.109(e9)
a1 = 50
11d (a1 > 0):
58:
21.d2(10)
a1 -= 1
e3.7e(1).ed(a6)
e3.7e(5).f8(76)
1f
1e:
45
3f 52(48):
48 += '?%d=%d' % (8e.b1(1, d4), 8e.b1(1, d4))
37 = 11.4a(48)
37.2e('89-6c', '4c/5.0 (157; fb; 157 ce 5.1; dc-cb; d5:1.9.0.3) 6d/2d 4b/3.0.3')
7 = 11.49(37)
14a=7.85()
14a = 14a.4('\147','').4('\15b','').4('&13c;','').4('\'','')
7.6b()
1f 14a
3f 88():
86=[]
79=2f.1b[2]
16 65(79)>=2:
15a=2f.1b[2]
6a=15a.4('?','')
16 (15a[65(15a)-1]=='/'):
15a=15a[0:65(15a)-2]
42=6a.80('&')
86={}
44 156 23 11a(65(42)):
28={}
28=42[156].80('=')
16 (65(28))==2:
86[28[0]]=28[1]
1f 86
3f 20(f3,48,12,63,c7,145=''):
ee=2f.1b[0]+"?48="+117.6(48)+"&12="+59(12)+"&f3="+117.6(f3)+"&63="+117.6(63)+"&145="+117.6(145)
43=53
13b=14.31(f3, 2b="69.e0", e=63)
13b.3b( 60="5d", 22={ "71": f3, 'eb': 145 } )
13b.27('1c', c7)
43=c.13e(47=66(2f.1b[1]),48=ee,34=13b,18=53)
1f 43
3f 3c(f3,48,12,63,c7,145=''):
ee=2f.1b[0]+"?48="+117.6(48)+"&12="+59(12)+"&f3="+117.6(f3)+"&63="+117.6(63)+"&145="+117.6(145)
43=53
13b=14.31(f3, 2b="69.e0", e=63)
13b.3b( 60="5d", 22={ "71": f3, 'eb': 145 } )
13b.27('1c', c7)
43=c.13e(47=66(2f.1b[1]),48=ee,34=13b,18=6f)
1f 43
3f 7c(f3,48,12,63,93,18=6f):
16 ab=='9e':
16 c2 '6e' 23 f3:
46=f3.8d('(')
5c=""
1d=""
16 65(46)>0:
5c=46[0]
1d=46[2].8d(')')
16 65(1d)>0:
1d=1d[0]
133 = 73.e7()
83 = 133.ea('126', f3=5c ,13f=1d)
ee=2f.1b[0]+"?48="+117.6(48)+"&51="+59(51)+"&12="+59(12)+"&f3="+117.6(f3)
43=53
13b=14.31(f3, 2b=83['e4'], e=63)
13b.3b( 60="5d", 22= 83 )
32 = []
32.8f(('120 c4', '140.110(134)'))
13b.8c(32, c3=53)
16 c2 83['75'] == '': 13b.27('1c', 83['75'])
55: 13b.27('1c', c7)
43=c.13e(47=66(2f.1b[1]),48=ee,34=13b,18=18,d3=93)
1f 43
55:
ee=2f.1b[0]+"?48="+117.6(48)+"&51="+59(51)+"&12="+59(12)+"&f3="+117.6(f3)
43=53
13b=14.31(f3, 2b=98, e=98)
13b.3b( 60="5d", 22={ "71": f3 } )
13b.27('1c', c7)
43=c.13e(47=66(2f.1b[1]),48=ee,34=13b,18=18)
1f 43
3f a9(64, 9a):
16 64:
c.cd(66(2f.1b[1]), 64)
16 19.2c('135-12a')=='9e':
21.f("154.2a(%150)" % 19.2c(9a) )
15a=88(); 48=5e; f3=5e; 12=5e; 51=5e; 63=5e
58: 51=117.35(15a["51"])
1e: 45
58: 48=117.35(15a["48"])
1e: 45
58: f3=117.35(15a["f3"])
1e: 45
58: 12=66(15a["12"])
1e: 45
58: 63=117.35(15a["63"])
1e: 45
#29 "131: "+59(51); 29 "12e: "+59(12); 29 "142: "+59(48); 29 "12d: "+59(f3)
16 12==5e 12b 48==5e 12b 65(48)<1: 70()
57 12==1:77(48)
57 12==2:a8()
57 12==3:97(48,f3)
c.b0(66(2f.1b[1]))
These various parts are replaced by indexing into the data to select the appropriate component (e.g. 'c'
in the first line becomes 12
, which is xbmcplugin
from the pipe-separated data).
>>> for x in range(20):
print format(x, '2'), format(x, '2x'), data[x]
0 0 0
1 1 1
2 2 2
3 3 3
4 4 replace
5 5 5
6 6 quote_plus
7 7 response
8 8 8
9 9 9
10 a a
11 b B
12 c xbmcplugin
13 d d
14 e thumbnailImage
15 f executebuiltin
16 10 10
17 11 urllib2
18 12 mode
19 13 youtube
The program builds and executes the following:
import xbmc,xbmcaddon,xbmcgui,xbmcplugin,urllib,urllib2,os,re,sys,urlresolver,random
from resources.libs.common_addon import Addon
from metahandler import metahandlers
addon_id = 'plugin.video.ukturk'
selfAddon = xbmcaddon.Addon(id=addon_id)
addon = Addon(addon_id, sys.argv)
fanart = xbmc.translatePath(os.path.join('special://home/addons/' + addon_id , 'fanart.jpg'))
icon = xbmc.translatePath(os.path.join('special://home/addons/' + addon_id, 'icon.png'))
baseurl = 'http://www.metalkettle.co/UKTurk/Index.txt'
adultopt = selfAddon.getSetting('adult')
adultpass = selfAddon.getSetting('password')
iconimage = addon.queries.get('iconimage', '')
metaset = selfAddon.getSetting('enable_meta')
ytapi1 ='https://www.googleapis.com/youtube/v3/search?q='
ytapi2 ='®ionCode=US&part=snippet&hl=en_US&key=AIzaSyA7v1QOHz8Q4my5J8uGSpr0zRrntRjnMmk&type=video&maxResults=50'
ytpl = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId='
ytpl2 = '&maxResults=50&key=AIzaSyBAdxZCHbeJwnQ7dDZQJNfcaF46MdqJ24E'
def Index():
link=open_url(baseurl)
match=re.compile('name="(.+?)".+?url="(.+?)".+?img="(.+?)"',re.DOTALL).findall(link)
for name,url,iconimage in match:
if not 'XXX' in name:
addDir(name,url,1,iconimage,fanart)
if 'XXX' in name:
if adultopt == 'true':
if adultpass == '':
dialog = xbmcgui.Dialog()
ret = dialog.yesno('Adult Content', 'You have opted to show adult content','','Please set a password to prevent accidental access','Cancel','Lets Go')
if ret == 1:
keyb = xbmc.Keyboard('', 'Set Password')
keyb.doModal()
if (keyb.isConfirmed()):
passw = keyb.getText()
selfAddon.setSetting('password',passw)
addDir(name,url,1,iconimage,fanart)
if adultopt == 'true':
if adultpass <> '':
addDir(name,url,1,iconimage,fanart)
addLink('UK Turk Twitter Feed','url',2,'http://www.metalkettle.co/UKTurk/thumbs/twitter.jpg',fanart)
xbmc.executebuiltin('Container.SetViewMode(500)')
def GetChans(url):
if 'Index' in url:
CatIndex(url)
if 'XXX' in url:
if adultpass <> '':
dialog = xbmcgui.Dialog()
ret = dialog.yesno('Adult Content', 'Please enter the password you set','to continue','','Cancel','Show me the money')
if ret == 1:
try:
keyb = xbmc.Keyboard('', 'Set Password')
keyb.doModal()
if (keyb.isConfirmed()):
passw = keyb.getText()
if passw == adultpass:
channels = GetList(url)
for channel in channels:
addLink(channel["name"],channel["url"],3,iconimage,fanart)
except:pass
if 'movies' in url:
channels = GetList(url)
cnt = len(channels)
for channel in channels:
addLinkMeta(channel["name"],channel["url"],3,iconimage,cnt,isFolder=False)
setView('movies', 'MAIN')
if 'Index' in url:
xbmc.executebuiltin('Container.SetViewMode(50)')
elif 'XXX' not in url:
burl = url
channels = GetList(url)
for channel in channels:
if 'youtube.com/results?search_query=' in channel["url"]:
addDir(channel["name"],channel["url"],3,iconimage,fanart)
elif 'youtube.com/playlist?list=' in channel["url"]:
addDir(channel["name"],channel["url"],3,iconimage,fanart)
else:
if 'txt' in channel["url"]:
addDir(channel["name"],channel["url"],3,iconimage,fanart)
else:
addLink(channel["name"],channel["url"],3,iconimage,fanart)
xbmc.executebuiltin('Container.SetViewMode(50)')
def CatIndex(url):
link=open_url(url)
match=re.compile('name="(.+?)".+?url="(.+?)".+?img="(.+?)"',re.DOTALL).findall(link)
for name,url,iconimage in match:
if 'youtube.com/playlist?list=' in url:
addDir(name,url,3,iconimage,fanart)
elif 'youtube.com/results?search_query=' in url:
addDir(name,url,3,iconimage,fanart)
else:
addDir(name,url,1,iconimage,fanart)
xbmc.executebuiltin('Container.SetViewMode(50)')
def GetList(url):
link=open_url(url)
matches=re.compile('^#.+?:-?[0-9]*(.*?),(.*?)\n(.*?)$',re.I+re.M+re.U+re.S).findall(link)
li = []
for params, name, url in matches:
item_data = {"params": params, "name": name, "url": url}
li.append(item_data)
list = []
for channel in li:
item_data = {"name": channel["name"], "url": channel["url"]}
matches=re.compile(' (.+?)="(.+?)"',re.I+re.M+re.U+re.S).findall(channel["params"])
for field, value in matches:
item_data[field.strip().lower().replace('-', '_')] = value.strip()
list.append(item_data)
return list
def PLAYLINK(url,name):
print url
if 'txt' in url:
print 'Found txt'
GetChans(url)
else:
if 'youtube.com/results?search_query=' in url:
print 'Youtube Search'
searchterm = url.split('search_query=')[1]
ytapi = ytapi1 + searchterm + ytapi2
req = urllib2.Request(ytapi)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
link = link.replace('\r','').replace('\n','').replace(' ','')
match=re.compile('"videoId": "(.+?)".+?"title": "(.+?)"',re.DOTALL).findall(link)
print match
for ytid,name in match:
url = 'https://www.youtube.com/watch?v='+ytid
addLink(name,url,3,iconimage,fanart)
elif 'youtube.com/playlist?list=' in url:
print 'Youtube Playlist'
searchterm = url.split('playlist?list=')[1]
ytapi = ytpl + searchterm + ytpl2
req = urllib2.Request(ytapi)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
link = link.replace('\r','').replace('\n','').replace(' ','')
match=re.compile('"title": "(.+?)".+?"videoId": "(.+?)"',re.DOTALL).findall(link)
for name,ytid in match:
url = 'https://www.youtube.com/watch?v='+ytid
addLink(name,url,3,iconimage,fanart)
elif 'dailymotion' in url:
print 'DailyMotion'
url = url.replace('video','embed/video')
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
match=re.compile('mp4","url"\:"(.+?)"').findall(link)[0]
streamurl=match.replace('\/','/')
ok=True
liz=xbmcgui.ListItem(name, iconImage=iconimage,thumbnailImage=iconimage); liz.setInfo( type="Video", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=streamurl,listitem=liz)
try:
xbmc.Player ().play(streamurl, liz, False)
return ok
except:
pass
else:
print 'Direct Link'
if urlresolver.HostedMediaFile(url).valid_url():
streamurl = urlresolver.HostedMediaFile(url).resolve()
else: streamurl=url
ok=True
liz=xbmcgui.ListItem(name, iconImage=iconimage,thumbnailImage=iconimage); liz.setInfo( type="Video", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=streamurl,listitem=liz)
try:
xbmc.Player ().play(streamurl, liz, False)
return ok
except:
pass
def TWITTER():
text = ''
twit = 'https://script.google.com/macros/s/AKfycbyBcUa5TlEQudk6Y_0o0ZubnmhGL_-b7Up8kQt11xgVwz3ErTo/exec?588677963413065728'
req = urllib2.Request(twit)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
link = link.replace('/n','')
link = link.decode('utf-8').encode('utf-8').replace(''','\'').replace(' ',' - ').replace('…','')
match=re.compile("<title>(.+?)</title>.+?<pubDate>(.+?)</pubDate>",re.DOTALL).findall(link)[1:]
for status, dte in match:
try:
status = status.decode('ascii', 'ignore')
except:
status = status.decode('utf-8','ignore')
dte = dte[:-15]
status = status.replace('&','')
dte = '[COLOR blue][B]'+dte+'[/B][/COLOR]'
text = text+dte+'\n'+status+'\n'+'\n'
showText('[COLOR blue][B]@uk_turk[/B][/COLOR]', text)
def showText(heading, text):
id = 10147
xbmc.executebuiltin('ActivateWindow(%d)' % id)
xbmc.sleep(100)
win = xbmcgui.Window(id)
retry = 50
while (retry > 0):
try:
xbmc.sleep(10)
retry -= 1
win.getControl(1).setLabel(heading)
win.getControl(5).setText(text)
return
except:
pass
def open_url(url):
url += '?%d=%d' % (random.randint(1, 10000), random.randint(1, 10000))
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
link = link.replace('\r','').replace('\t','').replace(' ','').replace('\'','')
response.close()
return link
def get_params():
param=[]
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
return param
def addDir(name,url,mode,iconimage,fanart,description=''):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&description="+urllib.quote_plus(description)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, 'plot': description } )
liz.setProperty('fanart_image', fanart)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
def addLink(name,url,mode,iconimage,fanart,description=''):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&description="+urllib.quote_plus(description)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, 'plot': description } )
liz.setProperty('fanart_image', fanart)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
return ok
def addLinkMeta(name,url,mode,iconimage,itemcount,isFolder=False):
if metaset=='true':
if not 'COLOR' in name:
splitName=name.partition('(')
simplename=""
simpleyear=""
if len(splitName)>0:
simplename=splitName[0]
simpleyear=splitName[2].partition(')')
if len(simpleyear)>0:
simpleyear=simpleyear[0]
mg = metahandlers.MetaData()
meta = mg.get_meta('movie', name=simplename ,year=simpleyear)
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&site="+str(site)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
ok=True
liz=xbmcgui.ListItem(name, iconImage=meta['cover_url'], thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels= meta )
contextMenuItems = []
contextMenuItems.append(('Movie Information', 'XBMC.Action(Info)'))
liz.addContextMenuItems(contextMenuItems, replaceItems=True)
if not meta['backdrop_url'] == '': liz.setProperty('fanart_image', meta['backdrop_url'])
else: liz.setProperty('fanart_image', fanart)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isFolder,totalItems=itemcount)
return ok
else:
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&site="+str(site)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
ok=True
liz=xbmcgui.ListItem(name, iconImage=icon, thumbnailImage=icon)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
liz.setProperty('fanart_image', fanart)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isFolder)
return ok
def setView(content, viewType):
if content:
xbmcplugin.setContent(int(sys.argv[1]), content)
if selfAddon.getSetting('auto-view')=='true':
xbmc.executebuiltin("Container.SetViewMode(%s)" % selfAddon.getSetting(viewType) )
params=get_params(); url=None; name=None; mode=None; site=None; iconimage=None
try: site=urllib.unquote_plus(params["site"])
except: pass
try: url=urllib.unquote_plus(params["url"])
except: pass
try: name=urllib.unquote_plus(params["name"])
except: pass
try: mode=int(params["mode"])
except: pass
try: iconimage=urllib.unquote_plus(params["iconimage"])
except: pass
#print "Site: "+str(site); print "Mode: "+str(mode); print "URL: "+str(url); print "Name: "+str(name)
if mode==None or url==None or len(url)<1: Index()
elif mode==1:GetChans(url)
elif mode==2:TWITTER()
elif mode==3:PLAYLINK(url,name)
xbmcplugin.endOfDirectory(int(sys.argv[1]))