l0l_open.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let key = 'dyxs';
  3. let HOST = 'https://www.l0l.tv';
  4. let siteKey = '';
  5. let siteType = 0;
  6. 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';
  7. async function request(reqUrl, agentSp) {
  8. let res = await req(reqUrl, {
  9. method: 'get',
  10. headers: {
  11. 'User-Agent': agentSp || UA,
  12. 'Referer': HOST
  13. },
  14. });
  15. return res.content;
  16. }
  17. // cfg = {skey: siteKey, ext: extend}
  18. async function init(cfg) {
  19. siteKey = cfg.skey;
  20. siteType = cfg.stype;
  21. }
  22. async function home(filter) {
  23. let classes = [{"type_id":1,"type_name":"电影"},{"type_id":2,"type_name":"追剧"},{"type_id":3,"type_name":"综艺"},{"type_id":4,"type_name":"动漫"}];
  24. let filterObj = {
  25. "1":[{"key":"class","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":"恐怖"},{"n":"悬疑","v":"悬疑"},{"n":"惊悚","v":"惊悚"},{"n":"经典","v":"经典"},{"n":"青春","v":"青春"},{"n":"文艺","v":"文艺"},{"n":"微电影","v":"微电影"},{"n":"古装","v":"古装"},{"n":"历史","v":"历史"}]},{"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":"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"},{"n":"2009","v":"2009"},{"n":"2008","v":"2008"},{"n":"2007","v":"2007"},{"n":"2006","v":"2006"},{"n":"2005","v":"2005"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  26. "2":[{"key":"class","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":"网剧"},{"n":"其他","v":"其他"}]},{"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":"其他"}]},{"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"},{"n":"2009","v":"2009"},{"n":"2008","v":"2008"},{"n":"2007","v":"2007"},{"n":"2006","v":"2006"},{"n":"2005","v":"2005"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  27. "3":[{"key":"class","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":"求职"}]},{"key":"area","name":"地区","value":[{"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"},{"n":"2009","v":"2009"},{"n":"2008","v":"2008"},{"n":"2007","v":"2007"},{"n":"2006","v":"2006"},{"n":"2005","v":"2005"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  28. "4":[{"key":"class","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":"社会"},{"n":"原创","v":"原创"},{"n":"亲子","v":"亲子"},{"n":"益智","v":"益智"},{"n":"励志","v":"励志"},{"n":"其他","v":"其他"}]},{"key":"area","name":"地区","value":[{"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"},{"n":"2009","v":"2009"},{"n":"2008","v":"2008"},{"n":"2007","v":"2007"},{"n":"2006","v":"2006"},{"n":"2005","v":"2005"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}]
  29. };
  30. return JSON.stringify({
  31. class: classes,
  32. filters: filterObj,
  33. });
  34. }
  35. async function homeVod() {}
  36. async function category(tid, pg, filter, extend) {
  37. if (pg <= 0) pg = 1;
  38. const link = HOST + '/vodshow/' + tid + '-' + (extend.area || '') + '-' + (extend.by || 'time') + '-' + (extend.class || '') + '-----' + pg + '---' + (extend.year || '') + '/';//https://www.l0l.tv/vodshow/1-%E7%BE%8E%E5%9B%BD-hits-%E5%8A%A8%E4%BD%9C-%E8%8B%B1%E8%AF%AD-------2022.html
  39. const html = await request(link);
  40. const $ = load(html);
  41. const items = $('div.module-items div.module-item');
  42. let videos = _.map(items, (item) => {
  43. const it = $(item).find('a')[0];
  44. const k = $(item).find('img:first')[0];
  45. const remarks = $($(item).find('div.module-item-text')[0]).text().trim();
  46. return {
  47. vod_id: it.attribs.href,
  48. vod_name: it.attribs.title,
  49. vod_pic: k.attribs['data-src'],
  50. vod_remarks: remarks || '',
  51. };
  52. });
  53. const hasMore = $('div#page > a:contains(下一页)').length > 0;
  54. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  55. return JSON.stringify({
  56. page: parseInt(pg),
  57. pagecount: pgCount,
  58. limit: 24,
  59. total: 24 * pgCount,
  60. list: videos,
  61. });
  62. }
  63. async function detail(id) {
  64. const html = await request( HOST + id);
  65. const $ = load(html);
  66. const vod = {
  67. vod_id: id,
  68. vod_name: $('h1:first').text().trim(),
  69. vod_type: $('.video-info-aux a').text(),
  70. vod_actor: $('.video-info-main a').text(),
  71. vod_pic: $('.module-item-pic img:first').attr('data-src'),
  72. vod_remarks : $('.stui-content__detail p:nth-child(5)').text() || '',
  73. vod_content: $('.video-info-content span').text().trim(),
  74. };
  75. let playMap = {};
  76. const tabs = $('div.module-tab-content > div.module-tab-item > span');
  77. const playlists = $('div.sort-item');
  78. _.each(tabs, (tab, i) => {
  79. const from = tab.children[0].data;
  80. let list = playlists[i];
  81. list = $(list).find('a');
  82. _.each(list, (it) => {
  83. const title = $(it).text();
  84. const playUrl = it.attribs.href;
  85. if (title.length == 0) title = it.children[0].data.trim();
  86. if (!playMap.hasOwnProperty(from)) {
  87. playMap[from] = [];
  88. }
  89. playMap[from].push( title + '$' + playUrl);
  90. });
  91. });
  92. vod.vod_play_from = _.keys(playMap).join('$$$');
  93. const urls = _.values(playMap);
  94. let vod_play_url = _.map(urls, (urlist) => {
  95. return urlist.join('#');
  96. });
  97. vod.vod_play_url = vod_play_url.join('$$$');
  98. return JSON.stringify({
  99. list: [vod],
  100. });
  101. }
  102. async function play(flag, id, flags) {
  103. const link = HOST + id;
  104. const html = await request(link);
  105. const $ = load(html);
  106. const js = JSON.parse($('script:contains(player_)').html().replace('var player_aaaa=',''));
  107. const playUrl = unescape(js.url);
  108. return JSON.stringify({
  109. parse: 0,
  110. url: playUrl,
  111. });
  112. }
  113. function base64Encode(text) {
  114. return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text));
  115. }
  116. function base64Decode(text) {
  117. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  118. }
  119. async function search(wd, quick, pg) {
  120. if (pg <= 0) pg = 1;
  121. let data = await request(HOST + '/vodsearch/' + wd + '----------' + pg + '---' + '.html');//https://www.l0l.tv/vodsearch/%E6%88%91----------2---.html
  122. const $ = load(data);
  123. const items = $('div.module-items div.module-search-item');
  124. let videos = _.map(items, (item) => {
  125. const it = $(item).find('a')[0];
  126. const k = $(item).find('img:first')[0];
  127. const remarks = $($(item).find('div.video-serial')[0]).text().trim();
  128. return {
  129. vod_id: it.attribs.href,
  130. vod_name: it.attribs.title,
  131. vod_pic: k.attribs['data-src'],
  132. vod_remarks: remarks || '',
  133. };
  134. });
  135. const hasMore = $('div#page > a:contains(下一页)').length > 0;
  136. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  137. return JSON.stringify({
  138. page: parseInt(pg),
  139. pagecount: pgCount,
  140. limit: 24,
  141. total: 24 * pgCount,
  142. list: videos,
  143. });
  144. }
  145. export function __jsEvalReturn() {
  146. return {
  147. init: init,
  148. home: home,
  149. homeVod: homeVod,
  150. category: category,
  151. detail: detail,
  152. play: play,
  153. search: search,
  154. };
  155. }