yiso_open.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import { Crypto, _ } 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 = 'yiso';
  5. let siteType = 0;
  6. let siteUrl = 'https://yiso.fun';
  7. let patternAli = /(https:\/\/www\.(aliyundrive|alipan)\.com\/s\/[^"]+)/;
  8. let cookie = '';
  9. 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';
  10. async function request(reqUrl) {
  11. let res = await req(reqUrl, {
  12. method: 'get',
  13. headers: {
  14. 'User-Agent': UA,
  15. 'Referer': siteUrl,
  16. 'Cookie': cookie,
  17. },
  18. });
  19. return res.content;
  20. }
  21. // cfg = {skey: siteKey, ext: extend}
  22. async function init(cfg) {
  23. try {
  24. siteKey = _.isEmpty(cfg.skey) ? '' : cfg.skey;
  25. siteType = _.isEmpty(cfg.stype) ? '' : cfg.stype;
  26. const ext = _.isEmpty(cfg.ext) ? '' : cfg.ext;
  27. const configs = ext.split('$$$');
  28. if (configs.length == 2) {
  29. cookie = configs[1];
  30. }
  31. const token = {
  32. ext: configs[0]
  33. };
  34. await initAli(token);
  35. } catch (e) {
  36. await log('init:' + e.message + ' line:' + e.lineNumber);
  37. }
  38. }
  39. async function home(filter) {
  40. return '{}';
  41. }
  42. async function homeVod() {}
  43. async function category(tid, pg, filter, extend) {
  44. return '{}';
  45. }
  46. async function detail(id) {
  47. try {
  48. let matches = id.match(patternAli);
  49. if (!_.isEmpty(matches)) return await detailContent(matches[0]);
  50. return '';
  51. } catch (e) {
  52. await log('detail:' + e.message + ' line:' + e.lineNumber);
  53. }
  54. }
  55. async function play(flag, id, flags) {
  56. try {
  57. return await playContent(flag, id, flags);
  58. } catch (e) {
  59. await log('play:' + e.message + ' line:' + e.lineNumber);
  60. }
  61. }
  62. async function search(wd, quick, pg) {
  63. if (pg <= 0) pg = 1;
  64. const limit = 10;
  65. const resp = await request(siteUrl + "/api/search?name=" + encodeURIComponent(wd) + '&pageNo=' + pg + '&from=ali');
  66. const json = JSON.parse(resp).data;
  67. const total = json.total;
  68. const videos = _.map(json.list, (item) => {
  69. const name = item.fileInfos[0].fileName;
  70. const remark = item.gmtCreate;
  71. const url = decryptUrl(item.url);
  72. return {
  73. vod_id: url,
  74. vod_name: name,
  75. vod_pic: "https://inews.gtimg.com/newsapp_bt/0/13263837859/1000",
  76. vod_remarks: remark,
  77. };
  78. });
  79. const pgCount = parseInt(total / limit) + 1;
  80. return JSON.stringify({
  81. page: parseInt(pg),
  82. pagecount: pgCount,
  83. limit: limit,
  84. total: total,
  85. list: videos,
  86. });
  87. }
  88. function decryptUrl(url) {
  89. const data = {
  90. ciphertext: Crypto.enc.Base64.parse(url),
  91. };
  92. const key = Crypto.enc.Utf8.parse('4OToScUFOaeVTrHE');
  93. const iv = Crypto.enc.Utf8.parse('9CLGao1vHKqm17Oz');
  94. const mode = Crypto.mode.CBC;
  95. const padding = Crypto.pad.Pkcs7;
  96. const decrypted = Crypto.AES.decrypt(data, key, {
  97. 'iv': iv,
  98. 'mode': mode,
  99. 'padding': padding
  100. });
  101. const decryptedUrl = Crypto.enc.Utf8.stringify(decrypted);
  102. return decryptedUrl;
  103. }
  104. export function __jsEvalReturn() {
  105. return {
  106. init: init,
  107. home: home,
  108. homeVod: homeVod,
  109. category: category,
  110. detail: detail,
  111. play: play,
  112. search: search,
  113. };
  114. }