czzy_open.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. // 自动从 地址发布页 获取&跳转url地址
  2. import { Crypto, load, _ } from 'assets://js/lib/cat.js';
  3. let key = 'czzy';
  4. let host = 'https://cz01.vip/'; // 厂长地址发布页
  5. let url = '';
  6. let siteKey = '';
  7. let siteType = 0;
  8. 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';
  9. const cookie = {};
  10. async function request(reqUrl, referer, mth, data, hd) {
  11. const headers = {
  12. 'User-Agent': UA,
  13. Cookie: _.map(cookie, (value, key) => {
  14. return `${key}=${value}`;
  15. }).join(';'),
  16. };
  17. if (referer) headers.referer = encodeURIComponent(referer);
  18. let res = await req(reqUrl, {
  19. method: mth || 'get',
  20. headers: headers,
  21. data: data,
  22. postType: mth === 'post' ? 'form' : '',
  23. });
  24. if (res.headers['set-cookie']) {
  25. const set_cookie = _.isArray(res.headers['set-cookie']) ? res.headers['set-cookie'].join(';') : res.headers['set-cookie'];
  26. const cks = set_cookie.split(';');
  27. for (const c of cks) {
  28. const tmp = c.trim();
  29. if (tmp.startsWith('result=')) {
  30. cookie.result = tmp.substring(7);
  31. return await request(reqUrl, reqUrl, 'post', {
  32. result: cookie.result,
  33. });
  34. } else if (tmp.startsWith('esc_search_captcha=1')) {
  35. cookie.esc_search_captcha = 1;
  36. delete cookie.result;
  37. return await request(reqUrl);
  38. }
  39. }
  40. // console.log(res.headers['set-cookie']);
  41. }
  42. return res.content;
  43. }
  44. // cfg = {skey: siteKey, ext: extend}
  45. async function init(cfg) {
  46. siteKey = cfg.skey;
  47. siteType = cfg.stype;
  48. url = await checkValidUrl(cfg.ext);
  49. console.debug('厂长跳转地址 =====>' + url); // js_debug.log
  50. }
  51. async function checkValidUrl(ext) {
  52. let validUrl = ext;
  53. if (_.isEmpty(ext)) {
  54. let html = await request(host);
  55. let matches = html.matchAll(/推荐访问<a href="(.*)"/g);
  56. for (let match of matches) {
  57. try {
  58. let rcmdUrl = match[1];
  59. let res = await req(rcmdUrl, {
  60. method: 'get',
  61. headers: {
  62. 'User-Agent': UA,
  63. },
  64. redirect: 0,
  65. });
  66. let location = res.headers['location'];
  67. if (!_.isEmpty(location)) {
  68. validUrl = location;
  69. } else {
  70. validUrl = rcmdUrl;
  71. break;
  72. }
  73. } catch(e) {
  74. }
  75. }
  76. }
  77. return validUrl;
  78. }
  79. async function home(filter) {
  80. let filterObj = {};
  81. const html = await request(url + '/movie_bt');
  82. const $ = load(html);
  83. const tags = $('div#beautiful-taxonomy-filters-tax-movie_bt_tags > a');
  84. let tag = {
  85. key: 'tag',
  86. name: '类型',
  87. value: _.map(tags, (n) => {
  88. let v = n.attribs['cat-url'] || '';
  89. v = v.substring(v.lastIndexOf('/') + 1);
  90. return { n: n.children[0].data, v: v };
  91. }),
  92. };
  93. tag['init'] = tag.value[0].v;
  94. const series = $('div#beautiful-taxonomy-filters-tax-movie_bt_series > a[cat-url*=movie_bt_series]');
  95. let classes = _.map(series, (s) => {
  96. let typeId = s.attribs['cat-url'];
  97. typeId = typeId.substring(typeId.lastIndexOf('/') + 1);
  98. filterObj[typeId] = [tag];
  99. return {
  100. type_id: typeId,
  101. type_name: s.children[0].data,
  102. };
  103. });
  104. const sortName = ['电影', '电视剧', '国产剧', '美剧', '韩剧', '日剧', '海外剧(其他)', '华语电影', '印度电影', '日本电影', '欧美电影', '韩国电影', '动画', '俄罗斯电影', '加拿大电影'];
  105. classes = _.sortBy(classes, (c) => {
  106. const index = sortName.indexOf(c.type_name);
  107. return index === -1 ? sortName.length : index;
  108. });
  109. return JSON.stringify({
  110. class: classes,
  111. filters: filterObj,
  112. });
  113. }
  114. async function homeVod() {
  115. return '{}';
  116. }
  117. async function category(tid, pg, filter, extend) {
  118. if (pg <= 0) pg = 1;
  119. const tag = extend.tag || '';
  120. const link = url + '/movie_bt' + (tag.length > 0 ? `/movie_bt_tags/${tag}` : '') + '/movie_bt_series/' + tid + (pg > 1 ? `/page/${pg}` : '');
  121. const html = await request(link);
  122. const $ = load(html);
  123. const items = $('div.mrb > ul > li');
  124. let videos = _.map(items, (item) => {
  125. const img = $(item).find('img:first')[0];
  126. const a = $(item).find('a:first')[0];
  127. const hdinfo = $($(item).find('div.hdinfo')[0]).text().trim();
  128. const jidi = $($(item).find('div.jidi')[0]).text().trim();
  129. return {
  130. vod_id: a.attribs.href.replace(/.*?\/movie\/(.*).html/g, '$1'),
  131. vod_name: img.attribs.alt,
  132. vod_pic: img.attribs['data-original'],
  133. vod_remarks: jidi || hdinfo || '',
  134. };
  135. });
  136. const hasMore = $('div.mrb > div.pagenavi_txt > a:contains(>)').length > 0;
  137. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  138. return JSON.stringify({
  139. page: parseInt(pg),
  140. pagecount: pgCount,
  141. limit: 20,
  142. total: 20 * pgCount,
  143. list: videos,
  144. });
  145. }
  146. function stripHtmlTag(src) {
  147. return src
  148. .replace(/<\/?[^>]+(>|$)/g, '')
  149. .replace(/&.{1,5};/g, '')
  150. .replace(/\s{2,}/g, ' ');
  151. }
  152. async function detail(id) {
  153. const html = await request(url + '/movie/' + id + '.html');
  154. const $ = load(html);
  155. const detail = $('ul.moviedteail_list > li');
  156. let vod = {
  157. vod_id: id,
  158. vod_pic: $('div.dyimg img:first').attr('src'),
  159. vod_remarks: '',
  160. vod_content: stripHtmlTag($('div.yp_context').html()).trim(),
  161. };
  162. for (const info of detail) {
  163. const i = $(info).text().trim();
  164. if (i.startsWith('地区:')) {
  165. vod.vod_area = i.substring(3);
  166. } else if (i.startsWith('年份:')) {
  167. vod.vod_year = i.substring(3);
  168. } else if (i.startsWith('导演:')) {
  169. vod.vod_director = _.map($(info).find('a'), (a) => {
  170. return a.children[0].data;
  171. }).join('/');
  172. } else if (i.startsWith('主演:')) {
  173. vod.vod_actor = _.map($(info).find('a'), (a) => {
  174. return a.children[0].data;
  175. }).join('/');
  176. } else if (i.startsWith('语言:')) {
  177. vod.vod_lang = i.substring(3);
  178. }
  179. }
  180. const playlist = _.map($('div.paly_list_btn > a'), (a) => {
  181. return a.children[0].data + '$' + a.attribs.href.replace(/.*?\/v_play\/(.*).html/g, '$1');
  182. });
  183. vod.vod_play_from = key;
  184. vod.vod_play_url = playlist.join('#');
  185. return JSON.stringify({
  186. list: [vod],
  187. });
  188. }
  189. async function play(flag, id, flags) {
  190. const link = url + '/v_play/' + id + '.html';
  191. const html = await request(link);
  192. const $ = load(html);
  193. const iframe = $('body iframe[src*=Cloud]');
  194. if (iframe.length > 0) {
  195. const iframeHtml = (
  196. await req(iframe[0].attribs.src, {
  197. headers: {
  198. Referer: link,
  199. 'User-Agent': UA,
  200. },
  201. })
  202. ).content;
  203. let code = iframeHtml
  204. .match(/var url = '(.*?)'/)[1]
  205. .split('')
  206. .reverse()
  207. .join('');
  208. let temp = '';
  209. for (let i = 0x0; i < code.length; i = i + 0x2) {
  210. temp += String.fromCharCode(parseInt(code[i] + code[i + 0x1], 0x10));
  211. }
  212. const playUrl = temp.substring(0x0, (temp.length - 0x7) / 0x2) + temp.substring((temp.length - 0x7) / 0x2 + 0x7);
  213. return JSON.stringify({
  214. parse: 0,
  215. url: playUrl,
  216. });
  217. } else {
  218. const js = $('script:contains(window.wp_nonce)').html();
  219. const group = js.match(/(var.*)eval\((\w*\(\w*\))\)/);
  220. const md5 = Crypto;
  221. const result = eval(group[1] + group[2]);
  222. const playUrl = result.match(/url:.*?['"](.*?)['"]/)[1];
  223. return JSON.stringify({
  224. parse: 0,
  225. url: playUrl,
  226. });
  227. }
  228. }
  229. async function search(wd, quick) {
  230. const html = await request(url + '/?s=' + wd);
  231. const $ = load(html);
  232. const items = $('div.search_list > ul > li');
  233. let videos = _.map(items, (item) => {
  234. const img = $(item).find('img:first')[0];
  235. const a = $(item).find('a:first')[0];
  236. const hdinfo = $($(item).find('div.hdinfo')[0]).text().trim();
  237. const jidi = $($(item).find('div.jidi')[0]).text().trim();
  238. return {
  239. vod_id: a.attribs.href.replace(/.*?\/movie\/(.*).html/g, '$1'),
  240. vod_name: img.attribs.alt,
  241. vod_pic: img.attribs['data-original'],
  242. vod_remarks: jidi || hdinfo || '',
  243. };
  244. });
  245. return JSON.stringify({
  246. list: videos,
  247. });
  248. }
  249. export function __jsEvalReturn() {
  250. return {
  251. init: init,
  252. home: home,
  253. homeVod: homeVod,
  254. category: category,
  255. detail: detail,
  256. play: play,
  257. search: search,
  258. };
  259. }