diff --git a/audio-fetcher.py b/audio-fetcher.py index c078b44..64ea6d0 100644 --- a/audio-fetcher.py +++ b/audio-fetcher.py @@ -15,8 +15,8 @@ def captcha_handler(captcha): # getting pazans pazanIds = None pazansFileName = sys.argv[1] -with open(pazansFileName, "r") as file: - jsonData = json.loads(file.read()) +with open(pazansFileName, "r") as pazans_file: + jsonData = json.loads(pazans_file.read()) pazanIds = [item[0] for item in sorted(jsonData.items(), key=lambda item: len(item[1]), reverse=True)] vk = vk_api.VkApi(token=sys.argv[3], app_id=sys.argv[4], captcha_handler=captcha_handler) @@ -38,8 +38,8 @@ for index, pazanId in enumerate(pazanIds, start=(int(sys.argv[5]) if len(sys.arg "url" : audio["url"], } pazanSongs.append(pazanSong) - with open(sys.argv[2], "a", encoding="utf-8") as file: - file.write(json.dumps({pazanId: pazanSongs}, ensure_ascii=False) + "\n") + with open(sys.argv[2], "a", encoding="utf-8") as f_out: + f_out.write(json.dumps({pazanId: pazanSongs}, ensure_ascii=False) + "\n") done = True except vk_api.ApiError as e: if e.code == 9: