|
|
|
|
@ -16,8 +16,6 @@ import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
import okhttp3.HttpUrl; |
|
|
|
|
|
|
|
|
|
public class XtreamCode extends Spider { |
|
|
|
|
|
|
|
|
|
private List<Group> groups; |
|
|
|
|
@ -32,6 +30,12 @@ public class XtreamCode extends Spider { |
|
|
|
|
@Override |
|
|
|
|
public String liveContent(String url) { |
|
|
|
|
config.setUrl(url); |
|
|
|
|
setChannel(); |
|
|
|
|
setNumber(); |
|
|
|
|
return new Gson().toJson(groups); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setChannel() { |
|
|
|
|
List<XCategory> categoryList = getCategoryList(config); |
|
|
|
|
List<XStream> streamList = getStreamList(config); |
|
|
|
|
Map<String, String> categoryMap = new HashMap<>(); |
|
|
|
|
@ -46,22 +50,19 @@ public class XtreamCode extends Spider { |
|
|
|
|
if (!stream.getEpgChannelId().isEmpty()) channel.setTvgName(stream.getEpgChannelId()); |
|
|
|
|
channel.getUrls().addAll(stream.getPlayUrl(config)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setNumber() { |
|
|
|
|
int number = 0; |
|
|
|
|
for (Group group : groups) { |
|
|
|
|
for (Channel channel : group.getChannel()) { |
|
|
|
|
if (channel.getNumber().isEmpty()) channel.setNumber(++number); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return new Gson().toJson(groups); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static HttpUrl.Builder getBuilder(Config config) { |
|
|
|
|
HttpUrl url = HttpUrl.parse(config.getUrl()); |
|
|
|
|
return new HttpUrl.Builder().scheme(url.scheme()).host(url.host()).port(url.port()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getApiUrl(Config config, String action) { |
|
|
|
|
return getBuilder(config).addPathSegment("player_api.php").addQueryParameter("username", config.getName()).addQueryParameter("password", config.getPass()).addQueryParameter("action", action).build().toString(); |
|
|
|
|
return config.getUrl().newBuilder().addQueryParameter("action", action).build().toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<XCategory> getLiveCategoryList(Config config) { |
|
|
|
|
@ -81,13 +82,15 @@ public class XtreamCode extends Spider { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<XCategory> getCategoryList(Config config) { |
|
|
|
|
List<XCategory> categoryList = getLiveCategoryList(config); |
|
|
|
|
List<XCategory> categoryList = new ArrayList<>(); |
|
|
|
|
if (config.isLive()) categoryList.addAll(getLiveCategoryList(config)); |
|
|
|
|
if (config.isVod()) categoryList.addAll(getVodCategoryList(config)); |
|
|
|
|
return categoryList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<XStream> getStreamList(Config config) { |
|
|
|
|
List<XStream> streamList = getLiveStreamList(config); |
|
|
|
|
List<XStream> streamList = new ArrayList<>(); |
|
|
|
|
if (config.isLive()) streamList.addAll(getLiveStreamList(config)); |
|
|
|
|
if (config.isVod()) streamList.addAll(getVodStreamList(config)); |
|
|
|
|
return streamList; |
|
|
|
|
} |
|
|
|
|
|