sharenice_open.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // 搜索滑块验证
  2. import { load, _ } from './lib/cat.js';
  3. let key = '短视频';
  4. let HOST = 'http://www.sharenice.net';
  5. let siteKey = '';
  6. let siteType = 0;
  7. let PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36';
  8. async function request(reqUrl, agentSp) {
  9. let res = await req(reqUrl, {
  10. method: 'get',
  11. headers: {
  12. 'User-Agent': agentSp || PC_UA,
  13. },
  14. });
  15. return res.content;
  16. }
  17. async function init(cfg) {
  18. siteKey = cfg.skey;
  19. siteType = cfg.stype;
  20. }
  21. function clsjoin(cls) {
  22. _.each(cls, (s) => {
  23. let typeId = s.attribs['href'];
  24. typeId = typeId.substring(typeId.lastIndexOf('t/') + 2);
  25. classes.push({
  26. type_id: typeId,
  27. type_name: s.children[0].data,
  28. });
  29. });
  30. }
  31. let classes = [];
  32. async function home(filter) {
  33. let filterObj = {};
  34. let html = await request(HOST);
  35. let $ = load(html);
  36. let series = $('div.nav > ul > li > a[href*=net/]');
  37. let tag = $('div.hot-tags-list > a[href*=net]');
  38. clsjoin(series);
  39. clsjoin(tag);
  40. return JSON.stringify({
  41. class: classes,
  42. filters: filterObj,
  43. });
  44. }
  45. async function homeVod() {
  46. let link = HOST + '/t-576O5aWz';
  47. let html = await request(link);
  48. let $ = load(html);
  49. let items = $('div.item-box ul li');
  50. let videos = _.map(items, (item) => {
  51. let a = $(item).find('a:first')[0];
  52. let img = $(item).find('img:first')[0];
  53. return {
  54. vod_id: a.attribs.href,
  55. vod_name: a.attribs.title,
  56. vod_pic: img.attribs['data-original'],
  57. vod_remarks: '',
  58. };
  59. });
  60. return JSON.stringify({
  61. list: videos,
  62. });
  63. }
  64. async function category(tid, pg, filter, extend) {
  65. if (pg <= 0 || typeof(pg) == 'undefined') pg = 1;
  66. let link = HOST + '/' + tid + '?page=' + pg;
  67. let html = await request(link);
  68. let $ = load(html);
  69. let items = $('div.item-box ul li');
  70. let videos = _.map(items, (item) => {
  71. let a = $(item).find('a:first')[0];
  72. let img = $(item).find('img:first')[0];
  73. return {
  74. vod_id: a.attribs.href,
  75. vod_name: a.attribs.title,
  76. vod_pic: img.attribs['data-original'],
  77. vod_remarks: '',
  78. };
  79. });
  80. let hasMore = $('ul.pagination > li > a:contains(»)').length > 0;
  81. let pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  82. return JSON.stringify({
  83. page: parseInt(pg),
  84. pagecount: pgCount,
  85. limit: 16,
  86. total: 16 * pgCount,
  87. list: videos,
  88. });
  89. }
  90. async function detail(id) {
  91. let vod = {
  92. vod_id: id,
  93. vod_remarks: '',
  94. };
  95. let playlist = ['观看视频' + '$' + id];
  96. vod.vod_play_from = '道长在线';
  97. vod.vod_play_url = playlist.join('#');
  98. return JSON.stringify({
  99. list: [vod],
  100. });
  101. }
  102. async function play(flag, id, flags) {
  103. let html = await request(id);
  104. let $ = load(html);
  105. let playUrl = $('div.video-play-box').find('video:first')[0].attribs.src + '#.mp4';
  106. return JSON.stringify({
  107. parse: 0,
  108. url: playUrl,
  109. });
  110. }
  111. async function search(wd, quick, pg) {
  112. return '{}';
  113. }
  114. export function __jsEvalReturn() {
  115. return {
  116. init: init,
  117. home: home,
  118. homeVod: homeVod,
  119. category: category,
  120. detail: detail,
  121. play: play,
  122. search: search,
  123. };
  124. }