From 3cd33d2048e041559329557a73e8fa613250be90 Mon Sep 17 00:00:00 2001 From: Oleg Morozenkov Date: Mon, 22 Feb 2016 11:42:57 +0300 Subject: [PATCH] Fetch audio of best pazans first --- audio-fetcher.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/audio-fetcher.py b/audio-fetcher.py index 2daf662..09677dc 100644 --- a/audio-fetcher.py +++ b/audio-fetcher.py @@ -8,7 +8,8 @@ import vk_api pazanIds = None pazansFileName = sys.argv[1] with open(pazansFileName) as file: - pazanIds = [int(line) for line in file] + jsonData = json.loads(file.read()) + pazanIds = [item[0] for item in sorted(jsonData.items(), key=lambda item: len(item[1]), reverse=True)] # getting music def captcha_handler(captcha): @@ -21,7 +22,7 @@ for index, pazanId in enumerate(pazanIds, start=(int(sys.argv[5]) if len(sys.arg done = False while not done: try: - print(index) + print(index, pazanId) pazanSongs = [] # jsonData = vk.method("audio.get", {"owner_id": pazanId, "need_user": 0, "count": 100}) jsonData = vk.method("execute.getMusic", {"id": pazanId})