libvio_open.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // 自动从 地址发布页 获取&跳转url地址
  2. import { load, _ } from './lib/cat.js';
  3. var key = 'libvio';
  4. var HOST = 'https://libvio.app'; // 地址发布页
  5. var host = '';
  6. var siteKey = '';
  7. var siteType = 0;
  8. const MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36';
  9. async function request(reqUrl, agentSp) {
  10. var res = await req(reqUrl, {
  11. method: 'get',
  12. headers: {
  13. 'User-Agent': agentSp || MOBILE_UA,
  14. 'Referer': host
  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. var html = await request(HOST);
  24. var $ = load(html);
  25. host = $('div.content-top > ul > li').find('a:first')[0].attribs.href;
  26. // console.debug('libvio跳转地址 =====>' + urls); // js_debug.log
  27. }
  28. async function home(filter) {
  29. var html = await request(host);
  30. var $ = load(html);
  31. var class_parse = $('ul.stui-header__menu > li > a[href*=type]');
  32. var classes = [];
  33. classes = _.map(class_parse, (cls) => {
  34. var typeId = cls.attribs['href'];
  35. typeId = typeId.substring(typeId.lastIndexOf('/') + 1).replace('.html','');
  36. return {
  37. type_id: typeId,
  38. type_name: cls.children[0].data,
  39. };
  40. });
  41. var filterObj = {
  42. 1:[{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'}]},{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:'by',name:'排序',value:[{n:'时间',v:'time'},{n:'人气',v:'hits'},{n:'评分',v:'score'}]}],
  43. 2:[{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'}]},{key:'lang',name:'语言',value:[{n:'全部',v:''},{n:'国语',v:'国语'},{n:'英语',v:'英语'},{n:'粤语',v:'粤语'},{n:'闽南语',v:'闽南语'},{n:'韩语',v:'韩语'},{n:'日语',v:'日语'},{n:'其它',v:'其它'}]},{key:'by',name:'排序',value:[{n:'时间',v:'time'},{n:'人气',v:'hits'},{n:'评分',v:'score'}]}],
  44. 4:[{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'},{n:'2004',v:'2004'}]},{key:'lang',name:'语言',value:[{n:'全部',v:''},{n:'国语',v:'国语'},{n:'英语',v:'英语'},{n:'粤语',v:'粤语'},{n:'闽南语',v:'闽南语'},{n:'韩语',v:'韩语'},{n:'日语',v:'日语'},{n:'其它',v:'其它'}]},{key:'by',name:'排序',value:[{n:'时间',v:'time'},{n:'人气',v:'hits'},{n:'评分',v:'score'}]}],
  45. 27:[{key:'by',name:'排序',value:[{n:'时间',v:'time'},{n:'人气',v:'hits'},{n:'评分',v:'score'}]}],
  46. 15:[{key:'area',name:'地区',value:[{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:'lang',name:'语言',value:[{n:'全部',v:''},{n:'国语',v:'国语'},{n:'英语',v:'英语'},{n:'粤语',v:'粤语'},{n:'闽南语',v:'闽南语'},{n:'韩语',v:'韩语'},{n:'日语',v:'日语'},{n:'其它',v:'其它'}]},{key:'by',name:'排序',value:[{n:'时间',v:'time'},{n:'人气',v:'hits'},{n:'评分',v:'score'}]}],
  47. 16:[{key:'area',name:'地区',value:[{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:'lang',name:'语言',value:[{n:'全部',v:''},{n:'国语',v:'国语'},{n:'英语',v:'英语'},{n:'粤语',v:'粤语'},{n:'闽南语',v:'闽南语'},{n:'韩语',v:'韩语'},{n:'日语',v:'日语'},{n:'其它',v:'其它'}]},{key:'by',name:'排序',value:[{n:'时间',v:'time'},{n:'人气',v:'hits'},{n:'评分',v:'score'}]}]
  48. };
  49. return JSON.stringify({
  50. class: classes,
  51. filters: filterObj,
  52. });
  53. }
  54. async function homeVod() {
  55. var link = host + '/show/1--hits---------.html';
  56. var html = await request(link);
  57. var $ = load(html);
  58. var items = $('ul.stui-vodlist > li');
  59. let videos = _.map(items, (item) => {
  60. var a = $(item).find('a:first')[0];
  61. var remarks = $($(item).find('span.pic-text')[0]).text().trim();
  62. return {
  63. vod_id: a.attribs.href.replace(/.*?\/detail\/(.*).html/g, '$1'),
  64. vod_name: a.attribs.title,
  65. vod_pic: a.attribs['data-original'],
  66. vod_remarks: remarks || '',
  67. };
  68. });
  69. return JSON.stringify({
  70. list: videos,
  71. });
  72. }
  73. async function category(tid, pg, filter, extend) {
  74. if (pg <= 0 || typeof(pg) == 'undefined') pg = 1;
  75. var link = host + '/show/' + tid + '-' + (extend.area || '') + '-' + (extend.by || 'time') + '--' + (extend.lang || '') + '----' + pg + '---' + (extend.year || '') + '.html';
  76. var html = await request(link);
  77. var $ = load(html);
  78. var items = $('ul.stui-vodlist > li');
  79. let videos = _.map(items, (item) => {
  80. var a = $(item).find('a:first')[0];
  81. var remarks = $($(item).find('span.pic-text')[0]).text().trim();
  82. return {
  83. vod_id: a.attribs.href.replace(/.*?\/detail\/(.*).html/g, '$1'),
  84. vod_name: a.attribs.title,
  85. vod_pic: a.attribs['data-original'],
  86. vod_remarks: remarks || '',
  87. };
  88. });
  89. var hasMore = $('ul.stui-page__item > li > a:contains(下一页)').length > 0;
  90. var pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  91. return JSON.stringify({
  92. page: parseInt(pg),
  93. pagecount: pgCount,
  94. limit: 24,
  95. total: 24 * pgCount,
  96. list: videos,
  97. });
  98. }
  99. async function detail(id) {
  100. var html = await request(host + '/detail/' + id + '.html');
  101. var $ = load(html);
  102. var vod = {
  103. vod_id: id,
  104. vod_name: $('h1:first').text().trim(),
  105. vod_type: $('.stui-content__detail p:first a').text(),
  106. vod_actor: $('.stui-content__detail p:nth-child(3)').text().replace('主演:',''),
  107. vod_pic: $('.stui-content__thumb img:first').attr('data-original'),
  108. vod_remarks : $('.stui-content__detail p:nth-child(5)').text() || '',
  109. vod_content: $('span.detail-content').text().trim(),
  110. };
  111. var playMap = {};
  112. var tabs = $('div.stui-pannel__head > h3[class*=iconfont]');
  113. var playlists = $('ul.stui-content__playlist');
  114. _.each(tabs, (tab, i) => {
  115. var from = tab.children[0].data;
  116. var list = playlists[i];
  117. list = $(list).find('a');
  118. _.each(list, (it) => {
  119. var title = it.children[0].data;
  120. var playUrl = it.attribs.href;
  121. if (title.length == 0) title = it.children[0].data.trim();
  122. if (!playMap.hasOwnProperty(from)) {
  123. playMap[from] = [];
  124. }
  125. playMap[from].push( title + '$' + playUrl);
  126. });
  127. });
  128. vod.vod_play_from = _.keys(playMap).join('$$$');
  129. var urls = _.values(playMap);
  130. var vod_play_url = _.map(urls, (urlist) => {
  131. return urlist.join('#');
  132. });
  133. vod.vod_play_url = vod_play_url.join('$$$');
  134. return JSON.stringify({
  135. list: [vod],
  136. });
  137. }
  138. async function play(flag, id, flags) {
  139. var html = await request(host + id);
  140. html = html.match(/r player_.*?=(.*?)</)[1];
  141. var js = JSON.parse(html);
  142. var url = js.url;
  143. var from = js.from;
  144. var next = js.link_next;
  145. var id = js.id;
  146. var nid = js.nid;
  147. var paurl = await request(host +'/static/player/' + from + '.js');
  148. paurl = paurl.match(/ src="(.*?)'/)[1];
  149. var purl = paurl + url + '&next=' + next + '&id=' + id + '&nid=' + nid;
  150. var playUrl = await request(purl);
  151. playUrl = playUrl.match(/var .* = '(.*?)'/)[1];
  152. // console.debug('libvio playUrl =====>' + playUrl); // js_debug.log
  153. return JSON.stringify({
  154. parse: 0,
  155. url: playUrl,
  156. });
  157. }
  158. async function search(wd, quick) {
  159. var data = JSON.parse(await request(host + '/index.php/ajax/suggest?mid=1&wd=' + wd + '&limit=50')).list;
  160. var videos = [];
  161. for (const vod of data) {
  162. videos.push({
  163. vod_id: vod.id,
  164. vod_name: vod.name,
  165. vod_pic: vod.pic,
  166. vod_remarks: '',
  167. });
  168. }
  169. return JSON.stringify({
  170. list: videos,
  171. limit: 50,
  172. });
  173. }
  174. export function __jsEvalReturn() {
  175. return {
  176. init: init,
  177. home: home,
  178. homeVod: homeVod,
  179. category: category,
  180. detail: detail,
  181. play: play,
  182. search: search,
  183. };
  184. }