changzhang_open.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. import { Crypto, load, _ } from 'assets://js/lib/cat.js';
  2. /**
  3. * 厂长资源 发布页:https://cz01.vip/
  4. * author:Leospring
  5. * 公众号:蹲街捏蚂蚁
  6. *
  7. */
  8. var charStr = 'abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789';
  9. let COOKIE = 'PHPSESSID=' + randStr(26, true);
  10. let siteUrl = 'https://www.czys.pro/';
  11. let siteKey = '';
  12. let siteType = 0;
  13. COOKIE = 'PHPSESSID=gbk1aeo1ron2g5bcuasbrbe0a7; cf_clearance=rfmFuox8XopyxGkTd66IrfiBPYPOLQ5nWyY5J7ydhB8-1704875087-0-2-da940062.5bc4175f.8d955f82-150.0.0';
  14. let headers = {
  15. 'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 13_2_3 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Version/13.0 Mobile/13B14 Safari/537.36',
  16. 'Referer': siteUrl + '/',
  17. 'Cookie': COOKIE
  18. };
  19. async function request(reqUrl, postData, post) {
  20. let res = await req(reqUrl, {
  21. method: post ? 'post' : 'get',
  22. headers: headers,
  23. data: postData || {},
  24. postType: post ? 'form' : '',
  25. });
  26. let content = res.content;
  27. return content;
  28. }
  29. async function init(cfg) {
  30. siteKey = cfg.skey;
  31. siteType = cfg.stype;
  32. if (cfg.ext) {
  33. siteUrl = cfg.ext;
  34. }
  35. }
  36. async function home(filter) {
  37. let classes = [{
  38. type_id: 'dbtop250',
  39. type_name: '豆瓣电影Top250',
  40. },{
  41. type_id: 'zuixindianying',
  42. type_name: '最新电影',
  43. },{
  44. type_id: 'benyueremen',
  45. type_name: '热映中',
  46. },{
  47. type_id: 'gcj',
  48. type_name: '国产剧',
  49. },{
  50. type_id: 'meijutt',
  51. type_name: '美剧',
  52. },{
  53. type_id: 'hanjutv',
  54. type_name: '韩剧',
  55. },{
  56. type_id: 'fanju',
  57. type_name: '番剧',
  58. },{
  59. type_id: 'dongmanjuchangban',
  60. type_name: '动漫',
  61. }];
  62. return JSON.stringify({
  63. class: classes,
  64. // filters: filterObj
  65. });
  66. }
  67. async function homeVod() {
  68. let url = siteUrl;
  69. let videos = await getVideos(url);
  70. return JSON.stringify({
  71. list: videos,
  72. });
  73. }
  74. async function category(tid, pg, filter, ext) {
  75. if (!pg) pg = 1;
  76. if (pg <= 0) pg = 1;
  77. let url = siteUrl + '/' + tid;
  78. if (pg > 1) url += '/page/' + pg;
  79. let videos = await getVideos(url);
  80. return JSON.stringify({
  81. list: videos,
  82. page: pg,
  83. });
  84. }
  85. async function detail(id) {
  86. try {
  87. const html = await request(id);
  88. let $ = load(html);
  89. let content = $('div.yp_context > p:nth-child(1)').text();
  90. let type = _.map($('ul.moviedteail_list > li:nth-child(1) > a'), (n) => {
  91. return $(n).text();
  92. }).join(' ');
  93. let area = $('ul.moviedteail_list > li:nth-child(2) > a').text();
  94. let year = $('ul.moviedteail_list > li:nth-child(3) > a').text();
  95. let director = _.map($('ul.moviedteail_list > li:nth-child(6) > span'), (n) => {
  96. return $(n).text();
  97. }).join(' ');
  98. let actor = _.map($('ul.moviedteail_list > li:nth-child(8) > span'), (n) => {
  99. return $(n).text();
  100. }).join(' ');
  101. let playUrls = _.map($('div.paly_list_btn > a'), (n) => {
  102. return $(n).text() + '$' + $(n).attr('href');
  103. }).join('#');
  104. const video = {
  105. vod_play_from: 'Leospring',
  106. vod_play_url: playUrls,
  107. vod_content: content,
  108. vod_director: director,
  109. vod_actor: actor,
  110. vod_type: type,
  111. vod_area: area,
  112. vod_year: year,
  113. };
  114. const list = [video];
  115. const result = { list };
  116. return JSON.stringify(result);
  117. } catch (e) {
  118. console.log('err', e);
  119. }
  120. return null;
  121. }
  122. async function search(wd, quick, pg) {
  123. let url = siteUrl + '/xssearch?q=' + wd;
  124. const html = await request(url);
  125. if(html.indexOf('人机验证') > 0) {
  126. const regex = /(\d+\s*\+\s*\d+)/;
  127. const match = html.match(regex);
  128. //console.log('match', match);
  129. if(match) {
  130. let result = eval(match[1]);
  131. headers['Referer'] = siteUrl;
  132. const res = await req(url, {
  133. method: 'post',
  134. headers: headers,
  135. data: {'result': result},
  136. postType: 'form',
  137. });
  138. const $ = load(res.content);
  139. const cards = $('div.bt_img.mi_ne_kd> ul > li > a')
  140. let videos = _.map(cards, (n) => {
  141. let id = $(n).attr('href');
  142. let name = $($(n).find('img')[0]).attr('alt');
  143. let pic = $($(n).find('img')[0]).attr('data-original');
  144. let remarks = $($(n).find('div.jidi > span')[0]).text().trim();
  145. return {
  146. vod_id: id,
  147. vod_name: name,
  148. vod_pic: pic,
  149. vod_remarks: remarks,
  150. };
  151. });
  152. return JSON.stringify({
  153. list: videos,
  154. });
  155. }
  156. }
  157. //console.log('html', html);
  158. //TODO验证码处理
  159. let videos = await getVideos(url);
  160. return JSON.stringify({
  161. list: videos,
  162. });
  163. }
  164. async function play(flag, id, flags) {
  165. let playUrl = id;
  166. const html = await request(playUrl);
  167. const $ = load(html);
  168. const iframe = $('div.videoplay > iframe');
  169. if (iframe.length > 0) {
  170. const iframeHtml = (
  171. await req(iframe[0].attribs.src, {
  172. headers: headers,
  173. })
  174. ).content;
  175. //console.log('iframe', iframeHtml);
  176. let code = iframeHtml.split('"data":"')[1].split('"')[0]
  177. .split('')
  178. .reverse()
  179. .join('');
  180. let temp = '';
  181. for (let i = 0x0; i < code.length; i = i + 0x2) {
  182. temp += String.fromCharCode(parseInt(code[i] + code[i + 0x1], 0x10));
  183. }
  184. const playUrl = temp.substring(0x0, (temp.length - 0x7) / 0x2) + temp.substring((temp.length - 0x7) / 0x2 + 0x7);
  185. return JSON.stringify({
  186. parse: 0,
  187. url: playUrl,
  188. });
  189. }
  190. for(const n of $('script')) {
  191. if($(n).text().indexOf("md5.enc.Utf8") >= 0) {
  192. let encryptData = $(n).text().split("\n")[4];
  193. let strArr = encryptData.split('"');
  194. let data = strArr[1];
  195. let keyStr = strArr[3];
  196. let ivStr = '1234567890983456';
  197. // console.log('data', data);
  198. let res = aesDecode(data, keyStr, ivStr);
  199. //console.log('res', res);
  200. let url = res.split('url: "')[1].split('"')[0];
  201. if(url) {
  202. playUrl = url;
  203. }
  204. return JSON.stringify({
  205. parse: 0,
  206. url: playUrl,
  207. });
  208. }
  209. }
  210. return JSON.stringify({
  211. parse: 1,
  212. url: playUrl,
  213. });
  214. }
  215. //aes解密
  216. function aesDecode(str, keyStr, ivStr) {
  217. const key = Crypto.enc.Utf8.parse(keyStr);
  218. var bytes = Crypto.AES.decrypt(str, key, {
  219. iv: Crypto.enc.Utf8.parse(ivStr),
  220. mode: Crypto.mode.CBC,
  221. padding: Crypto.pad.Pkcs7
  222. });
  223. return bytes.toString(Crypto.enc.Utf8);
  224. }
  225. async function getVideos(url) {
  226. const html = await request(url);
  227. const $ = load(html);
  228. const cards = $('div.bt_img.mi_ne_kd> ul > li > a')
  229. let videos = _.map(cards, (n) => {
  230. let id = $(n).attr('href');
  231. let name = $($(n).find('img')[0]).attr('alt');
  232. let pic = $($(n).find('img')[0]).attr('data-original');
  233. let remarks = $($(n).find('div.jidi > span')[0]).text().trim();
  234. return {
  235. vod_id: id,
  236. vod_name: name,
  237. vod_pic: pic,
  238. vod_remarks: remarks,
  239. };
  240. });
  241. return videos;
  242. }
  243. function randStr(len, withNum) {
  244. var _str = '';
  245. let containsNum = withNum === undefined ? true : withNum;
  246. for (var i = 0; i < len; i++) {
  247. let idx = _.random(0, containsNum ? charStr.length - 1 : charStr.length - 11);
  248. _str += charStr[idx];
  249. }
  250. return _str;
  251. }
  252. export function __jsEvalReturn() {
  253. return {
  254. init: init,
  255. home: home,
  256. homeVod: homeVod,
  257. category: category,
  258. detail: detail,
  259. play: play,
  260. search: search,
  261. };
  262. }