360ba_open.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let siteUrl = 'https://m.360ba.co/';
  3. let siteKey = '';
  4. let siteType = 0;
  5. let headers = {
  6. 'User-Agent': 'Mozilla/5.0 (Linux; Android 12; Redmi K30 Build/SKQ1.210908.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/96.0.4664.104 Mobile Safari/537.36',
  7. 'Referer': siteUrl,
  8. 'Origin': siteUrl,
  9. };
  10. async function request(reqUrl, postData, post) {
  11. let res = await req(reqUrl, {
  12. method: post ? 'post' : 'get',
  13. headers: headers,
  14. data: postData || {},
  15. postType: post ? 'form' : '',
  16. });
  17. let content = res.content;
  18. return content;
  19. }
  20. async function init(cfg) {
  21. siteKey = cfg.skey;
  22. siteType = cfg.stype;
  23. }
  24. async function home(filter) {
  25. let classes = [{
  26. type_id: '1',
  27. type_name: '全部',
  28. },{
  29. type_id: '2',
  30. type_name: '足球',
  31. },{
  32. type_id: '3',
  33. type_name: '篮球',
  34. },{
  35. type_id: '99',
  36. type_name: '综合',
  37. }];
  38. //let filterObj = genFilterObj();
  39. return JSON.stringify({
  40. class: classes,
  41. // filters: filterObj
  42. });
  43. }
  44. async function category(tid, pg, filter, extend) {
  45. let url = siteUrl + 'api/web/live_lists/' + tid;
  46. let videos = await getVideos(url);
  47. return JSON.stringify({
  48. list: videos,
  49. page: 1,
  50. pagecount: 1,
  51. limit: 0,
  52. total: videos.length
  53. });
  54. }
  55. async function detail(id) {
  56. try {
  57. const video = {
  58. vod_play_from: 'Leospring',
  59. vod_play_url: '播放' + '$' + id,
  60. vod_content: '该资源由LeoSpring采集分享,公众号【蚂蚁科技杂谈】',
  61. };
  62. const list = [video];
  63. const result = { list };
  64. return JSON.stringify(result);
  65. } catch (e) {
  66. //console.log('err', e);
  67. }
  68. return null;
  69. }
  70. async function search(wd, quick, pg) {
  71. let url = siteUrl + 'api/web/search?keyword=' + wd;
  72. const data = JSON.parse(await request(url))['data']['ball'];
  73. let videos = _.map(data, (n) => {
  74. let id = n['url'];
  75. let name = n['league_name_zh'] + ' ' + n['home_team_zh'] + ' VS ' + n['away_team_zh'];
  76. let pic = n['cover'];
  77. let remarks = 'LIVING';
  78. return {
  79. vod_id: id,
  80. vod_name: name,
  81. vod_pic: pic,
  82. vod_remarks: remarks,
  83. };
  84. });
  85. return JSON.stringify({
  86. list: videos,
  87. });
  88. }
  89. async function play(flag, id, flags) {
  90. return JSON.stringify({
  91. parse: 0,
  92. url: id,
  93. header: headers
  94. });
  95. }
  96. async function getVideos(url) {
  97. const data = JSON.parse(await request(url))['data']['data'];
  98. let videos = _.map(data, (n) => {
  99. let id = n['url'];
  100. let name = n['league_name_zh'] + ' ' + n['home_team_zh'] + ' VS ' + n['away_team_zh'];
  101. let pic = n['cover'];
  102. let remarks = 'LIVING';
  103. return {
  104. vod_id: id,
  105. vod_name: name,
  106. vod_pic: pic,
  107. vod_remarks: remarks,
  108. };
  109. });
  110. return videos;
  111. }
  112. export function __jsEvalReturn() {
  113. return {
  114. init: init,
  115. home: home,
  116. category: category,
  117. detail: detail,
  118. play: play,
  119. search: search,
  120. };
  121. }