哔哩推荐.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. js:
  2. let d = [];
  3. function get_result(url){
  4. let videos = [];
  5. let html = request(url);
  6. let jo = JSON.parse(html);
  7. if(jo['code'] === 0){
  8. let vodList = jo.result?jo.result.list:jo.data.list;
  9. vodList.forEach(function (vod){
  10. let aid = (vod['season_id']+'').trim();
  11. let title = vod['title'].trim();
  12. let img = vod['cover'].trim();
  13. let remark = vod.new_ep?vod['new_ep']['index_show']:vod['index_show'];
  14. videos.push({
  15. "vod_id": aid,
  16. "vod_name": title,
  17. "vod_pic": img,
  18. "vod_remarks": remark
  19. });
  20. });
  21. }
  22. return videos;
  23. }
  24. function get_rank(tid,pg){
  25. return get_result('https://api.bilibili.com/pgc/web/rank/list?season_type='+tid+'&pagesize=20&page='+pg+'&day=3')
  26. }
  27. function get_rank2(tid,pg){
  28. return get_result('https://api.bilibili.com/pgc/season/rank/web/list?season_type='+tid+'&pagesize=20&page='+pg+'&day=3')
  29. }
  30. function home_video(){
  31. let videos = get_rank(1).slice(0,5);
  32. [4, 2, 5, 3, 7].forEach(function (i){
  33. videos = videos.concat(get_rank2(i).slice(0,5))
  34. });
  35. return videos;
  36. }
  37. VODS = home_video();