1+ // import { req, kitty, createTestEnv } from "utils" 
2+ 
3+ // 小猫影视 JS 扩展源:韩剧看看 
4+ // 作者:花专用 
5+ export  default  class  hanjukankan  implements  Handle  { 
6+   getConfig ( )  { 
7+     return  < Iconfig > { 
8+       id : "hanjukankan$" , 
9+       name : "韩剧看看" , 
10+       type : 1 , 
11+       nsfw : false , 
12+       api : "https://www.hanjukankan.com" , 
13+       extra : { 
14+         gfw : false , 
15+         searchLimit : 16 , 
16+       } 
17+     } 
18+   } 
19+ 
20+   async  getCategory ( )  { 
21+     return  [ 
22+       {  text : "韩剧" ,  id : "/xvs1xatxbtxctxdtxetxftxgtxhtatbtct.html"  } , 
23+       {  text : "韩影" ,  id : "/xvs2xatxbtxctxdtxetxftxgtxhtatbtct.html"  } , 
24+       {  text : "韩综" ,  id : "/xvs3xatxbtxctxdtxetxftxgtxhtatbtct.html"  } , 
25+     ] 
26+   } 
27+ 
28+   async  getHome ( )  { 
29+     const  cate  =  env . get < string > ( 'category' ) 
30+     const  page  =  env . get < number > ( 'page' ) 
31+     const  url  =  `${ env . baseUrl } ${ cate } ${ page }  
32+     const  html  =  await  req ( url ) 
33+     const  $  =  kitty . load ( html ) 
34+ 
35+     return  $ ( '.module-poster-item' ) 
36+       . toArray ( ) 
37+       . map ( item  =>  { 
38+         const  a  =  $ ( item ) . find ( "a" ) 
39+         const  img  =  $ ( item ) . find ( 'img' ) 
40+         return  { 
41+           id : a . attr ( 'href' )  ??  "" , 
42+           title : a . attr ( 'title' )  ||  img . attr ( 'alt' )  ||  "" , 
43+           cover : img . attr ( 'data-original' )  ||  img . attr ( 'src' )  ||  "" , 
44+           remark : $ ( item ) . find ( '.module-item-note' ) . text ( ) . trim ( )  ||  "" 
45+         } 
46+       } ) 
47+   } 
48+ 
49+   async  getDetail ( )  { 
50+     const  id  =  env . get < string > ( 'movieId' ) 
51+     const  html  =  await  req ( `${ env . baseUrl } ${ id }  ) 
52+     const  $  =  kitty . load ( html ) 
53+ 
54+     const  title  =  $ ( 'h1, .title, .module-info-heading .module-info-title' ) . text ( ) . trim ( ) 
55+     const  cover  =  $ ( '.module-info-poster img, .pic img' ) . attr ( 'data-original' )  || 
56+       $ ( '.module-info-poster img, .pic img' ) . attr ( 'src' )  ||  "" 
57+     const  desc  =  $ ( '.module-info-introduction, .content_desc, .vod_content' ) . text ( ) . trim ( ) 
58+ 
59+     const  playlist : IPlaylist [ ]  =  [ ] 
60+     $ ( '.module-play-list' ) . each ( ( i ,  el )  =>  { 
61+       const  lineTitle  =  $ ( el ) . find ( '.module-tab-item, .title' ) . text ( ) . trim ( )  ||  `线路${ i  +  1 }  
62+       const  videos  =  $ ( el ) . find ( 'a' ) . toArray ( ) . map ( a  =>  { 
63+         const  href  =  $ ( a ) . attr ( 'href' )  ??  "" 
64+         const  text  =  $ ( a ) . text ( ) . trim ( ) 
65+         return  {  id : href ,  text } 
66+       } ) 
67+       playlist . push ( {  title : lineTitle ,  videos } ) 
68+     } ) 
69+ 
70+     return  { 
71+       id, 
72+       title, 
73+       cover, 
74+       desc, 
75+       playlist
76+     } 
77+   } 
78+ 
79+   async  getSearch ( )  { 
80+     const  wd  =  env . get < string > ( 'keyword' ) 
81+     const  page  =  env . get < number > ( 'page' ) 
82+     const  url  =  `${ env . baseUrl } ${ encodeURIComponent ( wd ) } ${ page }  
83+     const  html  =  await  req ( url ) 
84+     const  $  =  kitty . load ( html ) 
85+ 
86+     return  $ ( '.module-items .module-item' ) . toArray ( ) . map ( item  =>  { 
87+       const  a  =  $ ( item ) . find ( "a" ) 
88+       const  img  =  $ ( item ) . find ( 'img' ) . first ( ) 
89+       return  { 
90+         id : a . attr ( 'href' )  ??  "" , 
91+         title : a . attr ( 'title' )  ||  img . attr ( 'alt' )  ||  "" , 
92+         cover : img . attr ( 'data-original' )  ||  img . attr ( 'src' )  ||  "" , 
93+         remark : $ ( item ) . find ( '.module-item-note' ) . text ( ) . trim ( )  ||  "" 
94+       } 
95+     } ) 
96+   } 
97+ 
98+   async  parseIframe ( )  { 
99+     return  kitty . utils . getM3u8WithIframe ( env ) 
100+   } 
101+ } 
102+ 
103+ // TEST 
104+ // const env = createTestEnv("https://www.hanjukankan.com") 
105+ // const call = new hanjukankan(); 
106+ // (async () => { 
107+ //   const cates = await call.getCategory() 
108+ //   env.set("category", cates[0].id) 
109+ //   env.set("page", 1) 
110+ //   const home = await call.getHome() 
111+ //   env.set("keyword", "爱情") 
112+ //   const search = await call.getSearch() 
113+ //   env.set("movieId", search[0].id) 
114+ //   const detail = await call.getDetail() 
115+ //   debugger 
116+ // })() 
0 commit comments