forked from QiuChenlyOpenSource/MusicDownload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
71 lines (52 loc) · 1.41 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright (c) 2023. 秋城落叶, Inc. All Rights Reserved
# @作者 : 秋城落叶(QiuChenly)
# @邮件 : [email protected]
# @文件 : 项目 [qqmusic] - test.py
# @修改时间 : 2023-03-06 06:02:23
# @上次修改 : 2023/3/6 下午6:02
import time
import uuid
from concurrent.futures import Future
from uuid import UUID
import requests
from flask import Flask
# from src.Api.Kuwo import KwApi
# from src.Api.Netease import Netease
# from src.Common import Concurrency
from src.Common.Concurrency import Downloader
# from src.Common.Tools import subString
# from src.Types.Types import Songs
# s = Songs("哈咯")
# s.title = "asd"
# print(s.title)
# subString("kw_token=123123;", "kw_token=", ";")
# kw = KwApi()
# res = kw.search("周杰伦")
# res = kw.getDownloadUrl(res[0].rid)
# res = requests.get(res)
# with open("test.mp3", 'wb+') as w:
# w.write(res.content)
# w.flush()
# 只能下载MP3格式 很遗憾
# ease = Netease()
# qrCode = ease.qrLogin()
def done(ret: Future):
print(f"ret is down {ret.result()}")
def executeFn(a1: str, a2: bool):
time.sleep(4)
return a1 + "a2 True" if a2 else "a2 False"
app: Flask = Flask(__name__)
c = Downloader()
c.initPool(16)
@app.get("/")
def add():
print("任务开始")
c.addTask(done, executeFn, "1234", False)
return {
'code': 200
}
app.run(
'0.0.0.0',
8899,
debug=False
)