use of com.dante.data.model.PigAvVideo in project 91Pop by DanteAndroid.
the class ParsePigAv method parserVideoUrl.
/**
* @param html 原网页
* @return json===
*/
public static BaseResult<PigAvVideo> parserVideoUrl(String html) {
BaseResult<PigAvVideo> baseResult = new BaseResult<>();
Document document = Jsoup.parse(html);
Element videoWrapper = document.getElementsByClass("td-post-content td-pb-padding-side").first();
String videoHtml = videoWrapper.html();
Logger.t(TAG).d(videoHtml);
int index = videoHtml.indexOf("setup") + 6;
int endIndexV = videoHtml.indexOf(");");
String videoUrl = videoHtml.substring(index, endIndexV);
Logger.t(TAG).d(videoUrl);
PigAvVideo pigAvVideo = new Gson().fromJson(videoUrl, PigAvVideo.class);
Elements items = document.getElementsByClass("td-block-span12");
List<PigAv> pigAvList = new ArrayList<>();
for (Element element : items) {
PigAv pigAv = new PigAv();
Element a = element.selectFirst("a");
String title = a.attr("title");
pigAv.setTitle(title);
String contentUrl = a.attr("href");
pigAv.setContentUrl(contentUrl);
Element img = element.selectFirst("img");
String imgUrl = img.attr("src");
int beginIndex = imgUrl.lastIndexOf("/");
int endIndex = imgUrl.indexOf("-");
String bigImg = StringUtils.subString(imgUrl, 0, endIndex);
if (TextUtils.isEmpty(bigImg)) {
pigAv.setImgUrl(imgUrl);
} else {
pigAv.setImgUrl(bigImg + ".jpg");
}
String pId = StringUtils.subString(imgUrl, beginIndex + 1, endIndex);
Logger.t(TAG).d(pId);
pigAv.setpId(pId);
int imgWidth = Integer.parseInt(img.attr("width"));
pigAv.setImgWidth(imgWidth);
int imgHeight = Integer.parseInt(img.attr("height"));
pigAv.setImgHeight(imgHeight);
pigAvList.add(pigAv);
}
pigAvVideo.setPigAvList(pigAvList);
baseResult.setData(pigAvVideo);
return baseResult;
}
use of com.dante.data.model.PigAvVideo in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPigAvVideoUrl.
@Override
public Observable<PigAvVideo> loadPigAvVideoUrl(String url, String pId, boolean pullToRefresh) {
if (TextUtils.isEmpty(pId)) {
pId = "aaa1";
pullToRefresh = true;
}
DynamicKey dynamicKey = new DynamicKey(pId);
return cacheProviders.cacheWithNoLimitTime(pigAvServiceApi.pigAvVideoUrl(url), dynamicKey, new EvictDynamicKey(pullToRefresh)).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> stringReply) throws Exception {
return stringReply.getData();
}
}).map(new Function<String, PigAvVideo>() {
@Override
public PigAvVideo apply(String s) throws Exception {
return ParsePigAv.parserVideoUrl(s).getData();
}
});
}
Aggregations