parsingUrl.java 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. import org.codehaus.jettison.json.JSONArray;
  2. import org.codehaus.jettison.json.JSONException;
  3. import org.codehaus.jettison.json.JSONObject;
  4. import java.io.BufferedReader;
  5. import java.io.IOException;
  6. import java.io.InputStreamReader;
  7. import java.net.HttpURLConnection;
  8. import java.net.IDN;
  9. import java.net.URL;
  10. import java.net.URLConnection;
  11. import java.nio.charset.StandardCharsets;
  12. import java.util.ArrayList;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.Map;
  16. import java.util.regex.Matcher;
  17. import java.util.regex.Pattern;
  18. import java.util.stream.Collectors;
  19. class UrlObject {
  20. private String name;
  21. private String url;
  22. public UrlObject(String name, String url) {
  23. this.name = name;
  24. this.url = url;
  25. }
  26. public String getName() {
  27. return name;
  28. }
  29. public String getUrl() {
  30. return url;
  31. }
  32. }
  33. public class parsingUrl {
  34. public static List<UrlObject> convertToObjectList(String jsonStr) throws JSONException {
  35. List<UrlObject> objectList = new ArrayList<>();
  36. JSONObject jsonObject = new JSONObject(jsonStr);
  37. JSONArray urlsArray = jsonObject.getJSONArray("urls");
  38. for (int i = 0; i < urlsArray.length(); i++) {
  39. JSONObject urlObject = urlsArray.getJSONObject(i);
  40. String name = urlObject.getString("name");
  41. String url = urlObject.getString("url");
  42. objectList.add(new UrlObject(name, url));
  43. }
  44. return objectList;
  45. }
  46. public static void main(String[] args) throws JSONException, IOException {
  47. main();
  48. // getjson();
  49. // accessUrl("http://肥猫.com",5000);
  50. // getPunycode("http://肥猫.com");
  51. }
  52. public static void main() throws JSONException {
  53. String json = "{\n" +
  54. " \"urls\": [\n" +
  55. " {\n" +
  56. " \"url\": \"http://肥猫.com\",\n" +
  57. " \"name\": \"新肥猫\"\n" +
  58. " },\n" +
  59. " {\n" +
  60. " \"name\": \"ygbox\",\n" +
  61. " \"url\": \"https://gitee.com/Hanby0511/tv_json/raw/master/ygbox.json\"\n" +
  62. " },\n" +
  63. " {\n" +
  64. " \"name\": \"ygbox1\",\n" +
  65. " \"url\": \"https://gitee.com/Hanby0511/tv_json/raw/master/ygbox1.json\"\n" +
  66. " },\n" +
  67. " {\n" +
  68. " \"name\": \"vip2\",\n" +
  69. " \"url\": \"https://gitee.com/Hanby0511/tv_json/raw/master/vip2.json\"\n" +
  70. " },\n" +
  71. " {\n" +
  72. " \"name\": \"hanby\",\n" +
  73. " \"url\": \"https://gitee.com/Hanby0511/tv_json/raw/master/hanby.json\"\n" +
  74. " },\n" +
  75. " {\n" +
  76. " \"name\": \"child\",\n" +
  77. " \"url\": \"https://gitee.com/Hanby0511/tv_json/raw/master/child.json\"\n" +
  78. " },\n" +
  79. " {\n" +
  80. " \"name\": \"放牛\",\n" +
  81. " \"url\": \"http://tvbox.王二小放牛娃.xyz\"\n" +
  82. " },\n" +
  83. " {\n" +
  84. " \"name\": \"云星日记\",\n" +
  85. " \"url\": \"http://itvbox.cc/云星日记\"\n" +
  86. " },\n" +
  87. " {\n" +
  88. " \"name\": \"OK猫\",\n" +
  89. " \"url\": \"https://jihulab.com/okcaptain/kko/-/raw/main/tv.txt\"\n" +
  90. " },\n" +
  91. " {\n" +
  92. " \"name\": \"高山流云\",\n" +
  93. " \"url\": \"https://www.gitlink.org.cn/api/wxrj/wx/raw/wx.json?ref=master\"\n" +
  94. " },\n" +
  95. " {\n" +
  96. " \"name\": \"俊于\",\n" +
  97. " \"url\": \"http://home.jundie.top:81/top98.json\"\n" +
  98. " },\n" +
  99. " {\n" +
  100. " \"name\": \"巧技\",\n" +
  101. " \"url\": \"http://pandown.pro/tvbox/tvbox.json\"\n" +
  102. " },\n" +
  103. " {\n" +
  104. " \"name\": \"Ray2\",\n" +
  105. " \"url\": \"https://dxawi.github.io/0/0.json\"\n" +
  106. " },\n" +
  107. " {\n" +
  108. " \"name\": \"巧儿\",\n" +
  109. " \"url\": \"http://pandown.pro/tvbox/tvbox.json\"\n" +
  110. " },\n" +
  111. " {\n" +
  112. " \"name\": \"俊哥\",\n" +
  113. " \"url\": \"http://home.jundie.top:81/top98.json\"\n" +
  114. " },\n" +
  115. " {\n" +
  116. " \"name\": \"天天开心\",\n" +
  117. " \"url\": \"http://tv.rihou.cc/天天开心\"\n" +
  118. " },\n" +
  119. " {\n" +
  120. " \"name\": \"香雅晴\",\n" +
  121. " \"url\": \"https://ghproxy.net/https://raw.githubusercontent.com/xyq254245/xyqonlinerule/main/XYQTVBox.json\"\n" +
  122. " },\n" +
  123. " {\n" +
  124. " \"name\": \"运输车\",\n" +
  125. " \"url\": \"https://weixine.net/ysc.json\"\n" +
  126. " },\n" +
  127. " {\n" +
  128. " \"name\": \"货运车\",\n" +
  129. " \"url\": \"https://cf.weixine.net/ysc.json\"\n" +
  130. " },\n" +
  131. " {\n" +
  132. " \"url\": \"http://我不是.摸鱼儿.top\",\n" +
  133. " \"name\": \"摸鱼\"\n" +
  134. " },\n" +
  135. " {\n" +
  136. " \"url\": \"http://xhww.fun/小米/DEMO.json\",\n" +
  137. " \"name\": \"小米\"\n" +
  138. " },\n" +
  139. " {\n" +
  140. " \"name\": \"动漫城\",\n" +
  141. " \"url\": \"https://www.yingm.cc/dm/dm.json\"\n" +
  142. " },\n" +
  143. " {\n" +
  144. " \"name\": \"业余阿里\",\n" +
  145. " \"url\": \"http://yydf.540734621.xyz/yydf/yydf/bd/ali.json\"\n" +
  146. " },\n" +
  147. " {\n" +
  148. " \"name\": \"影探\",\n" +
  149. " \"url\": \"http://www.lyyytv.cn/yt/yt.json\"\n" +
  150. " },\n" +
  151. " {\n" +
  152. " \"name\": \"飘零\",\n" +
  153. " \"url\": \"https://100km.top\"\n" +
  154. " },\n" +
  155. " {\n" +
  156. " \"name\": \"小马\",\n" +
  157. " \"url\": \"https://szyyds.cn/tv/x.json\"\n" +
  158. " },\n" +
  159. " {\n" +
  160. " \"name\": \"魔饭\",\n" +
  161. " \"url\": \"https://jihulab.com/yw88075/tvbox/-/raw/main/dr/js.json\"\n" +
  162. " },\n" +
  163. " {\n" +
  164. " \"name\": \"拾光4K\",\n" +
  165. " \"url\": \"https://gh.con.sh/https://raw.githubusercontent.com/xmbjm/vip4K/main/4Kvip.json\"\n" +
  166. " },\n" +
  167. " {\n" +
  168. " \"name\": \"拾光畅谈\",\n" +
  169. " \"url\": \"https://gh.con.sh/https://raw.githubusercontent.com/xmbjm/vip/main/vip4k.json\"\n" +
  170. " },\n" +
  171. " {\n" +
  172. " \"name\": \"一夫莫当\",\n" +
  173. " \"url\": \"http://yydf.540734621.xyz/yydf/yydf/bd/watson/watson.json\"\n" +
  174. " },\n" +
  175. " {\n" +
  176. " \"name\": \"业余PG\",\n" +
  177. " \"url\": \"http://yydf.540734621.xyz/yydf/yydf/bd/pg.json\"\n" +
  178. " },\n" +
  179. " {\n" +
  180. " \"url\": \"https://gh-proxy.com/https://raw.githubusercontent.com/gaotianliuyun/gao/master/XYQ.json\",\n" +
  181. " \"name\": \"香雅晴\"\n" +
  182. " },\n" +
  183. " {\n" +
  184. " \"url\": \"https://tvbox.cainisi.cf\",\n" +
  185. " \"name\": \"菜妮丝\"\n" +
  186. " },\n" +
  187. " {\n" +
  188. " \"url\": \"http://home.jundie.top:81/top98.json\",\n" +
  189. " \"name\": \"俊佬\"\n" +
  190. " },\n" +
  191. " {\n" +
  192. " \"url\": \"https://xhdwc.tk/0\",\n" +
  193. " \"name\": \"Ray明\"\n" +
  194. " },\n" +
  195. " {\n" +
  196. " \"url\": \"https://xhdwc.tk/0\",\n" +
  197. " \"name\": \"dxzwi0\"\n" +
  198. " },\n" +
  199. " {\n" +
  200. " \"url\": \"https://raw.liucn.cc/box/m.json\",\n" +
  201. " \"name\": \"老刘备\"\n" +
  202. " },\n" +
  203. " {\n" +
  204. " \"url\": \"https://cn.kstore.space/download/2863/01.txt\",\n" +
  205. " \"name\": \"潇洒\"\n" +
  206. " },\n" +
  207. " {\n" +
  208. " \"url\": \"https://cn.kstore.space/download/2883/0110.txt\",\n" +
  209. " \"name\": \"蚂蚁\"\n" +
  210. " },\n" +
  211. " {\n" +
  212. " \"url\": \"http://tv.nxog.top/m/111.php?ou=%E6%AC%A7%E6%AD%8C&mz=index2&xl=&jar=index2\",\n" +
  213. " \"name\": \"欧歌\"\n" +
  214. " },\n" +
  215. " {\n" +
  216. " \"url\": \"http://52pan.top:81/api/v3/file/get/174964/%E5%90%BE%E7%88%B1%E8%AF%84%E6%B5%8B.m3u?sign=rPssLoffquDXszCARt6UNF8MobSa1FA27XomzOluJBY%3D%3A0\",\n" +
  217. " \"name\": \"吾爱\"\n" +
  218. " },\n" +
  219. " {\n" +
  220. " \"url\": \"http://itvbox.cc/tvbox/云星日记/1.m3u8\",\n" +
  221. " \"name\": \"云星日记\"\n" +
  222. " },\n" +
  223. " {\n" +
  224. " \"url\": \"http://meowtv.cn/tv\",\n" +
  225. " \"name\": \"喵影视\"\n" +
  226. " },\n" +
  227. " {\n" +
  228. " \"url\": \"https://notabug.org/qizhen15800/My9394/raw/master/ProfessionalEdition.m3u8\",\n" +
  229. " \"name\": \"不良帅\"\n" +
  230. " },\n" +
  231. " {\n" +
  232. " \"url\": \"https://www.macms.pro/box/3.json\",\n" +
  233. " \"name\": \"万达\"\n" +
  234. " },\n" +
  235. " {\n" +
  236. " \"url\": \"https://szyyds.cn/tv/x.json\",\n" +
  237. " \"name\": \"小马\"\n" +
  238. " },\n" +
  239. " {\n" +
  240. " \"url\": \"https://gh-proxy.com/https://raw.githubusercontent.com/yydfys/yydf/main/yydf/yydfjk.json\",\n" +
  241. " \"name\": \"业余打发\"\n" +
  242. " },\n" +
  243. " {\n" +
  244. " \"url\": \"http://rihou.cc:88/荷城茶秀\",\n" +
  245. " \"name\": \"荷城茶秀\"\n" +
  246. " },\n" +
  247. " {\n" +
  248. " \"url\": \"http://tt.iitvba.com/vip/tv.json\",\n" +
  249. " \"name\": \"iitvba\"\n" +
  250. " },\n" +
  251. " {\n" +
  252. " \"url\": \"http://tv.奥利给.top\",\n" +
  253. " \"name\": \"茄子库线路\"\n" +
  254. " },\n" +
  255. " {\n" +
  256. " \"url\": \"http://xhztv.top/xhz\",\n" +
  257. " \"name\": \"小盒子\"\n" +
  258. " },\n" +
  259. " {\n" +
  260. " \"url\": \"http://xhztv.top/4k.json\",\n" +
  261. " \"name\": \"4k接口\"\n" +
  262. " },\n" +
  263. " {\n" +
  264. " \"url\": \"http://清清.摸鱼儿.top\",\n" +
  265. " \"name\": \"失眠的夜\"\n" +
  266. " },\n" +
  267. " {\n" +
  268. " \"url\": \"http://meowtv.top/tv\",\n" +
  269. " \"name\": \"喵影视\"\n" +
  270. " },\n" +
  271. " {\n" +
  272. " \"url\": \"https://100km.top/0\",\n" +
  273. " \"name\": \"骚零\"\n" +
  274. " },\n" +
  275. " {\n" +
  276. " \"url\": \"https://gh-proxy.com/https://raw.githubusercontent.com/gaotianliuyun/gao/master/js.json\",\n" +
  277. " \"name\": \"高天流云\"\n" +
  278. " },\n" +
  279. " {\n" +
  280. " \"url\": \"http://sinopacifichk.com/box/56.txt\",\n" +
  281. " \"name\": \"太平洋\"\n" +
  282. " },\n" +
  283. " {\n" +
  284. " \"url\": \"https://jihulab.com/yueer/yueera/-/raw/main/11.17/yueer.json\",\n" +
  285. " \"name\": \"月儿\"\n" +
  286. " },\n" +
  287. " {\n" +
  288. " \"url\": \"https://wds.ecsxs.com/230989.json\",\n" +
  289. " \"name\": \"春盈\"\n" +
  290. " },\n" +
  291. " {\n" +
  292. " \"url\": \"http://cdn.qiaoji8.com/tvbox.json\",\n" +
  293. " \"name\": \"巧计\"\n" +
  294. " },\n" +
  295. " {\n" +
  296. " \"url\": \"http://www.wya6.cn/tv/yc.json\",\n" +
  297. " \"name\": \"无意\"\n" +
  298. " },\n" +
  299. " {\n" +
  300. " \"name\": \"\uD83E\uDD20潇洒仓\",\n" +
  301. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/SCXSVIP/TV/main/01.txt\"\n" +
  302. " },\n" +
  303. " {\n" +
  304. " \"name\": \"\uD83C\uDF5A饭太硬\",\n" +
  305. " \"url\": \"http://饭太硬.com/tv\"\n" +
  306. " },\n" +
  307. " {\n" +
  308. " \"name\": \"\uD83D\uDC3C肥猫源\",\n" +
  309. " \"url\": \"http://肥猫.com\"\n" +
  310. " },\n" +
  311. " {\n" +
  312. " \"name\": \"\uD83D\uDE9A运输车\",\n" +
  313. " \"url\": \"https://weixine.net/ysc.json\"\n" +
  314. " },\n" +
  315. " {\n" +
  316. " \"name\": \"\uD83E\uDD35高天仓\",\n" +
  317. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/gaotianliuyun/gao/master/js.json\"\n" +
  318. " },\n" +
  319. " {\n" +
  320. " \"name\": \"\uD83C\uDF2A南风\",\n" +
  321. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/yoursmile66/TVBox/main/XC.json\"\n" +
  322. " },\n" +
  323. " {\n" +
  324. " \"name\": \"\uD83D\uDC1F摸鱼儿\",\n" +
  325. " \"url\": \"http://我不是.摸鱼儿.top\"\n" +
  326. " },\n" +
  327. " {\n" +
  328. " \"name\": \"\uD83D\uDC4COK仓\",\n" +
  329. " \"url\": \"https://gitee.com/okjack/okk/raw/master/ok.txt\"\n" +
  330. " },\n" +
  331. " {\n" +
  332. " \"name\": \"\uD83D\uDCFD影视仓\",\n" +
  333. " \"url\": \"https://download.kstore.space/download/2883/nzk/nzk0722.json\"\n" +
  334. " },\n" +
  335. " {\n" +
  336. " \"name\": \"\uD83C\uDF19月光源\",\n" +
  337. " \"url\": \"https://gitlab.com/guot55/bh/-/raw/main/pro.json\"\n" +
  338. " },\n" +
  339. " {\n" +
  340. " \"name\": \"\uD83D\uDDC3\uFE0E宝盒源\",\n" +
  341. " \"url\": \"https://gitlab.com/guot55/bh/-/raw/main/box%E5%8E%9F.json\"\n" +
  342. " },\n" +
  343. " {\n" +
  344. " \"name\": \"\uD83C\uDF12月光宝盒\",\n" +
  345. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/guot55/YGBH/main/pro.json\"\n" +
  346. " },\n" +
  347. " {\n" +
  348. " \"name\": \"\uD83E\uDD35老刘备\",\n" +
  349. " \"url\": \"https://raw.liucn.cc/box/m.json\"\n" +
  350. " },\n" +
  351. " {\n" +
  352. " \"name\": \"\uD83D\uDC1D契斯特\",\n" +
  353. " \"url\": \"https://qist.tycng.com/jsm.json\"\n" +
  354. " },\n" +
  355. " {\n" +
  356. " \"name\": \"\uD83C\uDFA4欧歌主线\",\n" +
  357. " \"url\": \"http://tv.nxog.top/m/111.php?ou=欧歌&mz=index2&xl=&jar=index2\"\n" +
  358. " },\n" +
  359. " {\n" +
  360. " \"name\": \"\uD83D\uDC96念心线路\",\n" +
  361. " \"url\": \"https://gitee.com/nianxinxz/miao/raw/master/tvbox.json\"\n" +
  362. " },\n" +
  363. " {\n" +
  364. " \"name\": \"\uD83D\uDD2F忙忙软件\",\n" +
  365. " \"url\": \"https://www.gitlink.org.cn/api/Mrjkmm/MMRJK/raw/MMTV.json?ref=master\"\n" +
  366. " },\n" +
  367. " {\n" +
  368. " \"name\": \"➰\uFE0F环宇轩\",\n" +
  369. " \"url\": \"https://gitee.com/hyxuan_admin/xnf/raw/master/xnf.json\"\n" +
  370. " },\n" +
  371. " {\n" +
  372. " \"name\": \"❦缝纫机\",\n" +
  373. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/kunkka1986/my.img/main/frjbox.json\"\n" +
  374. " },\n" +
  375. " {\n" +
  376. " \"name\": \"\uD83D\uDD25amin\",\n" +
  377. " \"url\": \"https://d.kstore.space/download/7587/amin.json\"\n" +
  378. " },\n" +
  379. " {\n" +
  380. " \"name\": \"\uD83C\uDF29\uFE0F雷蒙影视\",\n" +
  381. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/n3rddd/N3RD/master/JN/lem.json\"\n" +
  382. " },\n" +
  383. " {\n" +
  384. " \"name\": \"\uD83C\uDF2E小武哥\",\n" +
  385. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/wwb521/live/main/movies.json\"\n" +
  386. " },\n" +
  387. " {\n" +
  388. " \"name\": \"\uD83C\uDF1F时光源\",\n" +
  389. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/xmbjm/xmbjm/main/api.json\"\n" +
  390. " },\n" +
  391. " {\n" +
  392. " \"name\": \"\uD83D\uDCDA拾光畅谈\",\n" +
  393. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/xmbjm/xmbjmjk/main/xmbjm.json\"\n" +
  394. " },\n" +
  395. " {\n" +
  396. " \"name\": \"☃\uFE0FPG源\",\n" +
  397. " \"url\": \"https://g.3344550.xyz/raw.githubusercontent.com/aaaafeng123/PG/main/jsm.json\"\n" +
  398. " },\n" +
  399. " {\n" +
  400. " \"name\": \"\uD83D\uDC27PizazzGY\",\n" +
  401. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/PizazzGY/TVBox/main/api.json\"\n" +
  402. " },\n" +
  403. " {\n" +
  404. " \"name\": \"\uD83E\uDD89恩惠源\",\n" +
  405. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/shichuanenhui/TvBox/main/fty.json\"\n" +
  406. " },\n" +
  407. " {\n" +
  408. " \"name\": \"\uD83E\uDD4B其人之道\",\n" +
  409. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/qirenzhidao/tvbox18/main/app.json\"\n" +
  410. " },\n" +
  411. " {\n" +
  412. " \"name\": \"\uD83E\uDD13GH-alantang1977\",\n" +
  413. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/alantang1977/X/main/X.json\"\n" +
  414. " },\n" +
  415. " {\n" +
  416. " \"name\": \"\uD83C\uDFBDGH-小牛动漫\",\n" +
  417. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/ls125781003/tvboxtg/main/%E5%8A%A8%E6%BC%AB%E9%A2%91%E9%81%93/api.json\"\n" +
  418. " },\n" +
  419. " {\n" +
  420. " \"name\": \"\uD83E\uDDD2\uD83C\uDFFBGH-小牛少儿\",\n" +
  421. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/ls125781003/tvboxtg/main/%E5%B0%91%E5%84%BF%E9%A2%91%E9%81%93/api.json\"\n" +
  422. " },\n" +
  423. " {\n" +
  424. " \"name\": \"\uD83C\uDF4BGH-qist(OK影视)\",\n" +
  425. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/qist/tvbox/master/0821.json\"\n" +
  426. " },\n" +
  427. " {\n" +
  428. " \"name\": \"\uD83C\uDF44GH-cyao2q\",\n" +
  429. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/cyao2q/files/master/n.json\"\n" +
  430. " },\n" +
  431. " {\n" +
  432. " \"name\": \"\uD83E\uDDFBGH-anaer\",\n" +
  433. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/anaer/Meow/main/meow.json\"\n" +
  434. " },\n" +
  435. " {\n" +
  436. " \"name\": \"\uD83D\uDCA6GH-aaliluya1977\",\n" +
  437. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/aliluya1977/TVBox/master/shg.json\"\n" +
  438. " },\n" +
  439. " {\n" +
  440. " \"name\": \"\uD83D\uDC96GH-andyMuj\",\n" +
  441. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/CandyMuj/ResourceInterface/main/TVBox/candymuj.json\"\n" +
  442. " },\n" +
  443. " {\n" +
  444. " \"name\": \"\uD83C\uDF4AGH-hackyjso(橘子柚)\",\n" +
  445. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/hackyjso/TVbox/main/jzy.txt\"\n" +
  446. " },\n" +
  447. " {\n" +
  448. " \"name\": \"\uD83D\uDC3BGH-xiongjian\",\n" +
  449. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/xiongjian83/TvBox/main/X.json\"\n" +
  450. " },\n" +
  451. " {\n" +
  452. " \"name\": \"\uD83D\uDD0CGH-bestpvp(插兜)\",\n" +
  453. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/bestpvp/tm/main/source/stable/main.json\"\n" +
  454. " },\n" +
  455. " {\n" +
  456. " \"name\": \"\uD83D\uDC54GH-wwb521\",\n" +
  457. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/wwb521/live/main/movies.json\"\n" +
  458. " },\n" +
  459. " {\n" +
  460. " \"name\": \"\uD83D\uDE3BT00700\",\n" +
  461. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/T00700/TVBoxSE/master/FongMi.json\"\n" +
  462. " },\n" +
  463. " {\n" +
  464. " \"name\": \"\uD83E\uDD65莫名的悲伤\",\n" +
  465. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/Dong-learn9/TVBox-zyjk/main/tvbox2.json\"\n" +
  466. " },\n" +
  467. " {\n" +
  468. " \"name\": \"\uD83E\uDD85网游鹰\",\n" +
  469. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/aa123jg/tvbox/main/wyyk/wyyk.json\"\n" +
  470. " },\n" +
  471. " {\n" +
  472. " \"name\": \"\uD83D\uDC09小白龙\",\n" +
  473. " \"url\": \"http://39.101.135.137:8080\"\n" +
  474. " },\n" +
  475. " {\n" +
  476. " \"name\": \"\uD83C\uDF0Baliluya1977\",\n" +
  477. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/aliluya1977/TVBox/master/shg.json\"\n" +
  478. " },\n" +
  479. " {\n" +
  480. " \"name\": \"\uD83C\uDF34多多影音\",\n" +
  481. " \"url\": \"https://gitee.com/shangyunvip/shangyunvipdc/raw/master/duoduo/dduo.json\"\n" +
  482. " },\n" +
  483. " {\n" +
  484. " \"name\": \"\uD83C\uDFA1业余打发\",\n" +
  485. " \"url\": \"http://yydf.540734621.xyz/QQ/yydf.json\"\n" +
  486. " },\n" +
  487. " {\n" +
  488. " \"name\": \"\uD83C\uDDF9天微线路\",\n" +
  489. " \"url\": \"https://gitee.com/tvkj/tw/raw/main/svip.json\"\n" +
  490. " },\n" +
  491. " {\n" +
  492. " \"name\": \"\uD83C\uDF38西夏影视\",\n" +
  493. " \"url\": \"https://d.kstore.space/download/2912/0318.json\"\n" +
  494. " },\n" +
  495. " {\n" +
  496. " \"name\": \"\uD83C\uDF39爱尚影视\",\n" +
  497. " \"url\": \"https://gitee.com/hailin886/fty/raw/master/tvbox/aishang.json\"\n" +
  498. " },\n" +
  499. " {\n" +
  500. " \"name\": \"\uD83C\uDF44挺好线路\",\n" +
  501. " \"url\": \"http://ztha.top/TVBox/thdjk.json\"\n" +
  502. " },\n" +
  503. " {\n" +
  504. " \"name\": \"\uD83D\uDCDB整挺好啊\",\n" +
  505. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/ZTHA000/tvbox/main/thzx1.json\"\n" +
  506. " },\n" +
  507. " {\n" +
  508. " \"name\": \"⭐恒星资料网\",\n" +
  509. " \"url\": \"https://gitee.com/heng546199810/hxvip8/raw/master/hxvip3.txt\"\n" +
  510. " },\n" +
  511. " {\n" +
  512. " \"name\": \"\uD83D\uDC3A猎狼\",\n" +
  513. " \"url\": \"https://yyds.lltv8.top/yyds.json\"\n" +
  514. " },\n" +
  515. " {\n" +
  516. " \"name\": \"\uD83D\uDC1F摸鱼\",\n" +
  517. " \"url\": \"https://jihulab.com/moyuer/momoyu/-/raw/main/moyu.json\"\n" +
  518. " },\n" +
  519. " {\n" +
  520. " \"name\": \"\uD83E\uDD89夜猫子\",\n" +
  521. " \"url\": \"https://jihulab.com/ymz1231/xymz/-/raw/main/ymz\"\n" +
  522. " },\n" +
  523. " {\n" +
  524. " \"name\": \"\uD83C\uDF3A春盈天下\",\n" +
  525. " \"url\": \"https://wds.ecsxs.com/230989.json\"\n" +
  526. " },\n" +
  527. " {\n" +
  528. " \"name\": \"\uD83C\uDF12月儿\",\n" +
  529. " \"url\": \"https://jihulab.com/yueer/yueera/-/raw/main/11.17/yueer.json\"\n" +
  530. " },\n" +
  531. " {\n" +
  532. " \"name\": \"\uD83D\uDC60万达\",\n" +
  533. " \"url\": \"https://www.macms.pro/box/3.json\"\n" +
  534. " },\n" +
  535. " {\n" +
  536. " \"name\": \"\uD83C\uDFAC影探\",\n" +
  537. " \"url\": \"http://www.lyyytv.cn/yt/yt.json\"\n" +
  538. " },\n" +
  539. " {\n" +
  540. " \"name\": \"\uD83E\uDD96龙门影视1\",\n" +
  541. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/lmclub/box/main/app/conf/tv.json\"\n" +
  542. " },\n" +
  543. " {\n" +
  544. " \"name\": \"\uD83D\uDC9E乐享汇J\",\n" +
  545. " \"url\": \"https://jihulab.com/lxhfans/TV/-/raw/master/tv.txt\"\n" +
  546. " },\n" +
  547. " {\n" +
  548. " \"name\": \"\uD83C\uDF1F乐享汇G\",\n" +
  549. " \"url\": \"https://g.3344550.xyz/raw.githubusercontent.com/lxhfans/TV/master/tv.txt\"\n" +
  550. " },\n" +
  551. " {\n" +
  552. " \"name\": \"\uD83C\uDF9E短剧剧集\",\n" +
  553. " \"url\": \"https://g.3344550.xyz/raw.githubusercontent.com/lxhfans/TV/master/duanju.json\"\n" +
  554. " },\n" +
  555. " {\n" +
  556. " \"name\": \"\uD83C\uDF6F蜂蜜1\",\n" +
  557. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/config.json\"\n" +
  558. " },\n" +
  559. " {\n" +
  560. " \"name\": \"\uD83D\uDC95全部4K\",\n" +
  561. " \"url\": \"https://codeberg.org/hengxing/hx/raw/branch/main/qb4k.txt\"\n" +
  562. " },\n" +
  563. " {\n" +
  564. " \"name\": \"\uD83C\uDFDA万达影视\",\n" +
  565. " \"url\": \"http://sinopacifichk.com/box/56.txt\"\n" +
  566. " },\n" +
  567. " {\n" +
  568. " \"name\": \"\uD83D\uDC7F心魔线路\",\n" +
  569. " \"url\": \"https://jihulab.com/yw88075/tvbox/-/raw/main/dr/js.json\"\n" +
  570. " },\n" +
  571. " {\n" +
  572. " \"name\": \"\uD83D\uDC3C熊猫不是猫\",\n" +
  573. " \"url\": \"https://jihulab.com/yw88075/tvbox/-/raw/main/dr/js.json\"\n" +
  574. " },\n" +
  575. " {\n" +
  576. " \"name\": \"✨\uFE0F壹梦在线\",\n" +
  577. " \"url\": \"http://qrh.yimkj.cn/ym/%E5%A3%B9%E6%A2%A6.json\"\n" +
  578. " },\n" +
  579. " {\n" +
  580. " \"name\": \"\uD83C\uDF40俊宇\",\n" +
  581. " \"url\": \"http://home.jundie.top:81/top98.json\"\n" +
  582. " },\n" +
  583. " {\n" +
  584. " \"name\": \"\uD83D\uDE1D非凡\",\n" +
  585. " \"url\": \"https://codeberg.org/jgfx/master/raw/branch/master/ff1130.json\"\n" +
  586. " },\n" +
  587. " {\n" +
  588. " \"name\": \"\uD83C\uDF43霜辉月明\",\n" +
  589. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/lm317379829/PyramidStore/pyramid/py.json\"\n" +
  590. " },\n" +
  591. " {\n" +
  592. " \"name\": \"\uD83E\uDDFBzhixc\",\n" +
  593. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/zhixc/CatVodTVSpider/main/json/tvbox_config.json\"\n" +
  594. " },\n" +
  595. " {\n" +
  596. " \"name\": \"\uD83D\uDCFAlystv\",\n" +
  597. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/lystv/short/main/%E5%BD%B1%E8%A7%86/cs.json\"\n" +
  598. " },\n" +
  599. " {\n" +
  600. " \"name\": \"\uD83D\uDC36二哈\",\n" +
  601. " \"url\": \"https://g.3344550.xyz/https://raw.githubusercontent.com/2hacc/TVBox/main/tvbox.json\"\n" +
  602. " },\n" +
  603. " {\n" +
  604. " \"name\": \"\uD83D\uDEE1大卫º\",\n" +
  605. " \"url\": \"https://dxawi.github.io/0/0.json\"\n" +
  606. " },\n" +
  607. " {\n" +
  608. " \"name\": \"\uD83D\uDC31喵呜\",\n" +
  609. " \"url\": \"https://anaer.github.io/Meow/meow.json\"\n" +
  610. " },\n" +
  611. " {\n" +
  612. " \"name\": \"\uD83D\uDCA6巧技2\",\n" +
  613. " \"url\": \"http://pandown.pro/tvbox/tvbox.json\"\n" +
  614. " },\n" +
  615. " {\n" +
  616. " \"name\": \"\uD83D\uDD18心魔\",\n" +
  617. " \"url\": \"https://jihulab.com/yw88075/tvbox/-/raw/main/ywxl.json\"\n" +
  618. " },\n" +
  619. " {\n" +
  620. " \"name\": \"\uD83D\uDC9D恋影\",\n" +
  621. " \"url\": \"https://www.lianyingtv.com/fast/fast\"\n" +
  622. " }\n" +
  623. " ]\n" +
  624. "}";
  625. List<UrlObject> urlObjects = convertToObjectList(json);
  626. //输出不能访问的url
  627. // List<UrlObject> unreachableUrls = new ArrayList<>();
  628. // long timeoutMillis = 10000;
  629. // for (int i = 0; i < urlObjects.size(); i++) {
  630. // UrlObject obj = urlObjects.get(i);
  631. // if (!accessUrl(obj.getUrl(), timeoutMillis)) {
  632. // unreachableUrls.add(obj);
  633. // urlObjects.remove(obj);
  634. // i--;
  635. // }
  636. // }
  637. // for (UrlObject obj : unreachableUrls) {
  638. // System.out.println(obj.getName() + " - " + obj.getUrl());
  639. // }
  640. // for (UrlObject obj : urlObjects) {
  641. // System.out.println(obj.getName() + " - " + obj.getUrl());
  642. // }
  643. //把能用的url重新转换为json
  644. long timeoutMillis = 5000;
  645. String resultJson = filterAndConvertToJson(urlObjects, timeoutMillis);
  646. System.out.println(resultJson);
  647. // System.out.println(urlObjects);
  648. }
  649. public static String filterAndConvertToJson(List<UrlObject> urlObjects, long timeoutMillis) {
  650. List<UrlObject> reachableUrls = new ArrayList<>();
  651. for (UrlObject obj : urlObjects) {
  652. if (accessUrl(obj.getUrl(), timeoutMillis)) {
  653. reachableUrls.add(obj);
  654. }
  655. }
  656. System.out.println("去重前:" + reachableUrls.size());
  657. List<Map<String, Object>> result = reachableUrls.stream()
  658. .map(obj -> {
  659. Map<String, Object> map = new HashMap<>();
  660. map.put("url", obj.getUrl());
  661. map.put("name", obj.getName());
  662. // 将其他属性添加到Map中
  663. return map;
  664. })
  665. .collect(Collectors.toList());
  666. System.out.println("去重后:" + result.size());
  667. StringBuilder json = new StringBuilder();
  668. json.append("{\"urls\":[");
  669. for (UrlObject urlObject : urlObjects) {
  670. // UrlObject reachableObj = reachableUrls.get(i);
  671. json.append("{\n");
  672. json.append(" \"name\": \"" + urlObject.getName() + "\",\n");
  673. json.append(" \"url\": \"" + urlObject.getUrl() + "\"\n");
  674. json.append("}");
  675. // if (i < reachableUrls.size() - 1) {
  676. json.append(",");
  677. // }
  678. }
  679. json.append("]}");
  680. return json.toString();
  681. }
  682. public static void getjson() throws IOException {
  683. String urlString = "http://itvbox.cc/云星日记"; // 替换为你的URL
  684. accessUrl(urlString, 500);
  685. }
  686. public static boolean accessUrl(String url, long timeoutMillis) {
  687. // String url1 = url;
  688. // if(containsChinese(url)) {
  689. // url1 = getPunycode(url);
  690. // }
  691. try {
  692. URL myUrl = new URL(url);
  693. // URLConnection connection = myUrl.openConnection();
  694. // //10 秒超时
  695. // connection.setConnectTimeout((int) timeoutMillis);
  696. // BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  697. // String inputLine;
  698. // while ((inputLine = in.readLine()) != null) {
  699. // //System.out.println(inputLine);
  700. // }
  701. // in.close();
  702. HttpURLConnection connection = (HttpURLConnection) myUrl.openConnection();
  703. //10秒超时
  704. connection.setConnectTimeout((int) timeoutMillis);
  705. connection.setReadTimeout((int) timeoutMillis);
  706. connection.setRequestMethod("HEAD"); // 使用 HEAD 方法减少数据传输
  707. int responseCode = connection.getResponseCode();
  708. // System.out.println("可以访问=====" + url);
  709. return true;
  710. } catch (IOException e) {
  711. System.out.println("不能访问=====" + url);
  712. return false;
  713. }
  714. }
  715. public static boolean containsChinese(String str) {
  716. Pattern pattern = Pattern.compile("[\u4E00-\u9FA5]");
  717. Matcher matcher = pattern.matcher(str);
  718. return matcher.find();
  719. }
  720. public static String getPunycode(String url) {
  721. // String punycodeString;
  722. // // 将Unicode字符串转换为Punycode字符串
  723. // punycodeString = Punycode.toPunycode(url);
  724. // System.out.println("Punycode: " + punycodeString);
  725. // return punycodeString;
  726. // String unicodeDomain = "例子.测试";
  727. String[] strings = url.split("//");
  728. try {
  729. String punycode = IDN.toASCII(strings[1]);
  730. // System.out.println(strings[0] + "//" + punycode); // 输出: http://xn--your-punycode-string-g1a.xn--com-w6g
  731. return strings[0] + "//" + punycode;
  732. } catch (Exception e) {
  733. e.printStackTrace();
  734. }
  735. return "";
  736. }
  737. }