jojo_open.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. import { Crypto, load, _, dayjs } from 'assets://js/lib/cat.js';
  2. let key = 'jiohub';
  3. let url = 'https://jiohub.top';
  4. let siteKey = '';
  5. let siteType = 0;
  6. 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';
  7. const cookie = {};
  8. async function request(reqUrl, referer, mth, data, hd) {
  9. const headers = {
  10. 'User-Agent': UA,
  11. Cookie: _.map(cookie, (value, key) => {
  12. return `${key}=${value}`;
  13. }).join(';'),
  14. };
  15. if (referer) headers.referer = encodeURIComponent(referer);
  16. let res = await req(reqUrl, {
  17. method: mth || 'get',
  18. headers: headers,
  19. data: data,
  20. postType: mth === 'post' ? 'form' : '',
  21. });
  22. return res.content;
  23. }
  24. // cfg = {skey: siteKey, ext: extend}
  25. async function init(cfg) {
  26. siteKey = cfg.skey;
  27. siteType = cfg.stype;
  28. }
  29. async function home(filter) {
  30. const html = await request(url);
  31. const $ = load(html);
  32. const series = $('.nav-list a[href*=/video]');
  33. let classes = _.map(series, (s) => {
  34. let typeId = s.attribs['href'];
  35. let typeName = typeId.match(/\/video\/(.*)\?/)[1];
  36. typeName = decodeURIComponent(typeName);
  37. return {
  38. type_id: typeName,
  39. type_name: typeName,
  40. };
  41. });
  42. return JSON.stringify({
  43. class: classes,
  44. });
  45. }
  46. async function homeVod() {
  47. return '{}';
  48. }
  49. async function category(tid, pg, filter, extend) {
  50. let page = pg || 1;
  51. if (page == 0) page = 1;
  52. const link = url + '/video/' + tid + "?page=" + page + '&size=18';
  53. const html = await request(link);
  54. const $ = load(html);
  55. const items = $('div.content-body > a');
  56. let videos = _.map(items, (item) => {
  57. const img = $(item).find('img:first')[0].attribs['src'];
  58. const a = item.attribs['href'].match(/\/watch\/(.*)/)[1];
  59. const n = ($(item).find('p.card-title')[0]).children[0].data;
  60. let speed = ($(item).find('p.item-speed')[0]).children[0].data || '';
  61. const score = ($(item).find('p.score')[0]).children[0].data || '';
  62. if (speed == tid) speed = '';
  63. return {
  64. vod_id: a,
  65. vod_name: n,
  66. vod_pic: img,
  67. vod_remarks: speed || score || '',
  68. };
  69. });
  70. let total = 18;
  71. const pag = $('ui-pagination');
  72. if (pag.length > 0) {
  73. try {
  74. total = parseInt(pag[0].attribs['total']);
  75. } catch (error) {
  76. }
  77. }
  78. return JSON.stringify({
  79. page: page,
  80. pagecount: _.ceil(total / 18),
  81. list: videos,
  82. });
  83. }
  84. function stripHtmlTag(src) {
  85. return src
  86. .replace(/<\/?[^>]+(>|$)/g, '')
  87. .replace(/&.{1,5};/g, '')
  88. .replace(/\s{2,}/g, ' ');
  89. }
  90. async function detail(id) {
  91. const html = await request(url + '/watch/' + id);
  92. const $ = load(html);
  93. const detail = $('div.content-detail > p');
  94. let vod = {
  95. vod_id: id,
  96. vod_content: stripHtmlTag($('div.content-detail span.detail-sketch').html()).trim(),
  97. };
  98. for (const info of detail) {
  99. const i = $(info).text().trim();
  100. if (i.startsWith('地区:')) {
  101. vod.vod_area = i.substring(3);
  102. } else if (i.startsWith('年份:')) {
  103. vod.vod_year = i.substring(3);
  104. } else if (i.startsWith('类型:')) {
  105. vod.vod_type = i.substring(3);
  106. } else if (i.startsWith('导演:')) {
  107. vod.vod_director = i.substring(3);
  108. } else if (i.startsWith('主演:')) {
  109. vod.vod_actor = i.substring(3);
  110. } else if (i.startsWith('语言:')) {
  111. vod.vod_lang = i.substring(3);
  112. }
  113. }
  114. const urls = html.match(/let urls = \"(.*)\";/)[1].replace(/_/g, '/').replace(/-/g, '+');
  115. var key = Crypto.enc.Utf8.parse("cf2d1a-6a4d-9ef8");
  116. var playlist = Crypto.AES.decrypt(urls, key, { iv: key, padding: Crypto.pad.Pkcs7 });
  117. playlist = Crypto.enc.Utf8.stringify(playlist).split('\n');
  118. vod.vod_play_from = 'JOJO';
  119. vod.vod_play_url = playlist.join('#');
  120. return JSON.stringify({
  121. list: [vod],
  122. });
  123. }
  124. function playPid() {
  125. var key = Crypto.enc.Utf8.parse('VSmJTRRE'+dayjs().format('YYYYMMDD'));
  126. var iv = Crypto.enc.Hex.parse("00000000000000000000000000000000");
  127. var pid = Crypto.AES.encrypt(dayjs().format('YYYY-MM-DD HH:mm'), key, { iv: iv, padding: Crypto.pad.Pkcs7 });
  128. pid = pid.toString().replace(/\+/g, '-');
  129. return pid;
  130. }
  131. async function play(flag, id, flags) {
  132. return JSON.stringify({
  133. parse: 0,
  134. url: id + '?pid=' + playPid(),
  135. header: {
  136. 'User-Agent': UA,
  137. },
  138. });
  139. }
  140. async function search(wd, quick, pg) {
  141. let page = pg || 1;
  142. if (page == 0) page = 1;
  143. const link = url + '/video/search?q=' + wd + "&page=" + page + '&size=18&pid=' + playPid();
  144. const html = await request(link);
  145. const $ = load(html);
  146. const items = $('div.content-body > a');
  147. let videos = _.map(items, (item) => {
  148. const img = $(item).find('img:first')[0].attribs['src'];
  149. const a = item.attribs['href'].match(/\/watch\/(.*)/)[1];
  150. const n = ($(item).find('p.card-title')[0]).children[0].data;
  151. let speed = ($(item).find('p.item-speed')[0]).children[0].data || '';
  152. const score = ($(item).find('p.score')[0]).children[0].data || '';
  153. if (speed == '电影') speed = '';
  154. return {
  155. vod_id: a,
  156. vod_name: n,
  157. vod_pic: img,
  158. vod_remarks: speed || score || '',
  159. };
  160. });
  161. let total = 18;
  162. const pag = $('ui-pagination');
  163. if (pag.length > 0) {
  164. try {
  165. total = parseInt(pag[0].attribs['total']);
  166. } catch (error) {
  167. }
  168. }
  169. return JSON.stringify({
  170. page: page,
  171. pagecount: _.ceil(total / 18),
  172. list: videos,
  173. });
  174. }
  175. export function __jsEvalReturn() {
  176. return {
  177. init: init,
  178. home: home,
  179. homeVod: homeVod,
  180. category: category,
  181. detail: detail,
  182. play: play,
  183. search: search,
  184. };
  185. }