use of com.dante.data.model.BaseResult in project 91Pop by DanteAndroid.
the class ParsePigAv method moreVideoList.
public static BaseResult<List<PigAv>> moreVideoList(String html) {
BaseResult<List<PigAv>> baseResult = new BaseResult<>();
baseResult.setTotalPage(1);
Document doc = Jsoup.parse(html);
Elements items = doc.getElementsByClass("td-block-span4");
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.lastIndexOf("-");
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);
}
baseResult.setData(pigAvList);
return baseResult;
}
use of com.dante.data.model.BaseResult in project 91Pop by DanteAndroid.
the class AppApiHelper method action.
private Observable<BaseResult<List<MeiZiTu>>> action(Observable<String> stringObservable, String tag, final int page, final boolean pullToRefresh) {
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(tag, page);
EvictDynamicKeyGroup evictDynamicKeyGroup = new EvictDynamicKeyGroup(pullToRefresh);
return cacheProviders.meiZiTu(stringObservable, dynamicKeyGroup, evictDynamicKeyGroup).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> stringReply) throws Exception {
return stringReply.getData();
}
}).map(new Function<String, BaseResult<List<MeiZiTu>>>() {
@Override
public BaseResult<List<MeiZiTu>> apply(String s) throws Exception {
return ParseMeiZiTu.parseMzPosts(s, page);
}
});
}
use of com.dante.data.model.BaseResult in project 91Pop by DanteAndroid.
the class AppApiHelper method list99Mm.
@Override
public Observable<BaseResult<List<Mm99>>> list99Mm(String category, final int page, boolean cleanCache) {
String url = buildUrl(category, page);
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(category, page);
EvictDynamicKeyGroup evictDynamicKeyGroup = new EvictDynamicKeyGroup(cleanCache);
return cacheProviders.cacheWithLimitTime(mm99ServiceApi.imageList(url), dynamicKeyGroup, evictDynamicKeyGroup).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> stringReply) {
return stringReply.getData();
}
}).map(new Function<String, BaseResult<List<Mm99>>>() {
@Override
public BaseResult<List<Mm99>> apply(String s) {
return Parse99Mm.parse99MmList(s, page);
}
});
}
use of com.dante.data.model.BaseResult in project 91Pop by DanteAndroid.
the class AppApiHelper method loadPorn91MyFavoriteVideos.
@Override
public Observable<BaseResult<List<UnLimit91PornItem>>> loadPorn91MyFavoriteVideos(String userName, int page, boolean cleanCache) {
Observable<String> favoriteObservable = noLimit91PornServiceApi.myFavoriteVideo(page, HeaderUtils.getIndexHeader(addressHelper));
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(userName, page);
EvictDynamicKey evictDynamicKey = new EvictDynamicKey(cleanCache);
return cacheProviders.getFavorite(favoriteObservable, dynamicKeyGroup, evictDynamicKey).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> responseBody) throws Exception {
return responseBody.getData();
}
}).map(new Function<String, BaseResult<List<UnLimit91PornItem>>>() {
@Override
public BaseResult<List<UnLimit91PornItem>> apply(String s) throws Exception {
return Parse91PronVideo.parseMyFavorite(s);
}
});
}
use of com.dante.data.model.BaseResult in project 91Pop by DanteAndroid.
the class Parse91PronVideo method parseMyFavorite.
/**
* 解析我的收藏
*
* @param html html
* @return list
*/
public static BaseResult<List<UnLimit91PornItem>> parseMyFavorite(String html) {
int totalPage = 1;
List<UnLimit91PornItem> unLimit91PornItemList = new ArrayList<>();
Document doc = Jsoup.parse(html);
Element body = doc.getElementById("leftside");
Elements videos = doc.select("div.myvideo");
for (Element element : videos) {
UnLimit91PornItem unLimit91PornItem = new UnLimit91PornItem();
String contentUrl = element.select("a").first().attr("href");
String viewKey = contentUrl.substring(contentUrl.indexOf("=") + 1, contentUrl.length());
unLimit91PornItem.setViewKey(viewKey);
Logger.t(TAG).d(viewKey);
String title = element.select("strong").first().text();
unLimit91PornItem.setTitle(title);
Logger.t(TAG).d(title);
String imgUrl = element.select("img").first().attr("src");
unLimit91PornItem.setImgUrl(imgUrl);
Logger.t(TAG).d(imgUrl);
String allInfo = element.text();
Logger.t(TAG).d(allInfo);
String duration = allInfo.substring(allInfo.indexOf("时长") + 3, allInfo.indexOf("Views") - 3);
unLimit91PornItem.setDuration(duration);
Logger.t(TAG).d(duration);
String info = allInfo.substring(allInfo.indexOf("添加时间"), allInfo.length());
unLimit91PornItem.setInfo(info);
Logger.t(TAG).d(info);
String rvid = element.select("input").first().attr("value");
Logger.t(TAG).d("rvid::" + rvid);
VideoResult videoResult = new VideoResult();
videoResult.setId(VideoResult.OUT_OF_WATCH_TIMES);
videoResult.setVideoId(rvid);
unLimit91PornItem.setVideoResult(videoResult);
unLimit91PornItemList.add(unLimit91PornItem);
}
// 总页数
Element pagingnav = body.getElementById("paging");
Elements a = pagingnav.select("a");
if (a.size() >= 2) {
String ppp = a.get(a.size() - 2).text();
if (TextUtils.isDigitsOnly(ppp)) {
totalPage = Integer.parseInt(ppp);
Logger.d("总页数:" + totalPage);
}
}
BaseResult<List<UnLimit91PornItem>> baseResult = new BaseResult<>();
// 尝试解析删除信息
Elements msgElements = doc.select("div.msgbox");
if (msgElements != null) {
String msgInfo = msgElements.text();
if (!TextUtils.isEmpty(msgInfo)) {
baseResult.setCode(BaseResult.SUCCESS_CODE);
baseResult.setMessage(msgInfo);
}
} else {
String errorMsg = parseErrorInfo(html);
if (!TextUtils.isEmpty(errorMsg)) {
baseResult.setMessage(errorMsg);
baseResult.setCode(BaseResult.ERROR_CODE);
}
}
baseResult.setTotalPage(totalPage);
baseResult.setData(unLimit91PornItemList);
return baseResult;
}
Aggregations