kanqiu_open.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let siteUrl = 'http://www.88kanqiu.one';
  3. let siteKey = '';
  4. let siteType = 0;
  5. let headers = {
  6. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
  7. };
  8. async function request(reqUrl, postData, agentSp, get) {
  9. let res = await req(reqUrl, {
  10. method: get ? 'get' : 'post',
  11. headers: headers,
  12. data: postData || {},
  13. postType: get ? '' : 'form',
  14. });
  15. let content = res.content;
  16. return content;
  17. }
  18. async function get(reqUrl) {
  19. let res = await req(reqUrl, {
  20. method: 'get',
  21. headers: headers
  22. });
  23. let content = res.content;
  24. return content;
  25. }
  26. async function init(cfg) {
  27. siteKey = cfg.skey;
  28. siteType = cfg.stype;
  29. if(cfg.ext) {
  30. siteUrl = cfg.ext;
  31. }
  32. }
  33. async function home(filter) {
  34. let classes = [{
  35. type_id: '0',
  36. type_name: '全部直播',
  37. },{
  38. type_id: '1',
  39. type_name: '篮球直播',
  40. },{
  41. type_id: '8',
  42. type_name: '足球直播',
  43. },{
  44. type_id: '29',
  45. type_name: '其他直播',
  46. }];
  47. let filterObj = genFilterObj();
  48. return JSON.stringify({
  49. class: classes,
  50. filters: filterObj
  51. });
  52. }
  53. async function category(tid, pg, filter, extend) {
  54. if(pg <=0) pg = 1;
  55. let cateId = tid == '0'?'':tid;
  56. if (extend['cateId']) {
  57. cateId = extend['cateId'];
  58. }
  59. let url = siteUrl;
  60. if (cateId != '') {
  61. url = url + '/match/' + cateId + '/live';
  62. }
  63. const html = await get(url);
  64. const $ = load(html);
  65. let videos = [];
  66. let cards = $('.list-group-item');
  67. for(let i=0;i<cards.length;i++){
  68. const n = cards[i];
  69. let vid = $($(n).find('.btn.btn-primary')[0]).attr('href');
  70. vid = vid == undefined? '':siteUrl + vid;
  71. let time = $($(n).find('.category-game-time')[0]).text().trim();
  72. let gameType = $($(n).find('.game-type')[0]).text().trim();
  73. let teamOne = $($(n).find('.team-name')[0]).text().trim();
  74. let teamTwo = $($(n).find('.team-name')[1]).text().trim();
  75. let liveStatus = $($(n).find('.pay-btn > a')[0]).text().trim();
  76. let name = '';
  77. if (time != '') {
  78. name = time + ' ' + gameType + ' ' + teamOne + ' VS ' + teamTwo + ' ' + liveStatus;
  79. } else {
  80. name = $(n).text().replaceAll('\n', '').trim();
  81. }
  82. let pic = $($(n).find('.col-xs-1 > img')[0]).attr('src');
  83. if(!pic || pic == '') pic = 'http://www.88kanqiu.one/static/img/default-img.png';
  84. if(pic.indexOf('http') < 0) pic = siteUrl + pic;
  85. let remark = $($(n).find('.btn.btn-primary')).text();
  86. if (extend['livingStatus'] != '1' || (extend['livingStatus'] === '1' && remark.length > 0)) {
  87. videos.push({
  88. vod_id: vid == ''?name:vid,
  89. vod_name: name,
  90. vod_pic: pic,
  91. vod_remarks: remark
  92. });
  93. }
  94. };
  95. return JSON.stringify({
  96. list: videos,
  97. page: 1,
  98. pagecount: 1,
  99. limit: 0,
  100. total: videos.length
  101. });
  102. }
  103. async function detail(id) {
  104. try {
  105. if(id.indexOf('http') < 0) {
  106. return '{}';
  107. }
  108. let url = id + '-url';
  109. const data = JSON.parse(await get(url)).links;
  110. let playUrls = [];
  111. data.forEach(item => {
  112. let name = item['name'];
  113. let playUrl = item['url'];
  114. playUrls.push(name + '$' + playUrl);
  115. });
  116. const video = {
  117. vod_id: id,
  118. vod_play_from: 'Leospring',
  119. vod_play_url: playUrls.join('#')
  120. };
  121. const list = [video];
  122. const result = { list };
  123. return JSON.stringify(result);
  124. } catch (e) {
  125. //console.log('err', e);
  126. }
  127. return null;
  128. }
  129. async function play(flag, id, flags) {
  130. return JSON.stringify(await getPlayObj(id));
  131. }
  132. async function getPlayObj(id) {
  133. if(id.indexOf('?url=') > 0) {
  134. return {parse: 0, url: id.split('?url=')[1]}
  135. }
  136. if(id.indexOf('replayer') > 0) {
  137. let url = 'https://dszbok.com/prod-api/match/detail?mid=' + id.split('id=')[1] + '&pid=7&langtype=vi&zoneld=Asia/Shanghai';
  138. let playUrl = JSON.parse(await get(url)).data.matchinfo.live_urls[0].url;
  139. return {parse: 0, url: playUrl}
  140. }
  141. if (id.indexOf('live.jpyex.com/player') > 0) {
  142. let url = id.replace('player/play.html', 'api/index/live');
  143. let playUrl = Object.values(JSON.parse(await get(url)).detail.play_url)[0].pCode.m3u8;
  144. return {parse: 0, url: playUrl}
  145. }
  146. if(id.indexOf('sportsteam1234') > 0) {
  147. let playUrl = await parseSportSteam1234(id);
  148. let parse = 0;
  149. if (!playUrl.startsWith('http')) {
  150. playUrl = id;
  151. parse = 1;
  152. }
  153. return {
  154. parse: parse,
  155. url: playUrl,
  156. header: {
  157. 'User-Agent': headers['User-Agent'],
  158. 'Referer': 'http://play.sportsteam1234.com/',
  159. 'Accept': '*/*'
  160. }
  161. }
  162. }
  163. if(id.indexOf('play.926.tv') > 0) {
  164. let playUrl = await parse926Tv(id);
  165. return {
  166. parse: 0,
  167. url: playUrl,
  168. header: {
  169. 'User-Agent': headers['User-Agent'],
  170. 'Referer': 'http://play.926.tv/',
  171. 'Accept': '*/*'
  172. }
  173. }
  174. }
  175. return {parse: 1, url: id,};
  176. }
  177. async function parseSportSteam1234(url) {
  178. if (url.indexOf('gm.php') > 0 || url.indexOf('kbm.php') > 0) {
  179. url = url.replace('gm.php', 'kbm.php');
  180. const html = await get(url);
  181. const $ = load(html);
  182. for(const n of $('script')) {
  183. const text = $(n).text();
  184. if(text.indexOf('encryptedBase64Str') > 0) {
  185. let str = text.split("var encryptedBase64Str = '")[1].split("';")[0];
  186. return decodeURIComponent(aesDecode(str));
  187. }
  188. }
  189. }
  190. return '';
  191. }
  192. async function parse926Tv(url) {
  193. const html = await get(url);
  194. const $ = load(html);
  195. let str = $('div#a1 > span').attr('no-zw-zxx');
  196. str = base64Decode(decode926Tv(str));
  197. str = 'http:' + decodeURIComponent(decode926Tv(str));
  198. return str;
  199. }
  200. function decode926Tv(str){
  201. var arr = [];
  202. for(var i=0;i<str.length;i=i+2){
  203. var v=parseInt(str.substr(i,0x02),0x10);
  204. arr.push(String.fromCharCode(v));
  205. }
  206. return arr.join('');
  207. }
  208. function genFilterObj() {
  209. return {
  210. '0': [{'key': 'livingStatus', 'name': '状态', 'value': [{'n': '全部', 'v': ''},{'n': '直播中', 'v': '1'}]}],
  211. '1': [{'key': 'cateId', 'name': '类型', 'value': [{'n': 'NBA', 'v': '1'}, {'n': 'CBA', 'v': '2'}, {'n': '篮球综合', 'v': '4'}, {'n': '纬来体育', 'v': '21'}]}],
  212. '8': [{'key': 'cateId', 'name': '类型', 'value': [{'n': '英超', 'v': '8'}, {'n': '西甲', 'v': '9'}, {'n': '意甲', 'v': '10'}, {'n': '欧冠', 'v': '12'}, {'n': '欧联', 'v': '13'}, {'n': '德甲', 'v': '14'}, {'n': '法甲', 'v': '15'}, {'n': '欧国联', 'v': '16'}, {'n': '足总杯', 'v': '27'}, {'n': '国王杯', 'v': '33'}, {'n': '中超', 'v': '7'}, {'n': '亚冠', 'v': '11'}, {'n': '足球综合', 'v': '23'}, {'n': '欧协联', 'v': '28'}, {'n': '美职联', 'v': '26'}]}],
  213. '29': [{'key': 'cateId', 'name': '类型', 'value': [{'n': '网球', 'v': '29'}, {'n': '斯洛克', 'v': '30'}, {'n': 'MLB', 'v': '38'}, {'n': 'UFC', 'v': '32'}, {'n': 'NFL', 'v': '25'}, {'n': 'CCTV5', 'v': '18'}]}]
  214. }
  215. }
  216. function base64Decode(text) {
  217. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  218. }
  219. //aes解密
  220. function aesDecode(str) {
  221. const key = Crypto.enc.Utf8.parse("toStringtoString");
  222. var bytes = Crypto.AES.decrypt(str, key, {
  223. iv: Crypto.enc.Utf8.parse("2202030405060719"),
  224. mode: Crypto.mode.CBC,
  225. padding: Crypto.pad.Pkcs7
  226. });
  227. return bytes.toString(Crypto.enc.Utf8);
  228. }
  229. export function __jsEvalReturn() {
  230. return {
  231. init: init,
  232. home: home,
  233. category: category,
  234. detail: detail,
  235. play: play,
  236. };
  237. }