missav.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let key = 'misaav';
  3. let url = 'https://missav789.com';
  4. let siteKey = '';
  5. let siteType = 0;
  6. 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';
  7. const cookie = {};
  8. const default_filter=[
  9. {
  10. key:'filters',
  11. name:'过滤',
  12. init:'',
  13. value:[
  14. {n:'所有',v:''},
  15. {n:'单人作品',v:'individual'},
  16. {n:'中文字幕',v:'chinese-subtitle'},
  17. ]
  18. },
  19. {
  20. key:'sort',
  21. name:'排序',
  22. init:'',
  23. value:[
  24. {n:'發行日期',v:'released_at'},
  25. {n:'最近更新',v:'published_at'},
  26. {n:'收藏數',v:'saved'},
  27. {n:'今日瀏覽數',v:'today_views'},
  28. {n:'本週瀏覽數',v:'weekly_views'},
  29. {n:'本月瀏覽數',v:'monthly_views'},
  30. {n:'瀏覽數',v:'views'},
  31. ]
  32. }
  33. ]
  34. async function request(reqUrl, referer, mth, data, hd) {
  35. const headers = {
  36. 'User-Agent': UA,
  37. Cookie: _.map(cookie, (value, key) => {
  38. return `${key}=${value}`;
  39. }).join(';'),
  40. };
  41. if (referer) headers.referer = encodeURIComponent(referer);
  42. let res = await req(reqUrl, {
  43. method: mth || 'get',
  44. headers: headers,
  45. data: data,
  46. postType: mth === 'post' ? 'form' : '',
  47. });
  48. if (res.headers['set-cookie']) {
  49. const set_cookie = _.isArray(res.headers['set-cookie']) ? res.headers['set-cookie'].join(';') : res.headers['set-cookie'];
  50. const cks = set_cookie.split(';');
  51. for (const c of cks) {
  52. const tmp = c.trim();
  53. if (tmp.startsWith('result=')) {
  54. cookie.result = tmp.substring(7);
  55. return await request(reqUrl, reqUrl, 'post', {
  56. result: cookie.result,
  57. });
  58. } else if (tmp.startsWith('esc_search_captcha=1')) {
  59. cookie.esc_search_captcha = 1;
  60. delete cookie.result;
  61. return await request(reqUrl);
  62. }
  63. }
  64. // console.log(res.headers['set-cookie']);
  65. }
  66. return res.content;
  67. }
  68. // cfg = {skey: siteKey, ext: extend}
  69. async function init(cfg) {
  70. siteKey = cfg.skey;
  71. siteType = cfg.stype;
  72. //let html=await request(url)
  73. }
  74. async function home(filter) {
  75. let type_list="最近更新=new+新作上市=release+今日热门=today-hot+本周热门=weekly-hot+本月热门=monthly-hot+专题=tags+女优大全=actresses+女优排行榜=actresses/ranking+类型=genres+发行商=makers".split('+')
  76. let filter_list="无码流出=uncensored-leak+中文字幕=chinese-subtitle+素人SIRO=siro+LUXU=luxu+GANA=gana+PrestigePremium=maan+S-CUTE=scute+ARA=ara+无码FC2=fc2+HEYZO=heyzo+东京热=tokyohot+一本道=1pondo+Caribbeancom=caribbeancom+Caribbeancompr=caribbeancompr+10musume=10musume+pacopacomama=pacopacomama+Gachinco=gachinco+XXX-AV=xxxav+人妻斩=marriedslash+顽皮4610=naughty4610+顽皮0930=naughty0930+麻豆传媒=madou+TWAV=twav+Furuke=furuke".split('+')
  77. let classes = _.map(type_list, (s) => {
  78. let typeId = s.split('=')
  79. return {
  80. type_id: typeId[1],
  81. type_name: typeId[0],
  82. };
  83. });
  84. let filterss = _.map(filter_list, (s) => {
  85. let fobj = s.split('=')
  86. return {
  87. v: fobj[1],
  88. n: fobj[0],
  89. };
  90. });
  91. let filterObj = {
  92. "tags":[
  93. {
  94. key:'tag',
  95. name:'主題',
  96. init:'uncensored-leak',
  97. value:filterss
  98. }
  99. ],
  100. "actresses":default_filter,
  101. "genres":default_filter,
  102. "makers":default_filter,
  103. "actresses/ranking":default_filter,
  104. };
  105. return JSON.stringify({
  106. class: classes,
  107. filters: filterObj,
  108. });
  109. }
  110. async function homeVod() {
  111. const min=1
  112. const max=100
  113. const range =max-min
  114. const random= Math.random()
  115. const result=min + Math.round(range*random)
  116. const html=await request(url+'/random/'+result)
  117. const $ =load(html)
  118. const items = $('div.thumbnail')
  119. let videos=_.map(items,(item)=>{
  120. const a = $(item).find('a')[0]
  121. const aa=$($(item).find('a')[1]).text()
  122. // console.log(a)
  123. const vid= a.attribs.href
  124. const img =$(a).find('img')[0].attribs.src
  125. const title=$(a).find('img')[0].attribs.alt
  126. return {
  127. vod_id: vid,
  128. vod_name: title,
  129. vod_pic:img,
  130. vod_remarks:aa
  131. }
  132. } )
  133. return JSON.stringify({
  134. list: videos,
  135. })
  136. }
  137. async function category(tid, pg, filter, extend) {
  138. if (pg <= 0) pg = 1;
  139. let html=null,$=null,items=null,videos=null
  140. switch(tid){
  141. case 'makers':
  142. html = await request(url+'/'+ tid+'?page='+pg)
  143. $=load(html)
  144. items = $('div.grid.grid-cols-2.gap-4 > div')
  145. videos=_.map(items,(item)=>{
  146. const a = $(item).find('a')
  147. console.log(a)
  148. const vid= a[0].attribs.href
  149. const rem =$(a[1]).text().replaceAll('\n','')
  150. const title=$(a[0]).text().replaceAll('\n','')
  151. return {
  152. vod_id: vid,
  153. vod_name: title,
  154. vod_remarks:rem,
  155. vod_tag:'folder'
  156. }
  157. } )
  158. return JSON.stringify({
  159. page: parseInt(pg),
  160. pagecount: 9999,
  161. limit: 20,
  162. total: 99999,
  163. list: videos,
  164. })
  165. break
  166. case 'genres':
  167. html = await request(url+'/'+ tid+'?page='+pg)
  168. $=load(html)
  169. items = $('div.grid.grid-cols-2.gap-4 > div')
  170. videos=_.map(items,(item)=>{
  171. const a = $(item).find('a')
  172. console.log(a)
  173. const vid= a[0].attribs.href
  174. const rem =$(a[1]).text().replaceAll('\n','')
  175. const title=$(a[0]).text().replaceAll('\n','')
  176. return {
  177. vod_id: vid,
  178. vod_name: title,
  179. vod_remarks:rem,
  180. vod_tag:'folder'
  181. }
  182. } )
  183. return JSON.stringify({
  184. page: parseInt(pg),
  185. pagecount: 9999,
  186. limit: 20,
  187. total: 99999,
  188. list: videos,
  189. })
  190. break
  191. case 'actresses/ranking':
  192. html = await request(url+'/'+ tid+'?page='+pg)
  193. $=load(html)
  194. items = $('ul.grid.grid-cols-2.gap-4 > li')
  195. videos=_.map(items,(item)=>{
  196. const a = $(item).find('a')
  197. const vid= a[0].attribs.href
  198. const imgs=$(a[0]).find('img')[0]
  199. const img=imgs?imgs.attribs.src:''
  200. const rem =$($(item).find('span')[0]).text().replaceAll('\n','')
  201. const title=$($(item).find('h4')[0]).text().replaceAll('\n','')
  202. return {
  203. vod_id: vid,
  204. vod_name: title,
  205. vod_remarks: rem,
  206. vod_pic:img,
  207. vod_tag:'folder'
  208. }
  209. } )
  210. return JSON.stringify({
  211. page: parseInt(pg),
  212. pagecount: 9999,
  213. limit: 20,
  214. total: 99999,
  215. list: videos,
  216. style: {
  217. type: "list",
  218. "ratio": 0.68
  219. }
  220. })
  221. break
  222. case 'actresses':
  223. html = await request(url+'/'+ tid+'?page='+pg)
  224. $=load(html)
  225. items = $('ul.grid.grid-cols-2.gap-4 > li')
  226. videos=_.map(items,(item)=>{
  227. const a = $(item).find('a')
  228. const vid= a[0].attribs.href
  229. const imgs=$(a[0]).find('img')[0]
  230. const img=imgs?imgs.attribs.src:''
  231. const rem =$($(item).find('p')[0]).text().replaceAll('\n','')
  232. const title=$($(item).find('h4')[0]).text().replaceAll('\n','')
  233. return {
  234. vod_id: vid,
  235. vod_name: title,
  236. vod_remarks: rem,
  237. vod_pic:img,
  238. vod_tag:'folder'
  239. }
  240. } )
  241. return JSON.stringify({
  242. page: parseInt(pg),
  243. pagecount: 9999,
  244. limit: 20,
  245. total: 99999,
  246. list: videos,
  247. })
  248. break
  249. default:
  250. let ttid=''
  251. if(tid=='tags')
  252. {
  253. ttid=extend.tag
  254. }else{
  255. ttid=tid
  256. }
  257. let urls=''
  258. if(tid.startsWith('http')){
  259. urls=tid+'?page='+pg+'&filters='+extend.filters+'&sort='+extend.sort
  260. }else{
  261. urls=url+'/'+ ttid+'?page='+pg
  262. }
  263. html = await request(urls)
  264. $=load(html)
  265. items = $('div.thumbnail')
  266. videos=_.map(items,(item)=>{
  267. const a = $(item).find('a')[0]
  268. const aa=$($(item).find('a')[1]).text()
  269. // console.log(a)
  270. const vid= a.attribs.href
  271. const img =$(a).find('img')[0].attribs['data-src']
  272. const title=$(a).find('img')[0].attribs.alt
  273. return {
  274. vod_id: vid,
  275. vod_name: title,
  276. vod_pic:img,
  277. vod_remarks:aa
  278. }
  279. } )
  280. return JSON.stringify({
  281. page: parseInt(pg),
  282. pagecount: 9999,
  283. limit: 20,
  284. total: 99999,
  285. list: videos,
  286. })
  287. break
  288. }
  289. return JSON.stringify({
  290. page: parseInt(pg),
  291. pagecount: pgCount,
  292. limit: 20,
  293. total: 20 * pgCount,
  294. list: videos,
  295. });
  296. }
  297. function stripHtmlTag(src) {
  298. return src
  299. .replace(/<\/?[^>]+(>|$)/g, '')
  300. .replace(/&.{1,5};/g, '')
  301. .replace(/\s{2,}/g, ' ');
  302. }
  303. async function detail(id) {
  304. const html = await request(id);
  305. const $ = load(html);
  306. let script=html.match(/let source[\s\S]+?eval.+/)[0];
  307. let sourceFhd=""
  308. let source842=''
  309. let source1280=''
  310. let source=''
  311. eval(script);
  312. let list=[];
  313. let items=[];
  314. list.push({name:"默认",url:sourceFhd||source||""})
  315. list.push({name:"720p",url:source1280||""})
  316. list.push({name:"480p",url:source842||""})
  317. let vod = {
  318. vod_id: id,
  319. vod_pic: '',
  320. vod_remarks: '',
  321. vod_content: '',
  322. };
  323. const playlist = []
  324. _.map(list, (a) => {
  325. if (a.url!=''){
  326. playlist.push(a.name +'$' + a.url);
  327. }
  328. });
  329. vod.vod_play_from = 'missav';
  330. vod.vod_play_url = playlist.join('#');
  331. return JSON.stringify({
  332. list: [vod],
  333. });
  334. }
  335. async function play(flag, id, flags) {
  336. return JSON.stringify({
  337. parse: 0,
  338. url: id,
  339. });
  340. }
  341. async function search(wd, quick,pg) {
  342. if (pg <= 0) pg = 1;
  343. const html = await request(url + '/search/' + wd+"?page="+pg);
  344. const $=load(html)
  345. const items = $('div.thumbnail')
  346. let videos=_.map(items,(item)=>{
  347. const a = $(item).find('a')[0]
  348. // console.log(a)
  349. const vid= a.attribs.href
  350. const img =$(a).find('img')[0].attribs['data-src']
  351. const title=$(a).find('img')[0].attribs.alt
  352. return {
  353. vod_id: vid,
  354. vod_name: title,
  355. vod_pic:img
  356. }
  357. } )
  358. return JSON.stringify({
  359. page: parseInt(pg),
  360. pagecount: 9999,
  361. limit: 20,
  362. total: 99999,
  363. list: videos,
  364. })
  365. }
  366. export function __jsEvalReturn() {
  367. return {
  368. init: init,
  369. home: home,
  370. homeVod: homeVod,
  371. category: category,
  372. detail: detail,
  373. play: play,
  374. search: search,
  375. };
  376. }