use of com.yausername.youtubedl_android.mapper.VideoInfo in project androidtv-news by anenasa.
the class Channel method parse.
void parse() throws JSONException, IOException, YoutubeDLException, InterruptedException {
String url = getUrl();
YoutubeDLRequest request;
if (url.startsWith("https://hamivideo.hinet.net/channel/") && url.endsWith(".do")) {
String id = url.substring(url.lastIndexOf("/") + 1, url.lastIndexOf("."));
OkHttpClient okHttpClient = new OkHttpClient();
Request okHttpRequest = new Request.Builder().url("https://hamivideo.hinet.net/api/play.do?freeProduct=1&id=" + id).build();
Response response = okHttpClient.newCall(okHttpRequest).execute();
JSONObject object = new JSONObject(response.body().string());
request = new YoutubeDLRequest(object.getString("url"));
} else {
request = new YoutubeDLRequest(url);
}
request.addOption("-f", getFormat());
if (!getHeader().isEmpty()) {
String[] headers = getHeader().split("\\\\r\\\\n");
for (String header : headers) {
request.addOption("--add-header", header);
}
}
VideoInfo streamInfo = YoutubeDL.getInstance().getInfo(request);
setVideo(streamInfo.getUrl());
}
Aggregations