File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,15 @@ const getSongDetail = async (playMusic: SongResult) => {
153
153
return { ...playMusic , backgroundColor, primaryColor } as SongResult ;
154
154
}
155
155
156
+ if ( playMusic . expiredAt && playMusic . expiredAt < Date . now ( ) ) {
157
+ console . info ( `歌曲已过期,重新获取: ${ playMusic . name } ` ) ;
158
+ playMusic . playMusicUrl = undefined ;
159
+ }
160
+
156
161
const playMusicUrl = playMusic . playMusicUrl || ( await getSongUrl ( playMusic . id , playMusic ) ) ;
162
+ playMusic . createdAt = Date . now ( ) ;
163
+ // 半小时后过期
164
+ playMusic . expiredAt = playMusic . createdAt + 1800000 ;
157
165
const { backgroundColor, primaryColor } =
158
166
playMusic . backgroundColor && playMusic . primaryColor
159
167
? playMusic
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ export interface SongResult {
38
38
cid : number ;
39
39
} ;
40
40
source ?: 'netease' | 'bilibili' ;
41
+ // 过期时间
42
+ expiredAt ?: number ;
43
+ // 获取时间
44
+ createdAt ?: number ;
41
45
}
42
46
43
47
export interface Song {
You can’t perform that action at this time.
0 commit comments