mirror of
https://source.perfectable.org/nivertius/napi.git
synced 2025-07-01 21:35:35 +02:00
using subprocess instead of os.system
This commit is contained in:
parent
71cb0943e3
commit
383c9af291
1 changed files with 15 additions and 1 deletions
16
napi
16
napi
|
@ -21,6 +21,7 @@ import urllib2
|
|||
import xml.etree.ElementTree as ET
|
||||
|
||||
import base64
|
||||
import subprocess
|
||||
|
||||
base_url = "http://napiprojekt.pl/api/api-napiprojekt3.php"
|
||||
password = "iBlm8NTigvru0Jr0"
|
||||
|
@ -56,7 +57,20 @@ def download_subtitles(digest):
|
|||
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+"\"")):
|
||||
executed = [
|
||||
'/usr/bin/7z', # executable
|
||||
'x', # command: extract
|
||||
'-p' + password, # use password
|
||||
'-y', # assume yes on all queries
|
||||
'-so', # into standard out
|
||||
input_filename, # input file
|
||||
]
|
||||
|
||||
with open(nazwa, "w") as output_file:
|
||||
process = subprocess.Popen(executed, stdout=output_file)
|
||||
result = process.wait()
|
||||
|
||||
if result != 0:
|
||||
print "nie ma napisa do filmu", sys.argv[1]
|
||||
os.remove(nazwa)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue