cleaned variable names

This commit is contained in:
Paweł Płazieński 2016-02-20 16:35:19 +01:00
parent 3db704fa51
commit b585f21d77

21
napi
View file

@ -60,16 +60,17 @@ for movie_filename in args:
"downloaded_subtitles_lang" : language
}
try:
request_stream = urllib.urlencode(request_data)
response = urllib.urlopen(base_url, request_stream)
xml = ET.XML(response.read())
content = xml.find("subtitles").find("content").text
request_data = urllib.urlencode(request_data)
response = urllib.urlopen(base_url, request_data)
response_xml = ET.XML(response.read())
content = response_xml.find("subtitles").find("content").text
except:
print "%s: No subtitles" % (movie_filename,)
sys.exit(2)
decoded_content = base64.b64decode(content)
with open(input_filename, "w") as input_file:
input_file.write(base64.b64decode(content))
nazwa = movie_filename[:-4]+'.srt'
input_file.write(decoded_content)
subtitle_filename = movie_filename[:-4] + ".srt"
executed = [
'/usr/bin/7z', # executable
@ -80,15 +81,15 @@ for movie_filename in args:
input_filename, # input file
]
with open(nazwa, "w") as output_file:
process = subprocess.Popen(executed, stdout=output_file)
with open(subtitle_filename, "w") as subtitle_file:
process = subprocess.Popen(executed, stdout=subtitle_file)
result = process.wait()
if result != 0:
print "%s: 7zip returned non-zero code: %s" % (movie_filename, subtitle_filename)
os.remove(nazwa)
os.remove(subtitle_filename)
sys.exit(3)
print "%s: Subtitles fetched successfully to %s" % (movie_filename, nazwa)
print "%s: Subtitles fetched successfully to %s" % (movie_filename, subtitle_filename)
os.remove(input_filename)