91free_open.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let key = '1free';
  3. let HOST = 'https://91d.top';//歪片星球.com
  4. let url = '';
  5. let siteKey = '';
  6. let siteType = 0;
  7. const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E230 Safari/601.1';
  8. async function request(reqUrl, agentSp) {
  9. let res = await req(reqUrl, {
  10. method: 'get',
  11. headers: {
  12. 'User-Agent': agentSp || UA,
  13. 'Referer': HOST
  14. },
  15. });
  16. return res.content;
  17. }
  18. // cfg = {skey: siteKey, ext: extend}
  19. async function init(cfg) {
  20. siteKey = cfg.skey;
  21. siteType = cfg.stype;
  22. let html = await request(HOST);
  23. url = html.match(/<a href="(http.*www.*)" target=.*>/)[1]
  24. console.debug('跳转地址 =====>' + url); // js_debug.log
  25. }
  26. async function home(filter) {
  27. let classes = [{"type_id":1,"type_name":"电影"},{"type_id":2,"type_name":"追剧"},{"type_id":3,"type_name":"综艺"},{"type_id":4,"type_name":"动漫"}];
  28. let filterObj = {
  29. "1":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"1"},{"n":"纪录片","v":"20"},{"n":"动作片","v":"6"},{"n":"爱情片","v":"8"},{"n":"科幻片","v":"9"},{"n":"恐怖片","v":"10"},{"n":"剧情片","v":"11"},{"n":"战争片","v":"12"},{"n":"喜剧片","v":"7"}]},{"key":"area","name":"地区","value":[{"n":"全部","v":""},{"n":"中国大陆","v":"大陆"},{"n":"中国香港","v":"香港"},{"n":"中国台湾","v":"台湾"},{"n":"美国","v":"美国"},{"n":"法国","v":"法国"},{"n":"英国","v":"英国"},{"n":"日本","v":"日本"},{"n":"韩国","v":"韩国"},{"n":"德国","v":"德国"},{"n":"泰国","v":"泰国"},{"n":"印度","v":"印度"},{"n":"意大利","v":"意大利"},{"n":"西班牙","v":"西班牙"},{"n":"加拿大","v":"加拿大"},{"n":"其他","v":"其他"}]},{"key":"lang","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"法语","v":"法语"},{"n":"德语","v":"德语"},{"n":"其它","v":"其它"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"2014","v":"2014"},{"n":"2013","v":"2013"},{"n":"2012","v":"2012"},{"n":"2011","v":"2011"},{"n":"2010","v":"2010"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  30. "2":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"2"},{"n":"国产剧","v":"13"},{"n":"欧美剧","v":"14"},{"n":"港台剧","v":"15"},{"n":"日韩剧","v":"16"},{"n":"泰剧","v":"21"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"2014","v":"2014"},{"n":"2013","v":"2013"},{"n":"2012","v":"2012"},{"n":"2011","v":"2011"},{"n":"2010","v":"2010"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  31. "3":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"3"},{"n":"大陆综艺","v":"22"},{"n":"港台综艺","v":"25"},{"n":"日韩综艺","v":"24"},{"n":"欧美综艺","v":"23"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"2014","v":"2014"},{"n":"2013","v":"2013"},{"n":"2012","v":"2012"},{"n":"2011","v":"2011"},{"n":"2010","v":"2010"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  32. "4":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"4"},{"n":"国产动漫","v":"26"},{"n":"日韩动漫","v":"28"},{"n":"欧美动漫","v":"27"},{"n":"港台动漫","v":"29"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"2014","v":"2014"},{"n":"2013","v":"2013"},{"n":"2012","v":"2012"},{"n":"2011","v":"2011"},{"n":"2010","v":"2010"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}]
  33. };
  34. return JSON.stringify({
  35. class: classes,
  36. filters: filterObj,
  37. });
  38. }
  39. async function homeVod() {}
  40. async function category(tid, pg, filter, extend) {
  41. if (pg <= 0) pg = 1;
  42. const link = url + '/vodshow/' + (extend.cateId || tid) + '-' + (extend.area || '') + '-' + (extend.by || 'time') + '--' + (extend.lang || '') + '----' + pg + '---' + (extend.year || '') + '.html';//https://91free.live/vodshow/6-%E7%BE%8E%E5%9B%BD-hits--%E8%8B%B1%E8%AF%AD----2---2022.html
  43. const html = await request(link);
  44. const $ = load(html);
  45. const items = $('div.module-items a.module-poster-item');
  46. let videos = _.map(items, (item) => {
  47. const it = $(item)[0];
  48. const k = $(item).find('img:first')[0];
  49. const remarks = $($(item).find('div.module-item-note')[0]).text().trim();
  50. return {
  51. vod_id: it.attribs.href.replace(/\/voddetail\/(.*?).html/g, '$1'),
  52. vod_name: k.attribs.alt,
  53. vod_pic: k.attribs['data-original'],
  54. vod_remarks: remarks || '',
  55. };
  56. });
  57. const hasMore = $('div#page > a:contains(下一页)').length > 0;
  58. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  59. return JSON.stringify({
  60. page: parseInt(pg),
  61. pagecount: pgCount,
  62. limit: 24,
  63. total: 24 * pgCount,
  64. list: videos,
  65. });
  66. }
  67. async function detail(id) {
  68. const html = await request( url + '/voddetail/' + id + '.html');
  69. const $ = load(html);
  70. const vod = {
  71. vod_id: id,
  72. vod_name: $('h1:first').text().trim(),
  73. vod_type: $('.module-info-tag a').text(),
  74. vod_actor: $('.module-info-item-content').text(),
  75. vod_pic: $('.module-info img:first').attr('data-src'),
  76. vod_remarks : $('.stui-content__detail p:nth-child(5)').text() || '',
  77. vod_content: $('.module-info-introduction-content p').text().trim(),
  78. };
  79. let playMap = {};
  80. const tabs = $('div.module-tab-items-box div.module-tab-item span');
  81. const playlists = $('div.module-play-list-content');
  82. _.each(tabs, (tab, i) => {
  83. const from = $(tab).text();
  84. let list = playlists[i];
  85. list = $(list).find('a');
  86. _.each(list, (it) => {
  87. const title = $(it).text();
  88. const playUrl = it.attribs.href.replace(/\/vodplay\/(.*?).html/g, '$1');
  89. if (title.length == 0) title = it.children[0].data.trim();
  90. if (!playMap.hasOwnProperty(from)) {
  91. playMap[from] = [];
  92. }
  93. playMap[from].push( title + '$' + playUrl);
  94. });
  95. });
  96. vod.vod_play_from = _.keys(playMap).join('$$$');
  97. const urls = _.values(playMap);
  98. let vod_play_url = _.map(urls, (urlist) => {
  99. return urlist.join('#');
  100. });
  101. vod.vod_play_url = vod_play_url.join('$$$');
  102. return JSON.stringify({
  103. list: [vod],
  104. });
  105. }
  106. async function play(flag, id, flags) {
  107. const link = url + '/vodplay/' + id + '.html';
  108. const html = await request(link);
  109. const $ = load(html);
  110. const js = JSON.parse($('script:contains(player_)').html().replace('var player_aaaa=',''));
  111. const playUrl = js.url;
  112. return JSON.stringify({
  113. parse: 0,
  114. url: playUrl,
  115. });
  116. }
  117. function base64Encode(text) {
  118. return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text));
  119. }
  120. function base64Decode(text) {
  121. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  122. }
  123. async function search(wd, quick, pg) {
  124. if (pg <= 0) pg = 1;
  125. let data = await request(url + '/phsch/' + '/page/' + pg + '/wd/' + wd + '.html');//https://www.physkan.com/phsch/page/2/wd/%E6%88%91.html
  126. const $ = load(data);
  127. const items = $('div.module-items > div.module-item');
  128. let videos = _.map(items, (item) => {
  129. const it = $(item).find('a:first')[0];
  130. const k = $(item).find('img:first')[0];
  131. const remarks = $($(item).find('div.module-item-note')[0]).text().trim();
  132. return {
  133. vod_id: it.attribs.href.replace(/\/v\/(.*?).html/g, '$1'),
  134. vod_name: k.attribs.alt,
  135. vod_pic: k.attribs['data-original'],
  136. vod_remarks: remarks || '',
  137. };
  138. });
  139. const hasMore = $('div#page > a:contains(下一页)').length > 0;
  140. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  141. return JSON.stringify({
  142. page: parseInt(pg),
  143. pagecount: pgCount,
  144. limit: 24,
  145. total: 24 * pgCount,
  146. list: videos,
  147. });
  148. }
  149. export function __jsEvalReturn() {
  150. return {
  151. init: init,
  152. home: home,
  153. homeVod: homeVod,
  154. category: category,
  155. detail: detail,
  156. play: play,
  157. search: search,
  158. };
  159. }