freeok_open.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. import { Crypto, load, _ } from 'assets://js/lib/cat.js';
  2. let key = 'freeok';
  3. let HOST = 'https://www.freeok.vip';
  4. let siteKey = '';
  5. let siteType = 0;
  6. let cookie = '';
  7. 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';
  8. async function request(reqUrl, reqCookie) {
  9. let res = await req(reqUrl, {
  10. method: 'get',
  11. headers: {
  12. 'User-Agent': UA,
  13. 'Referer': HOST,
  14. 'cookie': reqCookie
  15. },
  16. });
  17. return res.content;
  18. }
  19. // cfg = {skey: siteKey, ext: extend}
  20. async function init(cfg) {
  21. siteKey = cfg.skey;
  22. siteType = cfg.stype;
  23. if (cfg.hasOwnProperty('ext')) {
  24. if (cfg.ext.hasOwnProperty('host')) {
  25. HOST = cfg.ext.host;
  26. }
  27. if (cfg.ext.hasOwnProperty('cookie')) {
  28. cookie = cfg.ext.cookie;
  29. }
  30. }
  31. }
  32. async function home(filter) {
  33. let classes = [{"type_id":"1","type_name":"电影"},{"type_id":"2","type_name":"剧集"},{"type_id":"3","type_name":"动漫"},{"type_id":"4","type_name":"综艺"},{"type_id":"5","type_name":"少儿"}];
  34. let filterObj = {
  35. "1":[{"key":"class","name":"剧情","init":"","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":"动画"},{"n":"歌舞","v":"歌舞"},{"n":"历史","v":"历史"},{"n":"纪录","v":"纪录"},{"n":"其他","v":"其他"}]},{"key":"area","name":"地区","init":"","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":"语言","init":"","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"法语","v":"法语"},{"n":"德语","v":"德语"},{"n":"其它","v":"其它"}]},{"key":"year","name":"年份","init":"","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":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  36. "2":[{"key":"cateId","name":"类型","init":"2","value":[{"n":"全部","v":"2"},{"n":"国产剧","v":"6"},{"n":"港台剧","v":"7"},{"n":"日韩剧","v":"8"},{"n":"欧美剧","v":"9"},{"n":"海外剧","v":"10"},{"n":"其他剧","v":"11"}]},{"key":"class","name":"剧情","init":"","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":"网剧"},{"n":"其他","v":"其他"}]},{"key":"area","name":"地区","init":"","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":"语言","init":"","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":"year","name":"年份","init":"","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":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  37. "3":[{"key":"class","name":"剧情","init":"","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":"少年"}]},{"key":"area","name":"地区","init":"","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":"语言","init":"","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":"year","name":"年份","init":"","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":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  38. "4":[{"key":"class","name":"剧情","init":"","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":"纪实"},{"n":"科教","v":"科教"},{"n":"曲艺","v":"曲艺"},{"n":"歌舞","v":"歌舞"},{"n":"财经","v":"财经"},{"n":"汽车","v":"汽车"},{"n":"播报","v":"播报"},{"n":"其他","v":"其他"}]},{"key":"area","name":"地区","init":"","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":"语言","init":"","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":"year","name":"年份","init":"","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":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  39. "5":[{"key":"by","name":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  40. }
  41. return JSON.stringify({
  42. class: classes,
  43. filters: filterObj,
  44. });
  45. }
  46. async function homeVod() {}
  47. async function category(tid, pg, filter, extend) {
  48. if (pg <= 0) pg = 1;
  49. let page = '';
  50. if (pg > 1) {
  51. page = pg;
  52. }
  53. const link = HOST + '/vodshow/' + (extend.cateId || tid) + '-' + (extend.area || '') + '-' + (extend.by || '') + '-' + (extend.class || '') + '-' + (extend.lang || '') + '----' + page + '---' + (extend.year || '') + '.html';
  54. const html = await request(link);
  55. const $ = load(html);
  56. const items = $('a.module-item');
  57. const covers = $('.module-item-cover');
  58. let videos = _.map(items, (item, index) => {
  59. const cover = $(covers[index]);
  60. const img = cover.find('img:first')[0];
  61. const remarks = $(cover.find('div.module-item-note')[0]).text().trim();
  62. return {
  63. vod_id: item.attribs.href.replace(/.*?\/voddetail\/(.*).html/g, '$1'),
  64. vod_name: item.attribs.title,
  65. vod_pic: img.attribs['data-original'],
  66. vod_remarks: remarks || '',
  67. };
  68. });
  69. const hasMore = $('a.page-next:contains(下一页)').length > 0;
  70. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  71. return JSON.stringify({
  72. page: parseInt(pg),
  73. pagecount: pgCount,
  74. limit: 24,
  75. total: 24 * pgCount,
  76. list: videos,
  77. });
  78. }
  79. async function detail(id) {
  80. const html = await request(HOST + '/voddetail/' + id + '.html');
  81. const $ = load(html);
  82. const vod = {
  83. vod_id: id,
  84. vod_name: $('h1:first').text(),
  85. vod_type: $('.module-info-tag-link:eq(2) a:first').text().trim(),
  86. vod_year: $('.module-info-tag-link:eq(0)').text().trim(),
  87. vod_area: $('.module-info-tag-link:eq(1)').text().trim(),
  88. vod_director: $('.module-info-item:contains(导演:)').text().trim().substring(3).trim().replace(/\/$/g, ''),
  89. vod_actor: $('.module-info-item:contains(主演:)').text().trim().substring(3).trim().replace(/\/$/g, ''),
  90. vod_pic: $('.module-info-poster .module-item-pic img:first').attr('data-original'),
  91. vod_remarks : $('.module-info-item:contains(集数:)').text().trim().substring(3) || '',
  92. vod_content: $('.module-info-introduction-content').text().trim(),
  93. };
  94. let playMap = {};
  95. let tabs = $('.module-tab-items-box .module-tab-item');
  96. let playlists = $('.module-play-list');
  97. _.each(tabs, (tab, i) => {
  98. let from = tab.children[0].children[0].data;
  99. if (from.includes('夸克')) {
  100. return;
  101. }
  102. let list = playlists[i];
  103. list = $(list).find('a');
  104. _.each(list, (it) => {
  105. let title = it.children[0].children[0].data;
  106. let playUrl = it.attribs.href.replace(/.*?\/vodplay\/(.*).html/g, '$1');
  107. if (!playMap.hasOwnProperty(from)) {
  108. playMap[from] = [];
  109. }
  110. playMap[from].push(title + '$' + playUrl);
  111. });
  112. });
  113. vod.vod_play_from = _.keys(playMap).join('$$$');
  114. let urls = _.values(playMap);
  115. let vod_play_url = _.map(urls, (urlist) => {
  116. return urlist.join('#');
  117. });
  118. vod.vod_play_url = vod_play_url.join('$$$');
  119. return JSON.stringify({
  120. list: [vod],
  121. });
  122. }
  123. async function play(flag, id, flags) {
  124. const link = HOST + '/vodplay/' + id + '.html';
  125. const html = await request(link);
  126. const $ = load(html, true);
  127. const js = JSON.parse($('script:contains(player_)').html().replace('var player_aaaa=',''));
  128. let playUrl = js.url;
  129. if (js.encrypt == 1) {
  130. playUrl = unescape(playUrl);
  131. } else if (js.encrypt == 2) {
  132. playUrl = unescape(base64Decode(playUrl));
  133. }
  134. let playHtml = await request('https://www.freeok.vip/okplay/?url=' + playUrl);
  135. playUrl = decryptUrl(playHtml);
  136. return JSON.stringify({
  137. parse: 0,
  138. url: playUrl,
  139. header: {
  140. 'User-Agent': UA,
  141. }
  142. });
  143. }
  144. function decryptUrl(html) {
  145. const result = html.match(/var config = {[\w\W]*}[\w\W]*player/);
  146. const jsConfig = eval(result[0].replace(/player$/g, ';config'));
  147. const url = jsConfig.url;
  148. const $ = load(html);
  149. const textStr = $('meta[name="viewport"]').attr('id').replace('now_', '');
  150. const idStr = $('meta[charset="UTF-8"]').attr('id').replace('now_', '');
  151. let keyList = [];
  152. let sortedList = [];
  153. let keyStr = '';
  154. for (let index = 0; index < idStr.length; index++) {
  155. keyList.push({
  156. 'id': idStr[index],
  157. 'text': textStr[index]
  158. });
  159. }
  160. sortedList = keyList.sort((a, b)=> a.id - b.id);
  161. for (const item of sortedList) {
  162. keyStr += item.text;
  163. }
  164. const md5Key = Crypto.MD5(keyStr + '0xd8@pS^vOL$WuOF3').toString();
  165. const endStr = Crypto.enc.Utf8.parse(md5Key.substring(16));
  166. const iv = Crypto.enc.Utf8.parse(md5Key.substring(0, 16));
  167. const decrypted = Crypto.AES.decrypt(url, endStr, {
  168. 'iv': iv,
  169. 'mode': Crypto.mode.CBC,
  170. 'padding': Crypto.pad.Pkcs7,
  171. });
  172. const decryptedUrl = Crypto.enc.Utf8.stringify(decrypted);
  173. return decryptedUrl;
  174. }
  175. function base64Decode(text) {
  176. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  177. }
  178. async function search(wd, quick, pg) {
  179. let html = await request(HOST + '/vod-so/-------------.html?wd=' + wd, cookie);
  180. const $ = load(html);
  181. const items = $('div.module-card-item');
  182. let videos = _.map(items, (item) => {
  183. const title = $(item).find('.module-card-item-title a:first')[0];
  184. const cover = $(item).find('.module-item-cover');
  185. const img = cover.find('img:first')[0];
  186. const remarks = $(cover.find('.module-item-note')[0]).text().trim();
  187. return {
  188. vod_id: title.attribs.href.replace(/.*?\/voddetail\/(.*).html/g, '$1'),
  189. vod_name: title.children[0].children[0].data,
  190. vod_pic: img.attribs['data-original'],
  191. vod_remarks: remarks || '',
  192. };
  193. });
  194. return JSON.stringify({
  195. list: videos,
  196. });
  197. }
  198. export function __jsEvalReturn() {
  199. return {
  200. init: init,
  201. home: home,
  202. homeVod: homeVod,
  203. category: category,
  204. detail: detail,
  205. play: play,
  206. search: search,
  207. };
  208. }