changzhang.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /*
  2. * @File : changzhang.js
  3. * @Author : jade
  4. * @Date : 2024/2/2 16:02
  5. * @Email : jadehh@1ive.com
  6. * @Software : Samples
  7. * @Desc :
  8. */
  9. import {Spider} from "./spider.js";
  10. import {_, Crypto, load} from "../lib/cat.js";
  11. import {VodDetail, VodShort} from "../lib/vod.js";
  12. import * as Utils from "../lib/utils.js";
  13. import { aliName, detailContent,initCloud,playContent, quarkName } from "../lib/cloud.js";
  14. function cryptJs(text, key, iv, type) {
  15. let key_value = Crypto.enc.Utf8.parse(key || 'PBfAUnTdMjNDe6pL');
  16. let iv_value = Crypto.enc.Utf8.parse(iv || 'sENS6bVbwSfvnXrj');
  17. let content
  18. if (type) {
  19. content = Crypto.AES.encrypt(text, key_value, {
  20. iv: iv_value, mode: Crypto.mode.CBC, padding: Crypto.pad.Pkcs7
  21. })
  22. } else {
  23. content = Crypto.AES.decrypt(text, key_value, {
  24. iv: iv_value, padding: Crypto.pad.Pkcs7
  25. }).toString(Crypto.enc.Utf8)
  26. }
  27. return content
  28. }
  29. class ChangZhangSpider extends Spider {
  30. constructor() {
  31. super();
  32. this.siteUrl = "https://www.czys.top"
  33. }
  34. async init(cfg) {
  35. await super.init(cfg);
  36. await initCloud(this.cfgObj);
  37. }
  38. getName() {
  39. return "🏭️┃厂长直连┃🏭️"
  40. }
  41. getAppName() {
  42. return "厂长直连"
  43. }
  44. getJSName() {
  45. return "changzhang"
  46. }
  47. getType() {
  48. return 3
  49. }
  50. async getHtml(url = this.siteUrl, headers = this.getHeader()) {
  51. let response = await this.fetch(url, null, headers,false,true);
  52. let html = response["content"]
  53. if (!_.isEmpty(html) && html.indexOf("人机验证")===-1) {
  54. return load(html)
  55. } else {
  56. await this.jadeLog.error(`html获取失败`, true)
  57. }
  58. }
  59. getSearchHeader() {
  60. return {
  61. "Cookie": "cf_clearance=otYZbHg1safCIxkCtZfy9DPKbf1Gs_zUskkVDc0MVKM-1707026063-1-ATOpKnTLv9+pv171YE/rzxN/nmvGN9Mucx7vpwp0kW2vZb/cbtz5e2md2/ym7EE+9dT7pPBV+kQOg9vJx2v8cks=;myannoun=1;PHPSESSID=73386nobqugs7r3pb2ljcsp5q4",
  62. "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/100.0.4896.77 Mobile/15E148 Safari/604.1",
  63. "Connection":"keep-alive",
  64. "Host":"www.czzy55.com"
  65. }
  66. }
  67. parseVodShortFromElement($, element) {
  68. let vodShort = new VodShort()
  69. let imgElement = $($(element).find("a")).find("img")[0]
  70. vodShort.vod_name = imgElement.attribs.alt
  71. vodShort.vod_pic = imgElement.attribs["data-original"]
  72. vodShort.vod_remarks = $($($(element).find("[class='hdinfo']")).find("span")).text()
  73. vodShort.vod_id = $(element).find("a")[0].attribs.href
  74. return vodShort
  75. }
  76. async parseVodShortListFromDoc($) {
  77. let vod_list = []
  78. let aList = $($("[class=\"mi_cont\"]").find("ul")).find("li")
  79. for (const a of aList) {
  80. vod_list.push(this.parseVodShortFromElement($, a))
  81. }
  82. return vod_list
  83. }
  84. async parseVodShortListFromDocByCategory($) {
  85. let vod_list = []
  86. let aList = $($("[class=\"mi_cont \"]").find("ul")).find("li")
  87. for (const a of aList) {
  88. vod_list.push(this.parseVodShortFromElement($, a))
  89. }
  90. return vod_list
  91. }
  92. async parseVodDetailFromDoc($) {
  93. let vodDetail = new VodDetail()
  94. let nodeElement = $("[class='dyxingq']")
  95. vodDetail.vod_pic = $(nodeElement).find("img")[0].attribs.src
  96. vodDetail.vod_name = $($(nodeElement).find("h1")[0]).text()
  97. vodDetail.vod_content = $($($("[class='yp_context']")).find("p")).text()
  98. let infoArray = $(nodeElement).find("[class='moviedteail_list']").find("li")
  99. let x = $(infoArray).text()
  100. for (const info of infoArray) {
  101. let content = $(info).text()
  102. if (content.indexOf("类型") > -1) {
  103. vodDetail.type_name = content.replaceAll("类型", "").replaceAll(":", "")
  104. } else if (content.indexOf("年份") > -1) {
  105. vodDetail.vod_year = content.replaceAll("年份", "").replaceAll(":", "")
  106. } else if (content.indexOf("地区") > -1) {
  107. vodDetail.vod_area = content.replaceAll("地区", "").replaceAll(":", "")
  108. } else if (content.indexOf("豆瓣") > -1) {
  109. vodDetail.vod_remarks = content.replaceAll("豆瓣", "").replaceAll(":", "")
  110. } else if (content.indexOf("主演") > -1) {
  111. vodDetail.vod_actor = content.replaceAll("主演", "").replaceAll(":", "")
  112. } else if (content.indexOf("导演") > -1) {
  113. vodDetail.vod_director = content.replaceAll("导演", "").replaceAll(":", "")
  114. } else if (content.indexOf("剧情") > -1) {
  115. vodDetail.vod_content = content.replaceAll("剧情", "").replaceAll(":", "")
  116. }
  117. }
  118. let vod_play_from_list = ["厂长资源"]
  119. let vodPlayList = $("[class='paly_list_btn']")
  120. let vod_play_list = []
  121. for (const v1 of vodPlayList) {
  122. let vodItems = []
  123. let aList = $(v1).find("a")
  124. for (const tA of aList) {
  125. let episodeUrl = tA.attribs.href
  126. let episodeName = $(tA).text().replaceAll("立即播放  (", "").replaceAll(")", "")
  127. vodItems.push(episodeName + "$" + episodeUrl)
  128. }
  129. vod_play_list.push(vodItems.join("#"))
  130. }
  131. let valify_formt_list = ["磁力链接", aliName]
  132. let otherPlayList = $("[class=\"ypbt_down_list\"]").find("li")
  133. let playVod = {}
  134. for (const otherPlay of otherPlayList) {
  135. let form_name = $(otherPlay).text()
  136. let is_valify = false
  137. for (const valify_format_name of valify_formt_list) {
  138. if (form_name.indexOf(valify_format_name) > -1) {
  139. is_valify = true
  140. if (form_name.indexOf(aliName) === -1) {
  141. vod_play_from_list.push(valify_format_name)
  142. }
  143. }
  144. }
  145. if (is_valify) {
  146. let vodItems = []
  147. for (const ciliPlayUrl of $(otherPlay).find("a")) {
  148. let episodeUrl = ciliPlayUrl.attribs.href
  149. if ($(otherPlay).text().indexOf(aliName)) {
  150. playVod = await detailContent([episodeUrl])
  151. } else {
  152. let episodeName = Utils.getStrByRegex(/\[(.*?)]/, $(ciliPlayUrl).text())
  153. vodItems.push(episodeName + "$" + episodeUrl)
  154. playVod["磁力链接"] = (vodItems.join("#"))
  155. }
  156. }
  157. }
  158. }
  159. vodDetail.vod_play_from = _.keys(playVod).join('$$$');
  160. vodDetail.vod_play_url = _.values(playVod).join('$$$');
  161. return vodDetail
  162. }
  163. async parseVodShortListFromDocBySearch($) {
  164. const items = $('div.search_list > ul > li');
  165. return _.map(items, (item) => {
  166. const img = $(item).find('img:first')[0];
  167. const a = $(item).find('a:first')[0];
  168. const hdinfo = $($(item).find('div.hdinfo')[0]).text().trim();
  169. const jidi = $($(item).find('div.jidi')[0]).text().trim();
  170. return {
  171. vod_id: a.attribs.href,
  172. vod_name: img.attribs.alt,
  173. vod_pic: img.attribs['data-original'],
  174. vod_remarks: jidi || hdinfo || '',
  175. };
  176. })
  177. }
  178. async setClasses() {
  179. const $ = await this.getHtml(this.siteUrl + '/movie_bt');
  180. const series = $('div#beautiful-taxonomy-filters-tax-movie_bt_series > a[cat-url*=movie_bt_series]');
  181. const tags = $('div#beautiful-taxonomy-filters-tax-movie_bt_tags > a');
  182. let tag = {
  183. key: 'tag', name: '类型', value: _.map(tags, (n) => {
  184. let v = n.attribs['cat-url'] || '';
  185. v = v.substring(v.lastIndexOf('/') + 1);
  186. return {n: n.children[0].data, v: v};
  187. }),
  188. };
  189. tag['init'] = tag.value[0].v;
  190. let classes = _.map(series, (s) => {
  191. let typeId = s.attribs['cat-url'];
  192. typeId = typeId.substring(typeId.lastIndexOf('/') + 1);
  193. this.filterObj[typeId] = [tag];
  194. return {
  195. type_id: typeId, type_name: s.children[0].data,
  196. };
  197. });
  198. const sortName = ['电影', '电视剧', '国产剧', '美剧', '韩剧', '日剧', '海外剧(其他)', '华语电影', '印度电影', '日本电影', '欧美电影', '韩国电影', '动画', '俄罗斯电影', '加拿大电影'];
  199. let sort_classes = _.sortBy(classes, (c) => {
  200. const index = sortName.indexOf(c.type_name);
  201. return index === -1 ? sortName.length : index;
  202. });
  203. for (const sort_class of sort_classes){
  204. let type_name = sort_class["type_name"]
  205. if (type_name!=="会员专区" && type_name !== "站长推荐"){
  206. this.classes.push(sort_class)
  207. }
  208. }
  209. }
  210. async setHomeVod() {
  211. let $ = await this.getHtml()
  212. this.homeVodList = await this.parseVodShortListFromDoc($)
  213. }
  214. async setCategory(tid, pg, filter, extend) {
  215. if (pg <= 0) pg = 1;
  216. const tag = extend.tag || '';
  217. const link = this.siteUrl + '/movie_bt' + (tag.length > 0 ? `/movie_bt_tags/${tag}` : '') + '/movie_bt_series/' + tid + (pg > 1 ? `/page/${pg}` : '');
  218. let $ = await this.getHtml(link)
  219. this.vodList = await this.parseVodShortListFromDocByCategory($)
  220. }
  221. async setDetail(id) {
  222. let $ = await this.getHtml(id)
  223. this.vodDetail = await this.parseVodDetailFromDoc($)
  224. }
  225. async setSearch(wd, quick) {
  226. const $ = await this.getHtml(this.siteUrl + '/xssearch?q=' + wd,this.getSearchHeader());
  227. let html = $.html()
  228. this.vodList = await this.parseVodShortListFromDocBySearch($)
  229. }
  230. async setPlay(flag, id, flags) {
  231. if (flag.indexOf(aliName) > -1 || flag.indexOf(quarkName) > -1) {
  232. this.playUrl = await playContent(flag, id, flags)
  233. this.result.setHeader(getHeaders(flag))
  234. } else {
  235. if (id.indexOf("magnet") > -1) {
  236. this.playUrl = id
  237. } else {
  238. let $ = await this.getHtml(id)
  239. const iframe = $('body iframe[src*=https]');
  240. if (iframe.length > 0) {
  241. const iframeHtml = (await req(iframe[0].attribs.src, {
  242. headers: {
  243. Referer: id, 'User-Agent': Utils.CHROME,
  244. },
  245. })).content;
  246. let player = Utils.getStrByRegex(/var player = "(.*?)"/, iframeHtml)
  247. let rand = Utils.getStrByRegex(/var rand = "(.*?)"/, iframeHtml)
  248. let content = JSON.parse(cryptJs(player, "VFBTzdujpR9FWBhe", rand))
  249. this.playUrl = content["url"]
  250. } else {
  251. const js = $('script:contains(window.wp_nonce)').html();
  252. const group = js.match(/(var.*)eval\((\w*\(\w*\))\)/);
  253. const md5 = Crypto;
  254. const result = eval(group[1] + group[2]);
  255. this.playUrl = result.match(/url:.*?['"](.*?)['"]/)[1];
  256. }
  257. }
  258. }
  259. }
  260. }
  261. let spider = new ChangZhangSpider()
  262. async function init(cfg) {
  263. await spider.init(cfg)
  264. }
  265. async function home(filter) {
  266. return await spider.home(filter)
  267. }
  268. async function homeVod() {
  269. return await spider.homeVod()
  270. }
  271. async function category(tid, pg, filter, extend) {
  272. return await spider.category(tid, pg, filter, extend)
  273. }
  274. async function detail(id) {
  275. return await spider.detail(id)
  276. }
  277. async function play(flag, id, flags) {
  278. return await spider.play(flag, id, flags)
  279. }
  280. async function search(wd, quick) {
  281. return await spider.search(wd, quick)
  282. }
  283. async function proxy(segments, headers) {
  284. return await spider.proxy(segments, headers)
  285. }
  286. export function __jsEvalReturn() {
  287. return {
  288. init: init,
  289. home: home,
  290. homeVod: homeVod,
  291. category: category,
  292. detail: detail,
  293. play: play,
  294. proxy: proxy,
  295. search: search,
  296. };
  297. }
  298. export {spider}