Fix build
This commit is contained in:
parent
26ab3923e6
commit
3f5eae4da9
|
|
@ -15,3 +15,4 @@ dependencyResolutionManagement {
|
|||
}
|
||||
rootProject.name = "CatVodSpider"
|
||||
include ':app'
|
||||
include ':tools'
|
||||
|
|
|
|||
|
|
@ -1,18 +1,10 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = 'UTF-8'
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
data.json 為對應表,可依據需求新增修改 epg、name、logo。
|
||||
1. 執行 run.bat
|
||||
2. 輸入直播文本網址或檔名
|
||||
3. 自動產出 live.json
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1 +0,0 @@
|
|||
java -jar run.jar
|
||||
Binary file not shown.
|
|
@ -1 +0,0 @@
|
|||
rootProject.name = 'tools'
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: com.fongmi.tools.Run
|
||||
|
|
@ -12,96 +12,89 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Run {
|
||||
|
||||
private final List<Group> groups;
|
||||
private final List<Data> data;
|
||||
private final Gson gson;
|
||||
private final List<Group> groups;
|
||||
private final List<Data> data;
|
||||
private final Gson gson;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length > 0) {
|
||||
new Run().start(args[0]);
|
||||
} else {
|
||||
System.out.print("請輸入網址或檔名:");
|
||||
new Run().start(new Scanner(System.in).nextLine());
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) throws IOException {
|
||||
new Run().start("http://home.jundie.top:81/Cat/tv/live.txt");
|
||||
}
|
||||
|
||||
public Run() {
|
||||
groups = new ArrayList<>();
|
||||
data = Data.arrayFrom(Util.getFile("data.json"));
|
||||
gson = new Gson().newBuilder().disableHtmlEscaping().setPrettyPrinting().create();
|
||||
}
|
||||
public Run() {
|
||||
groups = new ArrayList<>();
|
||||
data = Data.arrayFrom(Util.getFile(getClass(), "data.json"));
|
||||
gson = new Gson().newBuilder().disableHtmlEscaping().setPrettyPrinting().create();
|
||||
}
|
||||
|
||||
private void start(String text) throws IOException {
|
||||
if (text.startsWith("http")) parse(Util.call(text));
|
||||
else parse(Util.getFile(text));
|
||||
//parseTxt(Util.getFile(getClass(), "live.txt"));
|
||||
writeFile();
|
||||
}
|
||||
private void start(String text) throws IOException {
|
||||
//parseTxt(Util.getFile(getClass(), "live.txt"));
|
||||
parse(Util.call(text));
|
||||
writeFile();
|
||||
}
|
||||
|
||||
private void parse(String text) {
|
||||
for (String line : text.split("\n")) {
|
||||
String[] split = line.split(",");
|
||||
if (split.length < 2) continue;
|
||||
if (line.contains("#genre#")) groups.add(Group.create(split[0]));
|
||||
if (split[1].contains("://")) {
|
||||
Group group = groups.get(groups.size() - 1);
|
||||
String name = split[0];
|
||||
String url = split[1].trim();
|
||||
group.find(Channel.create().name(name).epg(name)).addUrls(url.split("#"));
|
||||
}
|
||||
}
|
||||
int number = 0;
|
||||
for (Group group : groups) {
|
||||
for (Channel channel : group.getChannel()) {
|
||||
channel.number(String.format(Locale.getDefault(), "%03d", ++number));
|
||||
combine(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void parse(String text) {
|
||||
for (String line : text.split("\n")) {
|
||||
String[] split = line.split(",");
|
||||
if (split.length < 2) continue;
|
||||
if (line.contains("#genre#")) groups.add(Group.create(split[0]));
|
||||
if (split[1].contains("://")) {
|
||||
Group group = groups.get(groups.size() - 1);
|
||||
String name = split[0];
|
||||
String url = split[1].trim();
|
||||
group.find(Channel.create().name(name).epg(name)).addUrls(url.split("#"));
|
||||
}
|
||||
}
|
||||
int number = 0;
|
||||
for (Group group : groups) {
|
||||
for (Channel channel : group.getChannel()) {
|
||||
channel.number(String.format(Locale.getDefault(), "%03d", ++number));
|
||||
combine(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void parseTxt(String text) {
|
||||
for (String line : text.split("\n")) {
|
||||
String[] split = line.split(",");
|
||||
if (split.length < 2) continue;
|
||||
if (line.contains("#genre#")) groups.add(Group.create(split[0]));
|
||||
if (!line.contains("://")) continue;
|
||||
Group group = groups.get(groups.size() - 1);
|
||||
String number = split[0];
|
||||
String epg = split[1];
|
||||
String logo = split[2];
|
||||
String name = split[3];
|
||||
String url = split[4];
|
||||
group.find(Channel.create().number(number).epg(epg).logo(logo).name(name).ua(getUa(url))).addUrls(url.split("#"));
|
||||
}
|
||||
}
|
||||
private void parseTxt(String text) {
|
||||
for (String line : text.split("\n")) {
|
||||
String[] split = line.split(",");
|
||||
if (split.length < 2) continue;
|
||||
if (line.contains("#genre#")) groups.add(Group.create(split[0]));
|
||||
if (!line.contains("://")) continue;
|
||||
Group group = groups.get(groups.size() - 1);
|
||||
String number = split[0];
|
||||
String epg = split[1];
|
||||
String logo = split[2];
|
||||
String name = split[3];
|
||||
String url = split[4];
|
||||
group.find(Channel.create().number(number).epg(epg).logo(logo).name(name).ua(getUa(url))).addUrls(url.split("#"));
|
||||
}
|
||||
}
|
||||
|
||||
private void combine(Channel channel) {
|
||||
for (Data item : data) {
|
||||
if (item.getName().contains(channel.getName())) {
|
||||
channel.logo(item.getLogo());
|
||||
channel.epg(item.getEpg());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void combine(Channel channel) {
|
||||
for (Data item : data) {
|
||||
if (item.getName().contains(channel.getName())) {
|
||||
channel.logo(item.getLogo());
|
||||
channel.epg(item.getEpg());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getUa(String url) {
|
||||
if (url.contains("play-live.ifeng")) return "okhttp/3.15";
|
||||
return null;
|
||||
}
|
||||
private String getUa(String url) {
|
||||
if (url.contains("play-live.ifeng")) return "okhttp/3.15";
|
||||
return null;
|
||||
}
|
||||
|
||||
private void writeFile() {
|
||||
try {
|
||||
File file = new File("live.json");
|
||||
PrintWriter writer = new PrintWriter(file, String.valueOf(StandardCharsets.UTF_8));
|
||||
writer.println(gson.toJson(groups));
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private void writeFile() {
|
||||
try {
|
||||
File file = new File("json", "live.json");
|
||||
PrintWriter writer = new PrintWriter(file, String.valueOf(StandardCharsets.UTF_8));
|
||||
writer.println(gson.toJson(groups));
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue