cn.schoolwow.sdk.video.analyzer.YouKuAnalyzer Maven / Gradle / Ivy
package cn.schoolwow.sdk.video.analyzer;
import cn.schoolwow.quickhttp.QuickHttp;
import cn.schoolwow.quickhttp.request.Request;
import cn.schoolwow.quickhttp.response.Response;
import cn.schoolwow.sdk.util.RegExpUtil;
import cn.schoolwow.sdk.video.VideoUtil;
import cn.schoolwow.sdk.video.domain.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class YouKuAnalyzer extends AbstractAnalyzer {
private Logger logger = LoggerFactory.getLogger(YouKuAnalyzer.class);
private static final String ccode = "0532";
private static final String ckey = "7B19C0AB12633B22E7FE81271162026020570708D6CC189E4924503C49D243A0DE6CD84A766832C2C99898FC5ED31F3709BB3CDD82C96492E721BDD381735026";
@Override
public PlayList getPlaylist(String url) throws IOException {
//http://i.youku.com/u/UNTU1Mzg3Mzk2?
String vid = RegExpUtil.plainMatch(url, "/id_().html");
if(null==vid||vid.isEmpty()){
vid = RegExpUtil.plainMatch(url, "/u/()?");
}
if(null==vid||vid.isEmpty()){
throw new IllegalArgumentException("vid提取失败!url:"+url);
}
String api = "https://m.youku.com/video/id_" + vid + ".html";
Response response = QuickHttp.connect(api)
.userAgent(Request.UserAgent.ANDROID)
.execute();
String body = RegExpUtil.plainMatch(response.body(), "window.__INITIAL_DATA__ =();window.__PLATOCONFIG__");
JSONObject result = JSON.parseObject(body);
//解析播单信息
PlayList playList = new PlayList();
playList.tv = TV.YouKu;
playList.url = url;
JSONObject videoMap = result.getJSONObject("videoMap");
playList.name = videoMap.getString("showName");
playList.cover = videoMap.getString("showImgV");
playList.videoListSupplier = ()->{
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy