boosj_open.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import { load, _ } from './lib/cat.js';
  2. let key = '童趣';
  3. let HOST = 'https://www.boosj.com';
  4. let siteKey = '';
  5. let siteType = 0;
  6. 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';
  7. async function request(reqUrl, agentSp) {
  8. let res = await req(reqUrl, {
  9. method: 'get',
  10. headers: {
  11. 'User-Agent': agentSp || MOBILE_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. const classes = [{ type_id: '', type_name: '全部' }, { type_id: 28, type_name: '辅食' }, { type_id: 582, type_name: '动画' }, { type_id: 3364, type_name: '儿童舞蹈' }, { type_id: 3366, type_name: '少儿英语' }, { type_id: 3367, type_name: '儿童歌曲' }, { type_id: 3622, type_name: '才艺' }, { type_id: 3782, type_name: '播视自制' }, { type_id: 3822, type_name: '故事' }, { type_id: 3842, type_name: '亲子教育' }, { type_id: 4402, type_name: '美术' }, { type_id: 4583, type_name: '其他' }, { type_id: 4762, type_name: '儿童游戏' }, { type_id: 4842, type_name: '识物' }, { type_id: 4843, type_name: '绘本' }, { type_id: 4844, type_name: '古诗' }, { type_id: 4845, type_name: '科普' }, { type_id: 5102, type_name: '儿童玩具' }, { type_id: 5142, type_name: '播视童趣儿童玩具' }];
  24. const filterObj = {};
  25. const jsonData = [
  26. {
  27. key: 'age',
  28. name: '年龄段',
  29. value: [
  30. { n: '全部', v: '' },
  31. { n: '6岁以上', v: '?p367=370' },
  32. { n: '3~6岁', v: '?p367=369' },
  33. { n: '0~3岁', v: '?p367=368' },
  34. ],
  35. init: '',
  36. },
  37. {
  38. key: 'by',
  39. name: '排序',
  40. value: [
  41. { n: '全部', v: '' },
  42. { n: '最新发布', v: 'lately' },
  43. { n: '最多播放', v: 'pop' },
  44. { n: '最多评论', v: 'view' },
  45. ],
  46. init: '',
  47. },
  48. ];
  49. return JSON.stringify({
  50. class: _.map(classes, (cls) => {
  51. cls.land = 1;
  52. cls.ratio = 1.78;
  53. filterObj[cls.type_id] = jsonData;
  54. return cls;
  55. }),
  56. filters: filterObj,
  57. });
  58. }
  59. async function homeVod() {
  60. const link = HOST + '/search_res_3362__3364_1_.html';
  61. const html = await request(link);
  62. const $ = load(html);
  63. const items = $('body div.bj-col4:has(h3)');
  64. let videos = _.map(items, (it) => {
  65. const a = $(it).find('a:first')[0];
  66. const img = $(it).find('img:first')[0];
  67. const remarks = $(it).find('span.played')[0];
  68. return {
  69. vod_id: a.attribs.href,
  70. vod_name: a.attribs.title,
  71. vod_pic: img.attribs['data-original'],
  72. vod_remarks: remarks.children[0].data || '',
  73. };
  74. });
  75. return JSON.stringify({
  76. list: videos,
  77. });
  78. }
  79. async function category(tid, pg, filter, extend) {
  80. if (pg <= 0 || typeof (pg) == 'undefined') pg = 1;
  81. const link = HOST + '/search_res_3362__' + tid + '_' + pg + '_' + (extend.by || '') + '.html' + (extend.age || '');
  82. const html = await request(link);
  83. const $ = load(html);
  84. const items = $('body div.bj-col4:has(h3)');
  85. let videos = _.map(items, (it) => {
  86. const a = $(it).find('a:first')[0];
  87. const img = $(it).find('img:first')[0];
  88. const remarks = $(it).find('span.played')[0];
  89. return {
  90. vod_id: a.attribs.href,
  91. vod_name: a.attribs.title,
  92. vod_pic: img.attribs['data-original'],
  93. vod_remarks: remarks.children[0].data || '',
  94. };
  95. });
  96. const hasMore = $('div.pub_paging > a:contains(下一页)').length > 0;
  97. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  98. return JSON.stringify({
  99. page: parseInt(pg),
  100. pagecount: pgCount,
  101. limit: 30,
  102. total: 30 * pgCount,
  103. list: videos,
  104. });
  105. }
  106. async function detail(id) {
  107. const vod = {
  108. vod_id: id,
  109. vod_remarks: "",
  110. };
  111. const playlist = ["点击播放" + "$" + vod.vod_id];
  112. vod.vod_play_from = "道长在线";
  113. vod.vod_play_url = playlist.join("#");
  114. return JSON.stringify({
  115. list: [vod],
  116. });
  117. }
  118. async function play(flag, id, flags) {
  119. const body = JSON.parse(await request('https://gslb.boosj.com/ipv2.json'));
  120. body._id = id.match(/\d+/)[0];
  121. const json = JSON.parse(await request(buildUrl(body.gslb, body)));
  122. const purl = json.url + '?' + json.t
  123. // console.debug('童趣purl =====>' + purl); // js_debug.log
  124. let headers = {
  125. 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9; 22081212C Build/PQ3B.190801.002)',
  126. };
  127. return JSON.stringify({
  128. parse: 0,
  129. url: purl,
  130. header: headers,
  131. });
  132. }
  133. async function search(wd, quick) {
  134. var data = JSON.parse(await request('https://search.boosj.com/m_ajax?q=' + wd + '&p=' + pg + '&typeId=3362')).body;
  135. let videos = _.map(data.result, (it) => {
  136. return {
  137. vod_id: it.playUrl,
  138. vod_name: it.resourceName,
  139. vod_pic: it.imageUrl,
  140. vod_remarks: it.clickNumStr || '',
  141. }
  142. });
  143. return JSON.stringify({
  144. page: parseInt(pg),
  145. pagecount: data.pageCount,
  146. limit: 30,
  147. total: data.rowCount,
  148. list: videos,
  149. });
  150. }
  151. function buildUrl(url, obj) {
  152. obj = obj || {};
  153. if (url.indexOf('?') < 0) {
  154. url += '?'
  155. }
  156. let param_list = [];
  157. let keys = Object.keys(obj);
  158. keys.forEach(it => {
  159. param_list.push(it + '=' + obj[it])
  160. });
  161. let prs = param_list.join('&');
  162. if (keys.length > 0 && !url.endsWith('?')) {
  163. url += '&'
  164. }
  165. url += prs;
  166. return url
  167. }
  168. export function __jsEvalReturn() {
  169. return {
  170. init: init,
  171. home: home,
  172. homeVod: homeVod,
  173. category: category,
  174. detail: detail,
  175. play: play,
  176. search: search,
  177. };
  178. }