wogg.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import {load, _, Uri} from './lib/cat.js';
  2. import {log} from './lib/utils.js';
  3. import {initAli, detailContent, playContent} from './lib/ali.js';
  4. let siteKey = '';
  5. let siteType = 0;
  6. let siteUrl = 'https://wogg.xyz';
  7. let 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";
  8. let patternAli = /(https:\/\/www\.aliyundrive\.com\/s\/[^"]+)/
  9. // cfg = {skey: siteKey, ext: extend}
  10. async function init(cfg) {
  11. let ext = '';
  12. if (typeof cfg == 'object') {
  13. siteKey = cfg.skey;
  14. siteType = cfg.stype;
  15. ext = cfg.ext;
  16. } else {
  17. ext = cfg; //适配影视
  18. }
  19. await initAli(ext);
  20. }
  21. async function request(reqUrl, agentSp) {
  22. let header = {
  23. 'user-agent': agentSp || 'okhttp/3.12.0',
  24. };
  25. let uri = new Uri(reqUrl);
  26. let res = await req(uri.toString(), {
  27. headers: header,
  28. timeout: 10000
  29. });
  30. let content = res.content;
  31. return content;
  32. }
  33. function getHeader() {
  34. let header = {};
  35. header['User-Agent'] = UA;
  36. return header;
  37. }
  38. async function getString(url) {
  39. let res = await req(url, {
  40. headers: getHeader()
  41. });
  42. return res.content;
  43. }
  44. let classes = [{'type_id': 1, 'type_name' : '电影'},{'type_id': 20, 'type_name' : '电视剧'},{'type_id': 28, 'type_name' : '综艺'},{'type_id': 24, 'type_name' : '动漫'},{'type_id': 32, 'type_name' : '音乐'}];
  45. let filterObj = {};
  46. async function home(filter) {
  47. return JSON.stringify({
  48. class: classes,
  49. filters: filterObj,
  50. });
  51. }
  52. async function homeVod() {
  53. return '{}';
  54. }
  55. async function category(tid, pg, filter, extend) {
  56. let reqUrl = siteUrl + '/index.php/vodshow/'+tid+'--------'+pg+'---.html';
  57. let con = await request(reqUrl, UA);
  58. const $ = load(con);
  59. let items = $('.module:eq(0) > .module-list > .module-items > .module-item');
  60. let videos = [];
  61. for(var item of items) {
  62. let oneA = $(item).find('.module-item-cover .module-item-pic a').first();
  63. let href = oneA.attr('href');
  64. let name = oneA.attr('title');
  65. let oneImg = $(item).find('.module-item-cover .module-item-pic img').first();
  66. let pic = oneImg.attr('data-src');
  67. let remark = $(item).find('.module-item-text').first().text();
  68. videos.push({
  69. vod_id: href,
  70. vod_name: name,
  71. vod_pic: pic,
  72. vod_remarks: remark,
  73. });
  74. }
  75. const hasMore = $('#page > a:contains(下一页)').length > 0;
  76. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  77. return JSON.stringify({
  78. page: parseInt(pg),
  79. pagecount: pgCount,
  80. limit: 72,
  81. total: 72 * pgCount,
  82. list: videos,
  83. });
  84. }
  85. async function detail(id) {
  86. let preMatches = id.match(patternAli);
  87. if (!_.isEmpty(preMatches)) return await detailContent(preMatches[1]);
  88. let url = siteUrl + id;
  89. let aliUrl = await getString(url);
  90. let matches = aliUrl.match(patternAli);
  91. if (!_.isEmpty(matches)) return await detailContent(matches[1]);
  92. return '';
  93. }
  94. async function play(flag, id, flags) {
  95. return await playContent(flag, id, flags);
  96. }
  97. async function search(wd, quick) {
  98. await log('search---' + wd);
  99. let searchUrl = siteUrl + '/index.php/vodsearch/-------------.html?wd=' + wd;
  100. let html = await getString(searchUrl);
  101. let $ = load(html);
  102. let items = $('.module-search-item');
  103. let videos = [];
  104. for(var item of items) {
  105. let vodId = $(item).find(".video-serial")[0].attribs.href;
  106. let name = $(item).find(".video-serial")[0].attribs.title;
  107. let pic = $(item).find(".module-item-pic > img")[0].attribs['data-src'];
  108. let remark = '';
  109. videos.push({
  110. vod_id: vodId,
  111. vod_name: name,
  112. vod_pic: pic,
  113. vod_remarks: remark,
  114. });
  115. }
  116. return JSON.stringify({
  117. list: videos,
  118. });
  119. }
  120. export function __jsEvalReturn() {
  121. return {
  122. init: init,
  123. home: home,
  124. homeVod: homeVod,
  125. category: category,
  126. detail: detail,
  127. play: play,
  128. search: search,
  129. };
  130. }