czzy_open.js 8.5 KB

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