cntv_open_cctv4.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // 无搜索功能
  2. import { _ } from "./lib/cat.js";
  3. let key = 'CCTV4中文国际';
  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: "TOPC1451542134053698", type_name: "走遍中国"},
  24. {type_id: "TOPC1571300682556971", type_name: "环球综艺秀"},
  25. {type_id: "TOPC1571034804976375", type_name: "美食中国"},
  26. {type_id: "TOPC1451540709098112", type_name: "深度国际"},
  27. {type_id: "TOPC1451539894330405", type_name: "中国新闻"},
  28. {type_id: "TOPC1451540389082713", type_name: "今日关注"},
  29. {type_id: "TOPC1451541432396114", type_name: "中国文艺"},
  30. {type_id: "TOPC1451540448405749", type_name: "今日亚洲"},
  31. {type_id: "TOPC1451540328102649", type_name: "海峡两岸"},
  32. {type_id: "TOPC1451541349400938", type_name: "远方的家"},
  33. {type_id: "TOPC1458109953138295", type_name: "中国舆论场"},
  34. {type_id: "TOPC1473235107169415", type_name: "国家记忆"},
  35. {type_id: "TOPC1670828908956975", type_name: "记住乡愁"},
  36. {type_id: "TOPC1571034869935436", type_name: "国宝·发现"},
  37. {type_id: "TOPC1571034705435323", type_name: "今日环球"},
  38. {type_id: "TOPC1571646754621556", type_name: "华人故事"},
  39. {type_id: "TOPC1571646819318596", type_name: "中国缘"},
  40. {type_id: "TOPC1609904361007481", type_name: "鲁健访谈"},
  41. {type_id: "TOPC1451541666791291",type_name: "中华医药"}
  42. ];
  43. const filterObj = {};
  44. return JSON.stringify({
  45. class: _.map(classes, (cls) => {
  46. cls.land = 1;
  47. cls.ratio = 1.78;
  48. return cls;
  49. }),
  50. filters: filterObj,
  51. })
  52. }
  53. async function homeVod() {
  54. const data = JSON.parse(await request(HOST + '/NewVideo/getVideoListByColumn?id=TOPC1451558856402351&n=10&sort=desc&p=1&mode=0&serviceId=tvcctv'));
  55. let videos = _.map(data.data.list, (it) => {
  56. return {
  57. vod_id: it.guid,
  58. vod_name: it.title,
  59. vod_pic: it.image,
  60. vod_remarks: it.time || '',
  61. }
  62. });
  63. return JSON.stringify({
  64. list: videos,
  65. })
  66. }
  67. async function category(tid, pg, filter, extend) {
  68. if (pg <= 0 || typeof pg == 'undefined') pg = 1;
  69. const data = JSON.parse(await request(HOST + '/NewVideo/getVideoListByColumn?id=' + tid + '&n=10&sort=desc&p=' + pg + '&mode=0&serviceId=tvcctv'));
  70. let videos = _.map(data.data.list, (it) => {
  71. return {
  72. vod_id: it.guid,
  73. vod_name: it.title,
  74. vod_pic: it.image,
  75. vod_remarks: it.time || '',
  76. }
  77. });
  78. 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;
  79. const pgCount = pgChk.length > 0 ? parseInt(pg) + 1 : parseInt(pg);
  80. return JSON.stringify({
  81. page: parseInt(pg),
  82. pagecount: parseInt(pgCount),
  83. limit: 10,
  84. total: parseInt(data.total),
  85. list: videos,
  86. })
  87. }
  88. async function detail(id) {
  89. const vod = {
  90. vod_id: id,
  91. vod_remarks: '',
  92. };
  93. //const playlist = ['点击播放' + '$' + 'https://hls.cntv.myhwcdn.cn/asp/hls/2000/0303000a/3/default/' + id + '/2000.m3u8'];
  94. //const playlist = ['点击播放' + '$' + 'https://newcntv.qcloudcdn.com/asp/hls/main/0303000a/3/default/' + id + '/2000.m3u8'];
  95. //const playlist = ['点击播放' + '$' + 'https://hls.cntv.cdn20.com/asp/hls/2000/0303000a/3/default/' + id + '/2000.m3u8'];
  96. //const playlist = ['点击播放' + '$' + 'https://hls.cntv.myalicdn.com//asp/hls/2000/0303000a/3/default/' + id + '/2000.m3u8'];
  97. const playlist = ['点击播放' + '$' + 'https://dh5.cntv.myhwcdn.cn/asp//hls/2000/0303000a/3/default/' + id + '/2000.m3u8'];
  98. vod.vod_play_from = key;
  99. vod.vod_play_url = playlist.join('#');
  100. return JSON.stringify({
  101. list: [vod],
  102. });
  103. }
  104. async function play(flag, id, flags) {
  105. // console.debug('视聚场 id =====>' + id); // js_debug.log
  106. return JSON.stringify({
  107. parse: 0,
  108. url: id,
  109. })
  110. }
  111. async function search(wd, quick, pg) {
  112. return '{}'
  113. }
  114. export function __jsEvalReturn() {
  115. return {
  116. init: init,
  117. home: home,
  118. homeVod: homeVod,
  119. category: category,
  120. detail: detail,
  121. play: play,
  122. search: search,
  123. }
  124. }