dovx_open.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { _ } 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 = 'dovx';
  5. let siteType = 0;
  6. let siteUrl = 'https://api.dovx.tk';
  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. let matches = id.match(patternAli);
  37. if (!_.isEmpty(matches)) return await detailContent(matches[0]);
  38. return '';
  39. } catch (e) {
  40. await log('detail:' + e.message + ' line:' + e.lineNumber);
  41. }
  42. }
  43. async function play(flag, id, flags) {
  44. try {
  45. return await playContent(flag, id, flags);
  46. } catch (e) {
  47. await log('play:' + e.message + ' line:' + e.lineNumber);
  48. }
  49. }
  50. async function search(wd, quick, pg) {
  51. let resp = await request(siteUrl + "/ali/search?wd=" + encodeURIComponent(wd));
  52. let videos = JSON.parse(resp).list;
  53. _.each(videos, (item) => {
  54. item.vod_id = item.vod_content;
  55. item.vod_content = undefined;
  56. });
  57. return JSON.stringify({
  58. list: videos,
  59. });
  60. }
  61. export function __jsEvalReturn() {
  62. return {
  63. init: init,
  64. home: home,
  65. homeVod: homeVod,
  66. category: category,
  67. detail: detail,
  68. play: play,
  69. search: search,
  70. };
  71. }