admin commited on
Commit
bb1c682
·
1 Parent(s): d5dda18

combine if elif

Browse files
Files changed (1) hide show
  1. app.py +2 -12
app.py CHANGED
@@ -105,18 +105,8 @@ def url_infer(song: str, cache_dir="./__pycache__/mode2"):
105
  clean_cache(cache_dir)
106
  download_path = f"{cache_dir}/output.mp3"
107
  try:
108
- if is_url(song):
109
- if "163" in song and "?id=" in song:
110
- song_id = get_first_integer(song.split("?id=")[1])
111
- song = f"https://music.163.com/song/media/outer/url?id={song_id}.mp3"
112
- song_name, free = music163_song_info(song_id)
113
- if not free:
114
- raise AttributeError("Unable to parse VIP songs")
115
-
116
- download_audio(song, download_path)
117
-
118
- elif song.isdigit():
119
- song_id = song
120
  song = f"https://music.163.com/song/media/outer/url?id={song_id}.mp3"
121
  song_name, free = music163_song_info(song_id)
122
  if not free:
 
105
  clean_cache(cache_dir)
106
  download_path = f"{cache_dir}/output.mp3"
107
  try:
108
+ if (is_url(song) and "163" in song and "?id=" in song) or song.isdigit():
109
+ song_id = get_first_integer(song.split("?id=")[-1])
 
 
 
 
 
 
 
 
 
 
110
  song = f"https://music.163.com/song/media/outer/url?id={song_id}.mp3"
111
  song_name, free = music163_song_info(song_id)
112
  if not free: