Search in sources :

Example 1 with User

use of com.dante.data.model.User in project 91Pop by DanteAndroid.

the class AppApiHelper method userRegisterPorn91Video.

@Override
public Observable<User> userRegisterPorn91Video(String username, String password1, String password2, String email, String captchaInput) {
    String next = "";
    // String fingerprint = "2192328486";
    String fingerprint = UserHelper.randomFingerprint();
    String vip = "";
    String actionSignUp = "Sign Up";
    String submitX = "45";
    String submitY = "13";
    String ipAddress = addressHelper.getRandomIPAddress();
    return noLimit91PornServiceApi.register(next, username, password1, password2, email, captchaInput, fingerprint, vip, actionSignUp, submitX, submitY, HeaderUtils.getUserHeader(addressHelper, "signup"), ipAddress).retryWhen(new RetryWhenProcess(2)).map(new Function<String, User>() {

        @Override
        public User apply(String s) throws Exception {
            if (!UserHelper.isPornVideoLoginSuccess(s)) {
                String errorInfo = Parse91PronVideo.parseErrorInfo(s);
                throw new MessageException(errorInfo);
            }
            return Parse91PronVideo.parseUserInfo(s);
        }
    });
}
Also used : RetryWhenProcess(com.dante.rxjava.RetryWhenProcess) User(com.dante.data.model.User) MessageException(com.dante.exception.MessageException) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Example 2 with User

use of com.dante.data.model.User in project 91Pop by DanteAndroid.

the class Parse91PronVideo method parseUserInfo.

/**
 * 解析登录用户信息
 *
 * @return 用户
 */
public static User parseUserInfo(String html) {
    User user = new User();
    Document doc = Jsoup.parse(html);
    // 新帐号注册成功登录后信息不一样,导致无法解析
    Element element = doc.getElementById("userinfo-title");
    if (element == null) {
        return null;
    }
    // String userLinks = element.select("a").first().attr("href");
    // String userName = doc.getElementById("userinfo-title").select("a").first().text();
    String userAccountStatus = doc.getElementById("userinfo-title").select("font").first().text();
    String userName = doc.select("div#head a").first().text();
    String userLinksText = doc.select("div#usermenu p.myvideostat").first().toString();
    String userLinks = Jsoup.parse(userLinksText).select("a").first().attr("href");
    Logger.t(TAG).d(userAccountStatus);
    Logger.t(TAG).d(userName);
    int uid = Integer.parseInt(userLinks.substring(userLinks.indexOf("=") + 1, userLinks.length()));
    user.setUserId(uid);
    user.setStatus(userAccountStatus);
    user.setUserName(userName);
    Logger.t(TAG).d(uid);
    String userContent = doc.getElementById("userinfo-content").text();
    Logger.t(TAG).d(userContent);
    String lastLoginTime = userContent.substring(userContent.indexOf("最后登录"), userContent.indexOf("IP:"));
    String lastLoginIP = userContent.substring(userContent.indexOf("IP:"), userContent.indexOf("点此查看"));
    user.setLastLoginTime(lastLoginTime);
    user.setLastLoginIP(lastLoginIP);
    Logger.t(TAG).d(lastLoginTime);
    Logger.t(TAG).d(lastLoginIP);
    return user;
}
Also used : User(com.dante.data.model.User) Element(org.jsoup.nodes.Element) Document(org.jsoup.nodes.Document)

Example 3 with User

use of com.dante.data.model.User in project 91Pop by DanteAndroid.

the class AppApiHelper method userLoginPorn91Video.

@Override
public Observable<User> userLoginPorn91Video(String username, String password, String captcha) {
    String fingerprint = UserHelper.randomFingerprint();
    String fingerprint2 = UserHelper.randomFingerprint2();
    String actionLogin = "Log In";
    String x = "47";
    String y = "12";
    return noLimit91PornServiceApi.login(username, password, fingerprint, fingerprint2, captcha, actionLogin, x, y, HeaderUtils.getUserHeader(addressHelper, "login")).retryWhen(new RetryWhenProcess(2)).map(new Function<String, User>() {

        @Override
        public User apply(String s) throws Exception {
            if (!UserHelper.isPornVideoLoginSuccess(s)) {
                String errorInfo = Parse91PronVideo.parseErrorInfo(s);
                if (TextUtils.isEmpty(errorInfo)) {
                    errorInfo = "未知错误,请确认地址是否正确";
                }
                throw new MessageException(errorInfo);
            }
            return Parse91PronVideo.parseUserInfo(s);
        }
    });
}
Also used : RetryWhenProcess(com.dante.rxjava.RetryWhenProcess) User(com.dante.data.model.User) MessageException(com.dante.exception.MessageException) FavoriteException(com.dante.exception.FavoriteException) MessageException(com.dante.exception.MessageException)

Aggregations

User (com.dante.data.model.User)3 FavoriteException (com.dante.exception.FavoriteException)2 MessageException (com.dante.exception.MessageException)2 RetryWhenProcess (com.dante.rxjava.RetryWhenProcess)2 Document (org.jsoup.nodes.Document)1 Element (org.jsoup.nodes.Element)1