drpy推荐.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. js:
  2. let d = [];
  3. // let douban_api_host = 'https://frodo.douban.com/api/v2';
  4. let douban_api_host = 'http://api.douban.com/api/v2';
  5. let miniapp_apikey = '0ac44ae016490db2204ce0a042db2916';
  6. // let miniapp_apikey = '054022eaeae0b00e0fc068c0c0a2102a';
  7. const count = 30;
  8. function miniapp_request(path, query){
  9. try {
  10. let url = douban_api_host + path;
  11. query.apikey = miniapp_apikey;
  12. fetch_params.headers = oheaders;
  13. url = buildUrl(url,query);
  14. let html = fetch(url,fetch_params);
  15. return JSON.parse(html);
  16. }
  17. catch(e){
  18. print('发生了错误:'+e.message);
  19. return {}
  20. }
  21. }
  22. function subject_real_time_hotest(){
  23. try{
  24. let res = miniapp_request("/subject_collection/subject_real_time_hotest/items", {});
  25. let lists = [];
  26. let arr = res.subject_collection_items||[];
  27. arr.forEach(function (item){
  28. if(item.type==='movie'||item.type==='tv'){
  29. let rating = item.rating?item.rating.value:"暂无评分";
  30. let honnor = (item.honor_infos||[]).map(function (it){return it.title}).join('|');
  31. lists.append({
  32. "vod_id": "msearch:"+TYPE,
  33. // "vod_id": TYPE+"$1",
  34. "vod_name": item.title||"",
  35. "vod_pic": item.pic.normal,
  36. "vod_remarks": rating + " " + honnor
  37. })
  38. }
  39. });
  40. return lists
  41. }catch (e) {
  42. print('发生了错误:'+e.message);
  43. return []
  44. }
  45. }
  46. VODS = subject_real_time_hotest();
  47. print(VODS);