mirror of
https://source.perfectable.org/nivertius/napi.git
synced 2025-07-02 03:55:14 +02:00
67 lines
1.5 KiB
Python
Executable file
67 lines
1.5 KiB
Python
Executable file
#!/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
|
|
|
|
base_url = "http://napiprojekt.pl/api/api-napiprojekt3.php"
|
|
password = "iBlm8NTigvru0Jr0"
|
|
input_filename = '/tmp/napi-temp-file'
|
|
|
|
language = "PL"
|
|
|
|
if(len(sys.argv)==1):
|
|
print "wy*dalaj na stadion po film"
|
|
sys.exit(2)
|
|
|
|
d = md5.new()
|
|
movie_filename = sys.argv[1]
|
|
d.update(open(movie_filename).read(10485760))
|
|
|
|
def download_subtitles(digest):
|
|
request_data = {
|
|
"downloaded_subtitles_id" : digest,
|
|
"mode" : "31",
|
|
"client" : "NapiProjekt",
|
|
"downloaded_subtitles_lang" : language
|
|
}
|
|
try:
|
|
request_stream = urllib.urlencode(request_data)
|
|
request = urllib2.Request(base_url, 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)
|
|
with open(input_filename, "w") as input_file:
|
|
input_file.write(base64.b64decode(content))
|
|
nazwa = movie_filename[:-4]+'.srt'
|
|
|
|
if (os.system("/usr/local/bin/7z x -y -so -p" + password + " " + input_filename + " 2>/dev/null >\""+nazwa+"\"")):
|
|
print "nie ma napisa do filmu", sys.argv[1]
|
|
os.remove(nazwa)
|
|
else:
|
|
print "napisy pobrano, milordzie!"
|
|
|
|
os.remove(input_filename)
|
|
|
|
download_subtitles(d.hexdigest())
|