-
Notifications
You must be signed in to change notification settings - Fork 0
/
napi.py
executable file
·78 lines (64 loc) · 1.78 KB
/
napi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python
# reversed napi 0.16.3.1
#
# by gim,krzynio,dosiu,hash 2oo8.
#
#
#
# last modified: 6-I-2oo8
#
# 4pc0h f0rc3
#
# do dzialania potrzebny jest p7zip-full (tak sie nazywa paczka w debianie)
#
# POZDRAWIAMY NASZYCH FANOW!
import md5, sys, urllib, os
import urllib
import urllib2
import xml.etree.ElementTree as ET
import base64
def f(z):
idx = [ 0xe, 0x3, 0x6, 0x8, 0x2 ]
mul = [ 2, 2, 5, 4, 3 ]
add = [ 0, 0xd, 0x10, 0xb, 0x5 ]
b = []
for i in xrange(len(idx)):
a = add[i]
m = mul[i]
i = idx[i]
t = a + int(z[i], 16)
v = int(z[t:t+2], 16)
b.append( ("%x" % (v*m))[-1] )
return ''.join(b)
if(len(sys.argv)==1):
print "wy*dalaj na stadion po film"
sys.exit(2)
d = md5.new()
d.update(open(sys.argv[1]).read(10485760))
def download_subtitles(digest):
request_data = {
"downloaded_subtitles_id" : digest,
"mode" : "31",
"client" : "NapiProjekt",
"downloaded_subtitles_lang" : "PL"
}
try:
request_stream = urllib.urlencode(request_data)
request = urllib2.Request("http://napiprojekt.pl/api/api-napiprojekt3.php", request_stream)
response = urllib2.urlopen(request)
xml = ET.XML(response.read())
content = xml.find("subtitles").find("content").text
except:
print "nie ma napisa do filmu: ", sys.argv[1]
sys.exit(2)
location = os.path.dirname(sys.argv[1])
archivepath = os.path.join(location,"napisy.7z")
open(archivepath,"w").write(base64.b64decode(content))
nazwa=os.path.join(location,sys.argv[1][:-3]+'txt')
if (os.system("/usr/local/bin/7z x -y -so -piBlm8NTigvru0Jr0 "+archivepath+" 2>/dev/null >\""+nazwa+"\"")):
print "nie ma napisa do filmu", sys.argv[1]
os.remove(nazwa)
else:
print "napisy pobrano, milordzie!"
os.remove(archivepath)
download_subtitles(d.hexdigest())