Spaces:
Running
Running
admin
commited on
Commit
·
17c780d
1
Parent(s):
c86a17a
fix vip ret
Browse files
README.md
CHANGED
@@ -9,6 +9,4 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
short_description: QQ Music Parser
|
12 |
-
---
|
13 |
-
|
14 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
short_description: QQ Music Parser
|
12 |
+
---
|
|
|
|
app.py
CHANGED
@@ -31,13 +31,12 @@ def insert_metadata(file_path: str, title, artist, album):
|
|
31 |
print(f"Metadata was successfully inserted into {file_path}")
|
32 |
|
33 |
|
34 |
-
def download_file(
|
35 |
if os.path.exists(cache):
|
36 |
shutil.rmtree(cache)
|
37 |
|
38 |
os.makedirs(cache)
|
39 |
-
|
40 |
-
local_filename = f"{cache}/{id}.{format}"
|
41 |
response = requests.get(url, stream=True)
|
42 |
if response.status_code == 200:
|
43 |
with open(local_filename, "wb") as file:
|
@@ -106,10 +105,10 @@ def infer(url: str):
|
|
106 |
params={"mid": song_mid},
|
107 |
)
|
108 |
|
109 |
-
if response.status_code == 200:
|
110 |
data = response.json()["data"]
|
111 |
song = download_file(
|
112 |
-
data["
|
113 |
data["urls"][0]["url"],
|
114 |
data["title"],
|
115 |
data["author"],
|
@@ -122,6 +121,9 @@ def infer(url: str):
|
|
122 |
quality = data["urls"][0]["type"]
|
123 |
size = data["urls"][0]["size"]
|
124 |
|
|
|
|
|
|
|
125 |
except Exception as e:
|
126 |
title = f"{e}"
|
127 |
|
@@ -144,7 +146,7 @@ if __name__ == "__main__":
|
|
144 |
gr.Textbox(label="Artist", show_copy_button=True),
|
145 |
gr.Textbox(label="Album", show_copy_button=True),
|
146 |
gr.Textbox(label="Quality", show_copy_button=True),
|
147 |
-
gr.Textbox(label="Size", show_copy_button=True),
|
148 |
],
|
149 |
title="QQ Music Parser",
|
150 |
description="This site does not provide any audio storage services, only provide the most basic parsing services",
|
|
|
31 |
print(f"Metadata was successfully inserted into {file_path}")
|
32 |
|
33 |
|
34 |
+
def download_file(mid: str, url: str, title, artist, album, cache="./__pycache__"):
|
35 |
if os.path.exists(cache):
|
36 |
shutil.rmtree(cache)
|
37 |
|
38 |
os.makedirs(cache)
|
39 |
+
local_filename = f"{cache}/{mid}.mp3"
|
|
|
40 |
response = requests.get(url, stream=True)
|
41 |
if response.status_code == 200:
|
42 |
with open(local_filename, "wb") as file:
|
|
|
105 |
params={"mid": song_mid},
|
106 |
)
|
107 |
|
108 |
+
if response.status_code == 200 and response.json()["code"] == 200:
|
109 |
data = response.json()["data"]
|
110 |
song = download_file(
|
111 |
+
data["mid"],
|
112 |
data["urls"][0]["url"],
|
113 |
data["title"],
|
114 |
data["author"],
|
|
|
121 |
quality = data["urls"][0]["type"]
|
122 |
size = data["urls"][0]["size"]
|
123 |
|
124 |
+
else:
|
125 |
+
raise Exception(response.json()["msg"])
|
126 |
+
|
127 |
except Exception as e:
|
128 |
title = f"{e}"
|
129 |
|
|
|
146 |
gr.Textbox(label="Artist", show_copy_button=True),
|
147 |
gr.Textbox(label="Album", show_copy_button=True),
|
148 |
gr.Textbox(label="Quality", show_copy_button=True),
|
149 |
+
gr.Textbox(label="Size(B)", show_copy_button=True),
|
150 |
],
|
151 |
title="QQ Music Parser",
|
152 |
description="This site does not provide any audio storage services, only provide the most basic parsing services",
|