wobg.js 4.5 KB

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