2024-04-09 09:39:03 +08:00
/ *
* @ File : changzhang . js
* @ Author : jade
* @ Date : 2024 / 2 / 2 16 : 02
* @ Email : jadehh @ 1 ive . com
* @ Software : Samples
* @ Desc :
* /
2024-05-06 10:35:10 +08:00
import { Spider } from "./spider.js" ;
import { _ , Crypto , load } from "../lib/cat.js" ;
import { VodDetail , VodShort } from "../lib/vod.js" ;
2024-04-09 09:39:03 +08:00
import * as Utils from "../lib/utils.js" ;
2024-05-06 10:35:10 +08:00
import { detailContent , initAli , playContent } from "../lib/ali.js" ;
2024-04-09 09:39:03 +08:00
function cryptJs ( text , key , iv , type ) {
let key _value = Crypto . enc . Utf8 . parse ( key || 'PBfAUnTdMjNDe6pL' ) ;
let iv _value = Crypto . enc . Utf8 . parse ( iv || 'sENS6bVbwSfvnXrj' ) ;
let content
if ( type ) {
content = Crypto . AES . encrypt ( text , key _value , {
iv : iv _value , mode : Crypto . mode . CBC , padding : Crypto . pad . Pkcs7
} )
} else {
content = Crypto . AES . decrypt ( text , key _value , {
iv : iv _value , padding : Crypto . pad . Pkcs7
} ) . toString ( Crypto . enc . Utf8 )
}
return content
}
class ChangZhangSpider extends Spider {
constructor ( ) {
super ( ) ;
2024-04-25 14:24:07 +08:00
this . siteUrl = "https://www.czys.top"
2024-04-09 09:39:03 +08:00
}
async init ( cfg ) {
await super . init ( cfg ) ;
await initAli ( this . cfgObj [ "token" ] ) ;
}
getName ( ) {
return "🏭️┃厂长直连┃🏭️"
}
getAppName ( ) {
return "厂长直连"
}
getJSName ( ) {
return "changzhang"
}
getType ( ) {
return 3
}
async getHtml ( url = this . siteUrl , headers = this . getHeader ( ) ) {
2024-05-06 10:35:10 +08:00
let response = await this . fetch ( url , null , headers , false , true ) ;
2024-04-09 09:39:03 +08:00
let html = response [ "content" ]
2024-05-06 10:35:10 +08:00
if ( ! _ . isEmpty ( html ) && html . indexOf ( "人机验证" ) === - 1 ) {
2024-04-09 09:39:03 +08:00
return load ( html )
} else {
await this . jadeLog . error ( ` html获取失败 ` , true )
}
}
getSearchHeader ( ) {
return {
"Cookie" : "cf_clearance=otYZbHg1safCIxkCtZfy9DPKbf1Gs_zUskkVDc0MVKM-1707026063-1-ATOpKnTLv9+pv171YE/rzxN/nmvGN9Mucx7vpwp0kW2vZb/cbtz5e2md2/ym7EE+9dT7pPBV+kQOg9vJx2v8cks=;myannoun=1;PHPSESSID=73386nobqugs7r3pb2ljcsp5q4" ,
"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" ,
2024-05-06 10:35:10 +08:00
"Connection" : "keep-alive" ,
"Host" : "www.czzy55.com"
2024-04-09 09:39:03 +08:00
}
}
parseVodShortFromElement ( $ , element ) {
let vodShort = new VodShort ( )
let imgElement = $ ( $ ( element ) . find ( "a" ) ) . find ( "img" ) [ 0 ]
vodShort . vod _name = imgElement . attribs . alt
vodShort . vod _pic = imgElement . attribs [ "data-original" ]
vodShort . vod _remarks = $ ( $ ( $ ( element ) . find ( "[class='hdinfo']" ) ) . find ( "span" ) ) . text ( )
vodShort . vod _id = $ ( element ) . find ( "a" ) [ 0 ] . attribs . href
return vodShort
}
async parseVodShortListFromDoc ( $ ) {
let vod _list = [ ]
let aList = $ ( $ ( "[class=\"mi_cont\"]" ) . find ( "ul" ) ) . find ( "li" )
for ( const a of aList ) {
vod _list . push ( this . parseVodShortFromElement ( $ , a ) )
}
return vod _list
}
async parseVodShortListFromDocByCategory ( $ ) {
let vod _list = [ ]
let aList = $ ( $ ( "[class=\"mi_cont \"]" ) . find ( "ul" ) ) . find ( "li" )
for ( const a of aList ) {
vod _list . push ( this . parseVodShortFromElement ( $ , a ) )
}
return vod _list
}
async parseVodDetailFromDoc ( $ ) {
let vodDetail = new VodDetail ( )
let nodeElement = $ ( "[class='dyxingq']" )
vodDetail . vod _pic = $ ( nodeElement ) . find ( "img" ) [ 0 ] . attribs . src
vodDetail . vod _name = $ ( $ ( nodeElement ) . find ( "h1" ) [ 0 ] ) . text ( )
vodDetail . vod _content = $ ( $ ( $ ( "[class='yp_context']" ) ) . find ( "p" ) ) . text ( )
let infoArray = $ ( nodeElement ) . find ( "[class='moviedteail_list']" ) . find ( "li" )
let x = $ ( infoArray ) . text ( )
for ( const info of infoArray ) {
let content = $ ( info ) . text ( )
if ( content . indexOf ( "类型" ) > - 1 ) {
vodDetail . type _name = content . replaceAll ( "类型" , "" ) . replaceAll ( ": " , "" )
} else if ( content . indexOf ( "年份" ) > - 1 ) {
vodDetail . vod _year = content . replaceAll ( "年份" , "" ) . replaceAll ( ": " , "" )
} else if ( content . indexOf ( "地区" ) > - 1 ) {
vodDetail . vod _area = content . replaceAll ( "地区" , "" ) . replaceAll ( ": " , "" )
} else if ( content . indexOf ( "豆瓣" ) > - 1 ) {
vodDetail . vod _remarks = content . replaceAll ( "豆瓣" , "" ) . replaceAll ( ": " , "" )
} else if ( content . indexOf ( "主演" ) > - 1 ) {
vodDetail . vod _actor = content . replaceAll ( "主演" , "" ) . replaceAll ( ": " , "" )
} else if ( content . indexOf ( "导演" ) > - 1 ) {
vodDetail . vod _director = content . replaceAll ( "导演" , "" ) . replaceAll ( ": " , "" )
} else if ( content . indexOf ( "剧情" ) > - 1 ) {
vodDetail . vod _content = content . replaceAll ( "剧情" , "" ) . replaceAll ( ": " , "" )
}
}
let vod _play _from _list = [ "厂长资源" ]
let vodPlayList = $ ( "[class='paly_list_btn']" )
let vod _play _list = [ ]
for ( const v1 of vodPlayList ) {
let vodItems = [ ]
let aList = $ ( v1 ) . find ( "a" )
for ( const tA of aList ) {
let episodeUrl = tA . attribs . href
let episodeName = $ ( tA ) . text ( ) . replaceAll ( "立即播放 (" , "" ) . replaceAll ( ")" , "" )
vodItems . push ( episodeName + "$" + episodeUrl )
}
vod _play _list . push ( vodItems . join ( "#" ) )
}
let valify _formt _list = [ "磁力链接" , "阿里网盘" ]
let otherPlayList = $ ( "[class=\"ypbt_down_list\"]" ) . find ( "li" )
for ( const otherPlay of otherPlayList ) {
let form _name = $ ( otherPlay ) . text ( )
let is _valify = false
for ( const valify _format _name of valify _formt _list ) {
if ( form _name . indexOf ( valify _format _name ) > - 1 ) {
is _valify = true
if ( form _name . indexOf ( "阿里网盘" ) === - 1 ) {
vod _play _from _list . push ( valify _format _name )
}
}
}
if ( is _valify ) {
let vodItems = [ ]
for ( const ciliPlayUrl of $ ( otherPlay ) . find ( "a" ) ) {
let episodeUrl = ciliPlayUrl . attribs . href
if ( $ ( otherPlay ) . text ( ) . indexOf ( "阿里网盘" ) ) {
let aliVodDetail = await detailContent ( [ episodeUrl ] )
let aliPlayUrlList = aliVodDetail . vod _play _url . split ( "$$$" )
let is _exists = false
for ( const aliPlayUrl of aliPlayUrlList ) {
if ( ! _ . isEmpty ( aliPlayUrl ) ) {
is _exists = true
vod _play _list . push ( aliPlayUrl )
}
}
if ( is _exists ) {
for ( const aliFormatName of aliVodDetail . vod _play _from . split ( "$$$" ) ) {
vod _play _from _list . push ( "阿里云盘-" + aliFormatName )
}
}
} else {
let episodeName = Utils . getStrByRegex ( /\[(.*?)]/ , $ ( ciliPlayUrl ) . text ( ) )
vodItems . push ( episodeName + "$" + episodeUrl )
vod _play _list . push ( vodItems . join ( "#" ) )
}
}
}
}
vodDetail . vod _play _url = vod _play _list . join ( "$$$" )
vodDetail . vod _play _from = vod _play _from _list . join ( "$$$" )
return vodDetail
}
async parseVodShortListFromDocBySearch ( $ ) {
const items = $ ( 'div.search_list > ul > li' ) ;
return _ . map ( items , ( item ) => {
const img = $ ( item ) . find ( 'img:first' ) [ 0 ] ;
const a = $ ( item ) . find ( 'a:first' ) [ 0 ] ;
const hdinfo = $ ( $ ( item ) . find ( 'div.hdinfo' ) [ 0 ] ) . text ( ) . trim ( ) ;
const jidi = $ ( $ ( item ) . find ( 'div.jidi' ) [ 0 ] ) . text ( ) . trim ( ) ;
return {
vod _id : a . attribs . href ,
vod _name : img . attribs . alt ,
vod _pic : img . attribs [ 'data-original' ] ,
vod _remarks : jidi || hdinfo || '' ,
} ;
} )
}
async setClasses ( ) {
const $ = await this . getHtml ( this . siteUrl + '/movie_bt' ) ;
const series = $ ( 'div#beautiful-taxonomy-filters-tax-movie_bt_series > a[cat-url*=movie_bt_series]' ) ;
const tags = $ ( 'div#beautiful-taxonomy-filters-tax-movie_bt_tags > a' ) ;
let tag = {
key : 'tag' , name : '类型' , value : _ . map ( tags , ( n ) => {
let v = n . attribs [ 'cat-url' ] || '' ;
v = v . substring ( v . lastIndexOf ( '/' ) + 1 ) ;
2024-05-06 10:35:10 +08:00
return { n : n . children [ 0 ] . data , v : v } ;
2024-04-09 09:39:03 +08:00
} ) ,
} ;
tag [ 'init' ] = tag . value [ 0 ] . v ;
let classes = _ . map ( series , ( s ) => {
let typeId = s . attribs [ 'cat-url' ] ;
typeId = typeId . substring ( typeId . lastIndexOf ( '/' ) + 1 ) ;
this . filterObj [ typeId ] = [ tag ] ;
return {
type _id : typeId , type _name : s . children [ 0 ] . data ,
} ;
} ) ;
const sortName = [ '电影' , '电视剧' , '国产剧' , '美剧' , '韩剧' , '日剧' , '海外剧(其他)' , '华语电影' , '印度电影' , '日本电影' , '欧美电影' , '韩国电影' , '动画' , '俄罗斯电影' , '加拿大电影' ] ;
let sort _classes = _ . sortBy ( classes , ( c ) => {
const index = sortName . indexOf ( c . type _name ) ;
return index === - 1 ? sortName . length : index ;
} ) ;
2024-05-06 10:35:10 +08:00
for ( const sort _class of sort _classes ) {
2024-04-09 09:39:03 +08:00
let type _name = sort _class [ "type_name" ]
2024-05-06 10:35:10 +08:00
if ( type _name !== "会员专区" && type _name !== "站长推荐" ) {
2024-04-09 09:39:03 +08:00
this . classes . push ( sort _class )
}
}
}
async setHomeVod ( ) {
let $ = await this . getHtml ( )
this . homeVodList = await this . parseVodShortListFromDoc ( $ )
}
async setCategory ( tid , pg , filter , extend ) {
if ( pg <= 0 ) pg = 1 ;
const tag = extend . tag || '' ;
const link = this . siteUrl + '/movie_bt' + ( tag . length > 0 ? ` /movie_bt_tags/ ${ tag } ` : '' ) + '/movie_bt_series/' + tid + ( pg > 1 ? ` /page/ ${ pg } ` : '' ) ;
let $ = await this . getHtml ( link )
this . vodList = await this . parseVodShortListFromDocByCategory ( $ )
}
async setDetail ( id ) {
let $ = await this . getHtml ( id )
this . vodDetail = await this . parseVodDetailFromDoc ( $ )
}
async setSearch ( wd , quick ) {
2024-05-06 10:35:10 +08:00
const $ = await this . getHtml ( this . siteUrl + '/xssearch?q=' + wd , this . getSearchHeader ( ) ) ;
2024-04-09 09:39:03 +08:00
let html = $ . html ( )
this . vodList = await this . parseVodShortListFromDocBySearch ( $ )
}
async setPlay ( flag , id , flags ) {
if ( flag . indexOf ( "阿里云盘" ) > - 1 ) {
2024-05-06 10:35:10 +08:00
flag = flag . replaceAll ( "阿里云盘-" , "" )
2024-04-09 09:39:03 +08:00
this . playUrl = JSON . parse ( await playContent ( flag , id , flags ) ) [ "url" ] ;
} else {
if ( id . indexOf ( "magnet" ) > - 1 ) {
this . playUrl = id
} else {
let $ = await this . getHtml ( id )
const iframe = $ ( 'body iframe[src*=https]' ) ;
if ( iframe . length > 0 ) {
const iframeHtml = ( await req ( iframe [ 0 ] . attribs . src , {
headers : {
Referer : id , 'User-Agent' : Utils . CHROME ,
} ,
} ) ) . content ;
let player = Utils . getStrByRegex ( /var player = "(.*?)"/ , iframeHtml )
let rand = Utils . getStrByRegex ( /var rand = "(.*?)"/ , iframeHtml )
let content = JSON . parse ( cryptJs ( player , "VFBTzdujpR9FWBhe" , rand ) )
this . playUrl = content [ "url" ]
} else {
const js = $ ( 'script:contains(window.wp_nonce)' ) . html ( ) ;
const group = js . match ( /(var.*)eval\((\w*\(\w*\))\)/ ) ;
const md5 = Crypto ;
const result = eval ( group [ 1 ] + group [ 2 ] ) ;
this . playUrl = result . match ( /url:.*?['"](.*?)['"]/ ) [ 1 ] ;
}
}
}
}
}
let spider = new ChangZhangSpider ( )
async function init ( cfg ) {
await spider . init ( cfg )
}
async function home ( filter ) {
return await spider . home ( filter )
}
async function homeVod ( ) {
return await spider . homeVod ( )
}
async function category ( tid , pg , filter , extend ) {
return await spider . category ( tid , pg , filter , extend )
}
async function detail ( id ) {
return await spider . detail ( id )
}
async function play ( flag , id , flags ) {
return await spider . play ( flag , id , flags )
}
async function search ( wd , quick ) {
return await spider . search ( wd , quick )
}
async function proxy ( segments , headers ) {
return await spider . proxy ( segments , headers )
}
export function _ _jsEvalReturn ( ) {
return {
init : init ,
home : home ,
homeVod : homeVod ,
category : category ,
detail : detail ,
play : play ,
proxy : proxy ,
search : search ,
} ;
}
2024-05-06 10:35:10 +08:00
export { spider }