Some refactoring to audio-fetcher.py
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
import vk_api
|
||||
|
||||
|
||||
def captcha_handler(captcha):
|
||||
key = input("Enter Captcha {0}: ".format(captcha.get_url())).strip()
|
||||
return captcha.try_again(key)
|
||||
|
||||
# getting pazans
|
||||
pazanIds = None
|
||||
pazansFileName = sys.argv[1]
|
||||
@@ -11,20 +19,16 @@ with open(pazansFileName, "r") as 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):
|
||||
key = input("Enter Captcha {0}: ".format(captcha.get_url())).strip()
|
||||
return captcha.try_again(key)
|
||||
|
||||
vk = vk_api.VkApi(token=sys.argv[3], app_id=sys.argv[4], captcha_handler=captcha_handler)
|
||||
|
||||
for index, pazanId in enumerate(pazanIds, start=(int(sys.argv[5]) if len(sys.argv) > 5 else 0)):
|
||||
done = False
|
||||
while not done:
|
||||
try:
|
||||
print(index, pazanId)
|
||||
pazanSongs = []
|
||||
# jsonData = vk.method("audio.get", {"owner_id": pazanId, "need_user": 0, "count": 100})
|
||||
|
||||
print(index, pazanId)
|
||||
|
||||
jsonData = vk.method("execute.getMusic", {"id": pazanId})
|
||||
for audio in jsonData["items"]:
|
||||
pazanSong = {
|
||||
|
||||
Reference in New Issue
Block a user