index_bak.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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影视[官]', '菜狗[官]', '奇珍异兽[官]', '优酷[官]', '腾云驾雾[官]', '百忙无果[官]', '哔哩影视[官]', '采集之王[合]', '采集之王[合|密]'];
  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));
  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 = ['?type=url&params=../json/小学教育.json'];
  158. } else if (rname.includes('采集之王')) {
  159. extras = [
  160. '?type=url&params=../json/采集静态.json$1@采王道长[合]',
  161. '?type=url&params=../json/采集[zy]静态.json$1@采王zy[密]',
  162. '?type=url&params=../json/采集[密]静态.json@采王成人[密]',
  163. ];
  164. } else if (rname.includes('直播转点播')) {
  165. extras = [
  166. '?type=url&params=../json/live2cms.json',
  167. ];
  168. }
  169. //let excludes = ['玩偶哥哥','阿里土豆'];
  170. let excludes = [];
  171. if (!excludes.includes(rname)) {
  172. extras.forEach((extra, index) => {
  173. let ext_str = 'drpy_t3';
  174. let _name = extras.length > 1 ? `${rname}${index}` : `${rname}`;
  175. let ext_name = extra.includes('@') ? extra.split('@')[1]:_name;
  176. extra = extra.split('@')[0];
  177. if (extra) {
  178. try {
  179. ext_str = extra.split('/').slice(-1)[0].split('.')[0];
  180. } catch (e) {
  181. }
  182. }
  183. ext_name = ext_name || `${rname}(${ext_str})`;
  184. let data = {
  185. 'key': extras.length > 1 ? `hipy_js_${rname}${index}` : `hipy_js_${rname}`,
  186. 'name': `${ext_name}(drpy_t3)`,
  187. 'type': 3,
  188. 'api': js_api,
  189. 'searchable': 1,
  190. 'quickSearch': 1,
  191. 'filterable': 1,
  192. 'order_num': index,
  193. 'ext': `${js_path}/${it}${extra}`,
  194. };
  195. json_config.sites.push(data);
  196. });
  197. // for(let index in extras){
  198. // let extra = extras[index];
  199. // let ext_str = 'drpy_t3';
  200. // if(extra){
  201. // try{
  202. // ext_str = extra.split('/').slice(-1)[0].split('.')[0];
  203. // }catch(e){}
  204. // }
  205. // let data = {
  206. // 'key': extras.length>1?`hipy_js_${rname}${index}`:`hipy_js_${rname}`,
  207. // 'name': extras.length>1?`${rname}(${ext_str})`:`${rname}(drpy_t3)`,
  208. // 'type': 3,
  209. // 'api': js_api,
  210. // 'searchable': 1,
  211. // 'quickSearch': 1,
  212. // 'filterable': 1,
  213. // 'order_num': index,
  214. // 'ext': `${js_path}/${it}${extra}`,
  215. // };
  216. // json_config.sites.push(data);
  217. // }
  218. }
  219. });
  220. json_config.sites = json_config.sites.concat(config_sites);
  221. json_config.sites = json_config.sites.sort((a, b) => {
  222. let i = a.name.split('(')[0];
  223. let j = b.name.split('(')[0];
  224. return (js_order.indexOf(i) === -1 ? 9999 : js_order.indexOf(i)) - (js_order.indexOf(j) === -1 ? 9999 : js_order.indexOf(j));
  225. });
  226. let top_sites = json_config.sites.filter(x => js_order.includes(x.name.split('(')[0]));
  227. let other_sites = json_config.sites.filter(x => !js_order.includes(x.name.split('(')[0]));
  228. let ret_sites = top_sites.concat(naturalSort(other_sites, 'name'));
  229. json_config.sites = ret_sites;
  230. return JSON.stringify(json_config, null, "\t");
  231. }