import json
import multiprocessing
import requests
def text (path):
list1 = []
list2 = []
with open(path,mode=‘r’) as f:
res = f.readlines()[0].strip(’\n’).split(’}’)
for json_ in res[:-1]:
json = json + ‘}’
_json = json.loads(_json)
song_play_url = _json[‘song_play_url’]
if song_play_url is not None: o
list1.append(song_play_url)
song_name = _json[‘song_name’]
list2.append(song_name)
return list1 , list2
song_url,song_name = text(‘F:\vscode\top_500.txt’)
def A(song_url,song_name):
i = -1
for path in song_url:
i += 1
response = requests.get(path)
mp3_ = response.content
with open(‘D:\music\wp\’+song_name[i]+’.mp3’,mode=‘wb’) as f:
f.write(mp3_)
if name == “main”:
x = int(len(song_url)/2)
p1 = multiprocessing.Process(target = A,args=(song_url[0:x],song_name[0:x]))
p2 = multiprocessing.Process(target = A,args=(song_url[x:],song_name[x:]))
p1.start()
p2.start()
p1.join()
p2.join()