Skip to content

Commit f6a910d

Browse files
committed
feat: auto refresh play url for aliyundrive
close AlistGo/alist#5631 close AlistGo/alist#5574
1 parent 753e582 commit f6a910d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/pages/home/previews/aliyun_video.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,40 @@ const Preview = () => {
180180
player.subtitle.url = proxyLink(subtitle, true)
181181
})
182182
}
183+
interval = window.setInterval(resetPlayUrl, 1000 * 60 * 14)
183184
})
184185
})
186+
let interval: number
187+
let curSeek: number
188+
async function resetPlayUrl() {
189+
const resp = await post()
190+
handleResp(resp, async (data) => {
191+
const list =
192+
data.video_preview_play_info.live_transcoding_task_list.filter(
193+
(l) => l.url,
194+
)
195+
if (list.length === 0) {
196+
notify.error("No transcoding video found")
197+
return
198+
}
199+
const quality = list.map((item, i) => {
200+
return {
201+
html: item.template_id,
202+
url: item.url,
203+
default: i === list.length - 1,
204+
}
205+
})
206+
player.quality = quality
207+
curSeek = player.currentTime
208+
await player.switchUrl(quality[quality.length - 1].url)
209+
setTimeout(() => {
210+
player.seek = curSeek
211+
}, 1000)
212+
})
213+
}
185214
onCleanup(() => {
186215
player?.destroy()
216+
window.clearInterval(interval)
187217
})
188218
const [autoNext, setAutoNext] = createSignal()
189219
return (

0 commit comments

Comments
 (0)