tuxiaobei_open.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import { load, _ } from './lib/cat.js';
  2. let key = '🐰兔小贝';
  3. let HOST = 'https://www.tuxiaobei.com';
  4. let siteKey = '';
  5. let siteType = 0;
  6. const IOS_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';
  7. async function request(reqUrl, agentSp) {
  8. let res = await req(reqUrl, {
  9. method: 'get',
  10. headers: {
  11. 'User-Agent': agentSp || IOS_UA,
  12. },
  13. });
  14. return res.content
  15. }
  16. async function init(cfg) {
  17. siteKey = cfg.skey;
  18. siteType = cfg.stype
  19. }
  20. async function home(filter) {
  21. const classes = [{ type_id: '', type_name: '🐰全部' }, { type_id: 2, type_name: '🐰儿歌' }, { type_id: 3, type_name: '🐰故事' }, { type_id: 27, type_name: '🐰公益' }, { type_id: 9, type_name: '🐰十万个为什么' }, { type_id: 28, type_name: '🐰安全教育' }, { type_id: 29, type_name: '🐰动物奇缘' }, { type_id: 7, type_name: '🐰弟子规' }, { type_id: 5, type_name: '🐰古诗' }, { type_id: 6, type_name: '🐰三字经' }, { type_id: 8, type_name: '🐰千字文' }, { type_id: 11, type_name: '🐰数学' }, { type_id: 25, type_name: '🐰英语' }, { type_id: 24, type_name: '🐰折纸' }];
  22. const filterObj = {};
  23. return JSON.stringify({
  24. class: _.map(classes, (cls) => {
  25. cls.land = 1;
  26. cls.ratio = 1.78;
  27. return cls;
  28. }),
  29. filters: filterObj,
  30. })
  31. }
  32. async function homeVod() {
  33. const link = await request(HOST + '/list/mip-data?typeId=9&page=1&callback=');
  34. const html = link.match(/\((.*?)\);/)[1];
  35. const data = JSON.parse(html).data;
  36. let videos = _.map(data.items, (it) => {
  37. return {
  38. vod_id: it.video_id,
  39. vod_name: it.name,
  40. vod_pic: it.image,
  41. vod_remarks: it.root_category_name + ' | ' + it.duration_string || '',
  42. }
  43. });
  44. return JSON.stringify({
  45. list: videos,
  46. })
  47. }
  48. async function category(tid, pg, filter, extend) {
  49. if (pg <= 0 || typeof pg == 'undefined') pg = 1;
  50. const link = await request(HOST + '/list/mip-data?typeId=' + tid + '&page=' + pg + '&callback=');
  51. const html = link.match(/\((.*?)\);/)[1];
  52. const data = JSON.parse(html).data;
  53. let videos = _.map(data.items, (it) => {
  54. return {
  55. vod_id: it.video_id,
  56. vod_name: it.name,
  57. vod_pic: it.image,
  58. vod_remarks: it.root_category_name + ' | ' + it.duration_string || '',
  59. }
  60. });
  61. const pgCount = pg * 30 > data.totalCount ? parseInt(pg) : parseInt(pg) + 1;
  62. return JSON.stringify({
  63. page: parseInt(pg),
  64. pagecount: pgCount,
  65. limit: 30,
  66. total: data.totalCount,
  67. list: videos,
  68. })
  69. }
  70. async function detail(id) {
  71. const vod = {
  72. vod_id: id,
  73. vod_remarks: '',
  74. };
  75. const playlist = ['点击播放' + '$' + HOST + '/play/' + id];
  76. vod.vod_play_from = "道长在线";
  77. vod.vod_play_url = playlist.join('#');
  78. return JSON.stringify({
  79. list: [vod],
  80. });
  81. }
  82. async function play(flag, id, flags) {
  83. const html = await request(id);
  84. const $ = load(html);
  85. const pvideo = $("body mip-search-video[video-src*=http]");
  86. const purl = pvideo[0].attribs['video-src'];
  87. // console.debug('兔小贝 purl =====>' + purl); // js_debug.log
  88. return JSON.stringify({
  89. parse: 0,
  90. url: purl,
  91. });
  92. }
  93. async function search(wd, quick) {
  94. const link = HOST + "/search/" + wd;
  95. const html = await request(link);
  96. const $ = load(html);
  97. const list = $("div.list-con > div.items");
  98. let videos = _.map(list, (it) => {
  99. const a = $(it).find("a:first")[0];
  100. const img = $(it).find("mip-img:first")[0];
  101. const tt = $(it).find("p:first")[0];
  102. const remarks = $(it).find("p")[1];
  103. return {
  104. vod_id: a.attribs.href.replace(/.*?\/play\/(.*)/g, '$1'),
  105. vod_name: tt.children[0].data,
  106. vod_pic: img.attribs["src"],
  107. vod_remarks: remarks.children[0].data || "",
  108. };
  109. });
  110. return JSON.stringify({
  111. list: videos,
  112. land: 1,
  113. ratio: 1.78,
  114. });
  115. }
  116. export function __jsEvalReturn() {
  117. return {
  118. init: init,
  119. home: home,
  120. homeVod: homeVod,
  121. category: category,
  122. detail: detail,
  123. play: play,
  124. search: search,
  125. }
  126. }