cntv_open_cctv1.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // 无搜索功能
  2. import { _ } from "./lib/cat.js";
  3. let key = 'CCTV1综合频道';
  4. let HOST = 'http://api.cntv.cn';
  5. let siteKey = '';
  6. let siteType = 0;
  7. 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';
  8. async function request(reqUrl, agentSp) {
  9. let res = await req(reqUrl, {
  10. method: 'get',
  11. headers: {
  12. 'User-Agent': agentSp || MOBILE_UA,
  13. },
  14. });
  15. return res.content
  16. }
  17. async function init(cfg) {
  18. siteKey = cfg.skey;
  19. siteType = cfg.stype
  20. }
  21. async function home(filter) {
  22. const classes = [
  23. {type_id: "TOPC1451528971114112", type_name: "新闻联播"},
  24. {type_id: "TOPC1451558976694518", type_name: "焦点访谈"},
  25. {type_id: "TOPC1451378757637200", type_name: "等着我"},
  26. {type_id: "TOPC1451528792881669", type_name: "晚间新闻"},
  27. {type_id: "TOPC1460958183626327", type_name: "经典咏流传"},
  28. {type_id: "TOPC1579169060379297", type_name: "挑战不可能"},
  29. {type_id: "TOPC1451464665008914", type_name: "今日说法"},
  30. {type_id: "TOPC1636516276237257", type_name: "故事里的中国"},
  31. {type_id: "TOPC1557892390700355", type_name: "时代楷模发布厅"},
  32. {type_id: "TOPC1451464884159276", type_name: "开讲啦"},
  33. {type_id: "TOPC1451525396109388", type_name: "我有传家宝"},
  34. {type_id: "TOPC1451378857272262", type_name: "第一动画乐园"},
  35. {type_id: "TOPC1451378967257534", type_name: "动物世界"},
  36. {type_id: "TOPC1451525103989666", type_name: "人与自然" },
  37. {type_id: "TOPC1650782829200997", type_name: "正大综艺" },
  38. {type_id: "TOPC1451466072378425", type_name: "人口" },
  39. {type_id: "TOPC1451379250581117", type_name: "国际艺苑"},
  40. {type_id: "TOPC1451526037568184", type_name: "生活提示"},
  41. {type_id: "TOPC1451525460925648", type_name: "中华民族"},
  42. {type_id: "TOPC1554187056533820", type_name: "秘境之眼"},
  43. {type_id: "TOPC1611740341987572", type_name: "典籍里的中国"},
  44. {type_id: "TOPC1460958183626327", type_name: "中国诗词大会"},
  45. {type_id: "TOPC1451546588784893",type_name: "生活圈"}
  46. ];
  47. const filterObj = {};
  48. return JSON.stringify({
  49. class: _.map(classes, (cls) => {
  50. cls.land = 1;
  51. cls.ratio = 1.78;
  52. return cls;
  53. }),
  54. filters: filterObj,
  55. })
  56. }
  57. async function homeVod() {
  58. const data = JSON.parse(await request(HOST + '/NewVideo/getVideoListByColumn?id=TOPC1451558856402351&n=10&sort=desc&p=1&mode=0&serviceId=tvcctv'));
  59. let videos = _.map(data.data.list, (it) => {
  60. return {
  61. vod_id: it.guid,
  62. vod_name: it.title,
  63. vod_pic: it.image,
  64. vod_remarks: it.time || '',
  65. }
  66. });
  67. return JSON.stringify({
  68. list: videos,
  69. })
  70. }
  71. async function category(tid, pg, filter, extend) {
  72. if (pg <= 0 || typeof pg == 'undefined') pg = 1;
  73. const data = JSON.parse(await request(HOST + '/NewVideo/getVideoListByColumn?id=' + tid + '&n=10&sort=desc&p=' + pg + '&mode=0&serviceId=tvcctv'));
  74. let videos = _.map(data.data.list, (it) => {
  75. return {
  76. vod_id: it.guid,
  77. vod_name: it.title,
  78. vod_pic: it.image,
  79. vod_remarks: it.time || '',
  80. }
  81. });
  82. const pgChk = JSON.parse(await request(HOST + '/NewVideo/getVideoListByColumn?id=' + tid + '&n=10&sort=desc&p=' + (parseInt(pg) + 1) + '&mode=0&serviceId=tvcctv')).data.list;
  83. const pgCount = pgChk.length > 0 ? parseInt(pg) + 1 : parseInt(pg);
  84. return JSON.stringify({
  85. page: parseInt(pg),
  86. pagecount: parseInt(pgCount),
  87. limit: 10,
  88. total: parseInt(data.total),
  89. list: videos,
  90. })
  91. }
  92. async function detail(id) {
  93. const vod = {
  94. vod_id: id,
  95. vod_remarks: '',
  96. };
  97. //const playlist = ['点击播放' + '$' + 'https://hls.cntv.myhwcdn.cn/asp/hls/2000/0303000a/3/default/' + id + '/2000.m3u8'];
  98. //const playlist = ['点击播放' + '$' + 'https://newcntv.qcloudcdn.com/asp/hls/main/0303000a/3/default/' + id + '/2000.m3u8'];
  99. //const playlist = ['点击播放' + '$' + 'https://hls.cntv.cdn20.com/asp/hls/2000/0303000a/3/default/' + id + '/2000.m3u8'];
  100. //const playlist = ['点击播放' + '$' + 'https://hls.cntv.myalicdn.com//asp/hls/2000/0303000a/3/default/' + id + '/2000.m3u8'];
  101. const playlist = ['点击播放' + '$' + 'https://dh5.cntv.myhwcdn.cn/asp//hls/2000/0303000a/3/default/' + id + '/2000.m3u8'];
  102. vod.vod_play_from = key;
  103. vod.vod_play_from = key;
  104. vod.vod_play_url = playlist.join('#');
  105. return JSON.stringify({
  106. list: [vod],
  107. });
  108. }
  109. async function play(flag, id, flags) {
  110. // console.debug('视聚场 id =====>' + id); // js_debug.log
  111. return JSON.stringify({
  112. parse: 0,
  113. url: id,
  114. })
  115. }
  116. async function search(wd, quick, pg) {
  117. return '{}'
  118. }
  119. export function __jsEvalReturn() {
  120. return {
  121. init: init,
  122. home: home,
  123. homeVod: homeVod,
  124. category: category,
  125. detail: detail,
  126. play: play,
  127. search: search,
  128. }
  129. }