upyun_open.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 = 'upyun';
  5. let siteType = 0;
  6. let siteUrl = 'https://zyb.upyunso.com';
  7. let patternAli = /(https:\/\/www\.(aliyundrive|alipan)\.com\/s\/[^"]+)/
  8. async function request(reqUrl) {
  9. let res = await req(reqUrl, {
  10. method: 'get',
  11. headers: {
  12. 'Referer': siteUrl,
  13. },
  14. });
  15. return res.content;
  16. }
  17. // cfg = {skey: siteKey, ext: extend}
  18. async function init(cfg) {
  19. try {
  20. siteKey = _.isEmpty(cfg.skey) ? '' : cfg.skey;
  21. siteType = _.isEmpty(cfg.stype) ? '' : cfg.stype;
  22. await initAli(cfg);
  23. } catch (e) {
  24. await log('init:' + e.message + ' line:' + e.lineNumber);
  25. }
  26. }
  27. async function home(filter) {
  28. return '{}';
  29. }
  30. async function homeVod() {}
  31. async function category(tid, pg, filter, extend) {
  32. return '{}';
  33. }
  34. async function detail(id) {
  35. try {
  36. return await detailContent(id);
  37. } catch (e) {
  38. await log('detail:' + e.message + ' line:' + e.lineNumber);
  39. }
  40. }
  41. async function play(flag, id, flags) {
  42. try {
  43. return await playContent(flag, id, flags);
  44. } catch (e) {
  45. await log('play:' + e.message + ' line:' + e.lineNumber);
  46. }
  47. }
  48. async function search(wd, quick, pg) {
  49. if (pg <= 0) pg = 1;
  50. const limit = 25;
  51. const resp = await request(siteUrl + "/v15/search?keyword=" + encodeURIComponent(wd) + '&page=' + pg + '&s_type=2');
  52. const data = decrypt(resp);
  53. const items = JSON.parse(data).result.items;
  54. const videos = [];
  55. for(const item of items) {
  56. const url = decrypt(item.page_url);
  57. const matches = url.match(patternAli);
  58. if (_.isEmpty(matches)) continue;
  59. const title = _.isEmpty(item.content) ? item.title : item.content[0].title;
  60. videos.push({
  61. vod_id: url,
  62. vod_name: title.replaceAll(/<\/?[^>]+>/g, ""),
  63. vod_pic: "https://inews.gtimg.com/newsapp_bt/0/13263837859/1000",
  64. vod_remarks: item.insert_time,
  65. });
  66. }
  67. const hasMore = !_.isEmpty(items);
  68. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  69. return JSON.stringify({
  70. page: parseInt(pg),
  71. pagecount: pgCount,
  72. limit: limit,
  73. total: limit * pgCount,
  74. list: videos,
  75. });
  76. }
  77. function decrypt(text) {
  78. const data = {
  79. ciphertext: Crypto.enc.Hex.parse(text.toUpperCase()),
  80. };
  81. const key = Crypto.enc.Utf8.parse('qq1920520460qqzz');
  82. const iv = Crypto.enc.Utf8.parse('qq1920520460qqzz');
  83. const mode = Crypto.mode.CBC;
  84. const padding = Crypto.pad.Pkcs7;
  85. const decrypted = Crypto.AES.decrypt(data, key, {
  86. 'iv': iv,
  87. 'mode': mode,
  88. 'padding': padding
  89. });
  90. const decryptedData = Crypto.enc.Utf8.stringify(decrypted);
  91. return decryptedData;
  92. }
  93. export function __jsEvalReturn() {
  94. return {
  95. init: init,
  96. home: home,
  97. homeVod: homeVod,
  98. category: category,
  99. detail: detail,
  100. play: play,
  101. search: search,
  102. };
  103. }