@@ -28,7 +28,10 @@ def get_song(id,lyrics):
28
28
29
29
def get_song_id (url ):
30
30
res = requests .get (url , data = [('bitrate' , '320' )])
31
- return res .text .split ('"song":{"type":"' )[1 ].split ('","image":' )[0 ].split ('"id":"' )[- 1 ]
31
+ try :
32
+ return res .text .split ('"song":{"type":"' )[1 ].split ('","image":' )[0 ].split ('"id":"' )[- 1 ]
33
+ except IndexError :
34
+ return (res .text .split ('"pid":"' ))[1 ].split ('","' )[0 ]
32
35
33
36
def get_album (album_id ,lyrics ):
34
37
songs_json = []
@@ -44,7 +47,10 @@ def get_album(album_id,lyrics):
44
47
45
48
def get_album_id (input_url ):
46
49
res = requests .get (input_url )
47
- return res .text .split ('"album_id":"' )[1 ].split ('"' )[0 ]
50
+ try :
51
+ return res .text .split ('"album_id":"' )[1 ].split ('"' )[0 ]
52
+ except IndexError :
53
+ return res .text .split ('"page_id","' )[1 ].split ('","' )[0 ]
48
54
49
55
def get_playlist (listId ,lyrics ):
50
56
try :
@@ -60,7 +66,11 @@ def get_playlist(listId,lyrics):
60
66
61
67
def get_playlist_id (input_url ):
62
68
res = requests .get (input_url ).text
63
- return res .split ('"type":"playlist","id":"' )[1 ].split ('"' )[0 ]
69
+ try :
70
+ return res .split ('"type":"playlist","id":"' )[1 ].split ('"' )[0 ]
71
+ except IndexError :
72
+ return res .split ('"page_id","' )[1 ].split ('","' )[0 ]
73
+
64
74
65
75
def get_lyrics (id ):
66
76
url = endpoints .lyrics_base_url + id
0 commit comments