radio.js 871 B

12345678910111213141516171819202122
  1. addEventListener('fetch', event => {
  2. event.respondWith(handleRequest(event.request))
  3. })
  4. async function handleRequest(request) {
  5. const url = new URL(request.url)
  6. const id = url.searchParams.get('id') || '639'
  7. const logo = url.searchParams.has('logo')
  8. const d = new Date().toISOString().split('T')[0]
  9. const post = `startdate=&enddate=${d}&broadCastId=${id}`
  10. const apiUrl = 'https://ytapi.radio.cn/ytsrv/srv/interactive/program/list'
  11. const response = await fetch(apiUrl, {
  12. method: 'POST',
  13. headers: { 'equipmentsource': 'WEB' },
  14. body: post
  15. })
  16. const data = await response.json()
  17. const playurl = logo ? data.broadcastLiveImg :
  18. (data.broadcastPlayUrlHighMp3?.includes('m3u8') ? data.broadcastPlayUrlHighMp3 :
  19. data.playUrlHigh || 'https://live.fanmingming.com/assets/nosignal.mp3')
  20. return Response.redirect(playurl, 302)
  21. }