index.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /**
  2. pathLib: {
  3. join: [Function: join],
  4. dirname: [Function: dirname],
  5. readDir: [Function (anonymous)],
  6. readFile: [Function (anonymous)],
  7. stat: [Function (anonymous)]
  8. }
  9. path
  10. path_dir
  11. **/
  12. function naturalSort(arr, key) {
  13. return arr.sort((a, b) => a[key].localeCompare(b[key], undefined, {numeric: true, sensitivity: 'base'}));
  14. }
  15. async function main() {
  16. let js_order = ['360影视[官]', '菜狗[官]', '奇珍异兽[官]', '优酷[官]', '腾云驾雾[官]', '百忙无果[官]', '哔哩影视[官]', '哔哩教育[官]', '哔哩大全[官]', '采王道长[合]', '采王zy[密]'];
  17. let js_path = './drpy_js';
  18. let live_path = './lives';
  19. let config_path = './custom.json';
  20. let js_api = './drpy_libs/drpy2.min.js';
  21. let parse_apis = [
  22. '777,https://jx.777jiexi.com/player/?url=,0',
  23. '8090g,https://www.8090g.cn/jiexi/?url=,0',
  24. 'ik9,https://yparse.ik9.cc/index.php?url=,0',
  25. '杰森,https://jx.jsonplayer.com/player/?url=,0',
  26. '阳途,https://jx.yangtu.top/?url=,0',
  27. '冰豆,https://bd.jx.cn/?url=,0',
  28. 'm3u8TV,https://jx.m3u8.tv/jiexi/?url=,0',
  29. '听乐,https://jx.dj6u.com/?url=,0',
  30. '虾米,https://jx.xmflv.com/?url=,0',
  31. '虾米2,https://jx.xmflv.cc/?url=,0',
  32. '云析,https://jx.yparse.com/index.php?url=,0',
  33. '红狐,https://player.mrgaocloud.com/player/?url=,0',
  34. ];
  35. let parses = parse_apis.map((it) => {
  36. let _name = it.split(',')[0];
  37. let _url = it.split(',')[1];
  38. let _type = it.split(',').length > 2 ? it.split(',')[2] : '0';
  39. _type = Number(_type);
  40. return {
  41. name: _name,
  42. url: _url,
  43. type: _type,
  44. 'ext': {
  45. 'flag': [
  46. 'qiyi',
  47. 'imgo',
  48. '爱奇艺',
  49. '奇艺',
  50. 'qq',
  51. 'qq 预告及花絮',
  52. '腾讯',
  53. 'youku',
  54. '优酷',
  55. 'pptv',
  56. 'PPTV',
  57. 'letv',
  58. '乐视',
  59. 'leshi',
  60. 'mgtv',
  61. '芒果',
  62. 'sohu',
  63. 'xigua',
  64. 'fun',
  65. '风行',
  66. ],
  67. },
  68. 'header': {
  69. 'User-Agent': 'Mozilla/5.0',
  70. },
  71. };
  72. });
  73. let js_files = pathLib.readDir(pathLib.join(path_dir, js_path)).filter(file => file && file.endsWith('.js'));
  74. // console.log(js_files);
  75. let live_files = pathLib.readDir(pathLib.join(path_dir, live_path));
  76. // console.log(live_files);
  77. let config_sites = [];
  78. try {
  79. let config_file = pathLib.readFile(pathLib.join(path_dir, config_path));
  80. config_sites = JSON.parse(config_file).sites;
  81. } catch (e) {
  82. console.log(`get config_file error:${e.message}`);
  83. }
  84. let channels = [];
  85. channels.push({
  86. 'name': '稳定github直播',
  87. 'urls': [
  88. 'proxy://do=live&type=txt&ext=https://ghproxy.net/https://raw.githubusercontent.com/ssili126/tv/main/itvlist.txt',
  89. ],
  90. });
  91. live_files.forEach((it) => {
  92. let absp = pathLib.join(path_dir, `${live_path}/${it}`).replace(/\\/g, '/');
  93. if (absp.includes('/zyplayer/file/')) {
  94. absp = 'http://127.0.0.1:9978/api/v1/file/' + absp.split('/zyplayer/file/')[1];
  95. }
  96. let aname = it.split('.')[0];
  97. channels.push({
  98. 'name': aname,
  99. 'urls': [
  100. 'proxy://do=live&type=txt&ext=' + absp,
  101. ],
  102. });
  103. });
  104. channels = channels.concat([
  105. {
  106. 'name': '云星日记直播',
  107. 'urls': [
  108. 'proxy://do=live&type=txt&ext=http://itvbox.cc/云星日记/Ipv4.txt',
  109. ],
  110. },
  111. {
  112. 'name': '本地嗅探器直播',
  113. 'urls': [
  114. 'proxy://do=live&type=txt&ext=http://127.0.0.1:5708/ysp',
  115. ],
  116. },
  117. ]);
  118. let json_config = {
  119. 'wallpaper': 'https://tuapi.eees.cc/api.php?category=fengjing&type=302',
  120. 'homepage': 'https://github.com/hjdhnx/hipy-server',
  121. "homeLogo": "./img/logo500x200-1.png",
  122. "spider": "./jar/pg.jar?md5=7633f8ea346c082b7aa163be58aed023",
  123. 'sites': [],
  124. 'parses': parses,
  125. 'flags': [
  126. 'imgo',
  127. 'youku',
  128. 'qq',
  129. 'qq 预告及花絮',
  130. 'iqiyi',
  131. 'qiyi',
  132. 'fun',
  133. 'letv',
  134. 'leshi',
  135. 'sohu',
  136. 'tudou',
  137. 'xigua',
  138. 'cntv',
  139. '1905',
  140. 'pptv',
  141. 'mgtv',
  142. 'wasu',
  143. 'bilibili',
  144. 'renrenmi',
  145. ],
  146. 'lives': [
  147. {
  148. 'group': 'redirect',
  149. 'channels': channels,
  150. },
  151. ],
  152. };
  153. js_files.forEach((it, index) => {
  154. let rname = it.replace('.js', '');
  155. let extras = [''];
  156. if (rname.includes('我的哔哩[官]')) {
  157. extras = [
  158. '?type=url&params=../json/哔哩教育.json@哔哩教育[官]',
  159. '?type=url&params=../json/哔哩大全.json@哔哩大全[官]',
  160. ];
  161. } else if (rname.includes('采集之王')) {
  162. extras = [
  163. '?type=url&params=../json/采集静态.json$1@采王道长[合]',
  164. '?type=url&params=../json/采集[zy]静态.json$1@采王zy[密]',
  165. '?type=url&params=../json/采集[密]静态.json@采王成人[密]',
  166. ];
  167. } else if (rname.includes('直播转点播')) {
  168. extras = [
  169. '?type=url&params=../json/live2cms.json',
  170. ];
  171. }
  172. //let excludes = ['玩偶哥哥','阿里土豆'];
  173. let excludes = [];
  174. if (!excludes.includes(rname)) {
  175. extras.forEach((extra, index) => {
  176. let ext_str = 'drpy_t3';
  177. let _name = extras.length > 1 ? `${rname}${index}` : `${rname}`;
  178. let ext_name = extra.includes('@') ? extra.split('@')[1] : _name;
  179. extra = extra.split('@')[0];
  180. if (extra) {
  181. try {
  182. ext_str = extra.split('/').slice(-1)[0].split('.')[0];
  183. } catch (e) {
  184. }
  185. }
  186. ext_name = ext_name || `${rname}(${ext_str})`;
  187. let data = {
  188. 'key': extras.length > 1 ? `hipy_js_${rname}${index}` : `hipy_js_${rname}`,
  189. 'name': `${ext_name}(drpy_t3)`,
  190. 'type': 3,
  191. 'api': js_api,
  192. 'searchable': 1,
  193. 'quickSearch': 1,
  194. 'filterable': 1,
  195. 'order_num': index,
  196. 'ext': `${js_path}/${it}${extra}`,
  197. };
  198. json_config.sites.push(data);
  199. });
  200. // for(let index in extras){
  201. // let extra = extras[index];
  202. // let ext_str = 'drpy_t3';
  203. // if(extra){
  204. // try{
  205. // ext_str = extra.split('/').slice(-1)[0].split('.')[0];
  206. // }catch(e){}
  207. // }
  208. // let data = {
  209. // 'key': extras.length>1?`hipy_js_${rname}${index}`:`hipy_js_${rname}`,
  210. // 'name': extras.length>1?`${rname}(${ext_str})`:`${rname}(drpy_t3)`,
  211. // 'type': 3,
  212. // 'api': js_api,
  213. // 'searchable': 1,
  214. // 'quickSearch': 1,
  215. // 'filterable': 1,
  216. // 'order_num': index,
  217. // 'ext': `${js_path}/${it}${extra}`,
  218. // };
  219. // json_config.sites.push(data);
  220. // }
  221. }
  222. });
  223. json_config.sites = json_config.sites.concat(config_sites);
  224. json_config.sites = json_config.sites.sort((a, b) => {
  225. let i = a.name.split('(')[0];
  226. let j = b.name.split('(')[0];
  227. return (js_order.indexOf(i) === -1 ? 9999 : js_order.indexOf(i)) - (js_order.indexOf(j) === -1 ? 9999 : js_order.indexOf(j));
  228. });
  229. let top_sites = json_config.sites.filter(x => js_order.includes(x.name.split('(')[0]));
  230. let other_sites = json_config.sites.filter(x => !js_order.includes(x.name.split('(')[0]));
  231. let ret_sites = top_sites.concat(naturalSort(other_sites, 'name'));
  232. json_config.sites = ret_sites;
  233. return JSON.stringify(json_config, null, "\t");
  234. }