From b585f21d777e0c47566673f150c84cebed2f70ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20P=C5=82azie=C5=84ski?= Date: Sat, 20 Feb 2016 16:35:19 +0100 Subject: [PATCH] cleaned variable names --- napi | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/napi b/napi index 1b8b8f4..7d0ac6e 100755 --- a/napi +++ b/napi @@ -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)