mirror of
https://github.com/BsaLee/up163cloud.git
synced 2026-01-15 18:20:43 +08:00
新增:跳过已上传歌曲
上传音乐前,检测是否已上传
This commit is contained in:
parent
5a7bcc49f2
commit
ede9a1fd35
20
main.py
20
main.py
@ -66,6 +66,21 @@ def get_song_details(song_ids):
|
|||||||
print("响应内容无法解析为JSON:", response.text)
|
print("响应内容无法解析为JSON:", response.text)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
# 判断歌曲是否已上传云盘
|
||||||
|
def has_uploaded(song_id, cookie):
|
||||||
|
url = f"http://localhost:3000/user/cloud/detail?id={song_id}&cookie={cookie}"
|
||||||
|
response = requests.get(url)
|
||||||
|
try:
|
||||||
|
response_data = response.json()
|
||||||
|
if response_data.get('code') == 200 and len(response_data['data']) != 0:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print("获取云盘歌曲详情失败:", response_data.get("message"))
|
||||||
|
return False
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
print("获取云盘歌曲信息失败,响应内容无法解析为JSON:", response.text)
|
||||||
|
return False
|
||||||
|
|
||||||
# 执行 import 请求
|
# 执行 import 请求
|
||||||
def import_song(song_info, cookie):
|
def import_song(song_info, cookie):
|
||||||
song_id = song_info['id']
|
song_id = song_info['id']
|
||||||
@ -101,6 +116,11 @@ def process_songs(song_info_list, cookie):
|
|||||||
song_id = song_info['id']
|
song_id = song_info['id']
|
||||||
print(f"正在导入歌曲ID: {song_id}")
|
print(f"正在导入歌曲ID: {song_id}")
|
||||||
|
|
||||||
|
# 已上传则跳过
|
||||||
|
if has_uploaded(song_id, cookie):
|
||||||
|
print('该歌曲已上传,跳过!')
|
||||||
|
continue
|
||||||
|
|
||||||
# 查询歌曲的详细信息
|
# 查询歌曲的详细信息
|
||||||
song_details = get_song_details([song_id])
|
song_details = get_song_details([song_id])
|
||||||
if song_details:
|
if song_details:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user