xiaozhitiao_open.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import { load, _ } from 'assets://js/lib/cat.js';
  2. import { log } from './lib/utils.js';
  3. import { initAli, detailContent, playContent } from './lib/ali.js';
  4. let siteKey = 'xiaozhitiao';
  5. let siteType = 0;
  6. let siteUrl = 'https://gitcafe.net/tool/alipaper/';
  7. let aliUrl = "https://www.aliyundrive.com/s/";
  8. let token = '';
  9. let date = new Date();
  10. const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
  11. async function request(reqUrl, data) {
  12. let res = await req(reqUrl, {
  13. method: 'post',
  14. headers: {
  15. 'User-Agent': UA,
  16. },
  17. data: data,
  18. postType: 'form',
  19. });
  20. return res.content;
  21. }
  22. // cfg = {skey: siteKey, ext: extend}
  23. async function init(cfg) {
  24. try {
  25. siteKey = _.isEmpty(cfg.skey) ? '' : cfg.skey;
  26. siteType = _.isEmpty(cfg.stype) ? '' : cfg.stype;
  27. await initAli(cfg.ext);
  28. } catch (e) {
  29. await log('init:' + e.message + ' line:' + e.lineNumber);
  30. }
  31. }
  32. async function home(filter) {
  33. const classes = [{'type_id':'1','type_name':'电视'},{'type_id':'2','type_name':'电影'},{'type_id':'3','type_name':'动漫'},{'type_id':'4','type_name':'视频'},{'type_id':'5','type_name':'音乐'}];
  34. const filterObj = {
  35. '1':[{'key':'class','name':'类型','init':'hyds','value':[{'n':'华语','v':'hyds'},{'n':'日韩','v':'rhds'},{'n':'欧美','v':'omds'},{'n':'其他','v':'qtds'}]}],
  36. '2':[{'key':'class','name':'类型','init':'hydy','value':[{'n':'华语','v':'hydy'},{'n':'日韩','v':'rhdy'},{'n':'欧美','v':'omdy'},{'n':'其他','v':'qtdy'}]}],
  37. '3':[{'key':'class','name':'类型','init':'hydm','value':[{'n':'国漫','v':'hydm'},{'n':'日本','v':'rhdm'},{'n':'欧美','v':'omdm'}]}],
  38. '4':[{'key':'class','name':'类型','init':'jlp','value':[{'n':'纪录','v':'jlp'},{'n':'综艺','v':'zyp'},{'n':'教育','v':'jypx'},{'n':'其他','v':'qtsp'}]}],
  39. '5':[{'key':'class','name':'类型','init':'hyyy','value':[{'n':'华语','v':'hyyy'},{'n':'日韩','v':'rhyy'},{'n':'欧美','v':'omyy'},{'n':'其他','v':'qtyy'}]}],
  40. };
  41. return {
  42. class: classes,
  43. filters: filterObj,
  44. };
  45. }
  46. async function homeVod() {}
  47. async function category(tid, pg, filter, extend) {
  48. if (pg <= 0) pg = 1;
  49. const params = {
  50. action: "viewcat",
  51. cat: extend.class,
  52. num: pg,
  53. token: await getToken(),
  54. };
  55. const resp = await request(siteUrl, params);
  56. const json = JSON.parse(resp);
  57. const videos = _.map(json.data, (item) => {
  58. return {
  59. vod_id: aliUrl + item.alikey,
  60. vod_name: item.title,
  61. vod_pic: "https://i2.100024.xyz/2024/01/31/xp4o7o.webp",
  62. vod_remarks: item.creatime
  63. };
  64. });
  65. const pgCount = _.isEmpty(videos) ? pg : pg + 1;
  66. const limit = 50;
  67. return {
  68. page: pg,
  69. pagecount: pgCount,
  70. limit: limit,
  71. total: limit * pgCount,
  72. list: videos,
  73. };
  74. }
  75. async function detail(id) {
  76. try {
  77. return await detailContent(id);
  78. } catch (e) {
  79. await log('detail:' + e.message + ' line:' + e.lineNumber);
  80. }
  81. }
  82. async function play(flag, id, flags) {
  83. try {
  84. return await playContent(flag, id, flags);
  85. } catch (e) {
  86. await log('play:' + e.message + ' line:' + e.lineNumber);
  87. }
  88. }
  89. async function search(wd, quick, pg) {
  90. if (pg <= 0) pg = 1;
  91. const params = {
  92. action: "search",
  93. from: "web",
  94. keyword: wd,
  95. token: await getToken(),
  96. };
  97. const resp = await request(siteUrl, params);
  98. const json = JSON.parse(resp);
  99. const videos = _.map(json.data, (item) => {
  100. return {
  101. vod_id: aliUrl + item.alikey,
  102. vod_name: item.title,
  103. vod_pic: "https://i2.100024.xyz/2024/01/31/xp4o7o.webp",
  104. vod_remarks: item.creatime
  105. };
  106. });
  107. return {
  108. list: videos,
  109. };
  110. }
  111. async function getToken() {
  112. const newDate = new Date();
  113. if (_.isEmpty(token) || newDate > date) {
  114. const params = {
  115. action: "get_token",
  116. };
  117. const resp = await request(siteUrl, params);
  118. const json = JSON.parse(resp);
  119. if (json.success) {
  120. token = json.data;
  121. date = newDate;
  122. }
  123. }
  124. return token;
  125. }
  126. export function __jsEvalReturn() {
  127. return {
  128. init: init,
  129. home: home,
  130. homeVod: homeVod,
  131. category: category,
  132. detail: detail,
  133. play: play,
  134. search: search,
  135. };
  136. }