Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,96 +1,95 @@
/*
* Clover - 4chan browser https://github.com/Floens/Clover/
* Copyright (C) 2014 Floens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.floens.chan.core.site.common.tinyib;
/*
* Clover - 4chan browser https://github.com/Floens/Clover/
* Copyright (C) 2014 Floens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.floens.chan.core.site.common.tinyib;

import static android.text.TextUtils.isEmpty;
import org.floens.chan.core.site.SiteAuthentication;
import org.floens.chan.core.site.common.CommonSite;
import org.floens.chan.core.site.common.MultipartHttpCall;
import org.floens.chan.core.site.http.Reply;
import org.floens.chan.core.site.http.ReplyResponse;
import org.jsoup.Jsoup;

import org.floens.chan.core.site.SiteAuthentication;
import org.floens.chan.core.site.common.CommonSite;
import org.floens.chan.core.site.common.MultipartHttpCall;
import org.floens.chan.core.site.http.Reply;
import org.floens.chan.core.site.http.ReplyResponse;
import org.jsoup.Jsoup;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.Response;

import okhttp3.Response;
import static android.text.TextUtils.isEmpty;

public class TinyIBActions extends CommonSite.CommonActions {
public TinyIBActions(CommonSite commonSite) {
super(commonSite);
}
public class TinyIBActions extends CommonSite.CommonActions {
public TinyIBActions(CommonSite commonSite) {
super(commonSite);
}

@Override
public void setupPost(Reply reply, MultipartHttpCall call) {
call.parameter("email", reply.options);
@Override
public void setupPost(Reply reply, MultipartHttpCall call) {
call.parameter("email", reply.options);

if (reply.file != null) {
call.fileParameter("file", reply.fileName, reply.file);
}
if (reply.file != null) {
call.fileParameter("file", reply.fileName, reply.file);
}

call.parameter("message", reply.comment);
call.parameter("name", reply.name);
call.parameter("message", reply.comment);
call.parameter("name", reply.name);

if (reply.loadable.isThreadMode()) {
call.parameter("parent", String.valueOf(reply.loadable.no));
}
if (reply.loadable.isThreadMode()) {
call.parameter("parent", String.valueOf(reply.loadable.no));
}

if (!isEmpty(reply.password)) {
call.parameter("password", reply.password);
}
if (!isEmpty(reply.password)) {
call.parameter("password", reply.password);
}

if (!isEmpty(reply.subject)) {
call.parameter("subject", reply.subject);
}
}
if (!isEmpty(reply.subject)) {
call.parameter("subject", reply.subject);
}
}

@Override
public void handlePost(ReplyResponse replyResponse, Response response, String result) {
// extract the data we need from matching the result
int threadNo = 0;
int postNo = 0;
Matcher res = resultPattern().matcher(result);
if (res.find()) {
threadNo = Integer.parseInt(res.group(1));
postNo = Integer.parseInt(res.group(2));
}
Matcher err = errorPattern().matcher(result);
if (err.find()) {
replyResponse.errorMessage = Jsoup.parse(err.group(1)).body().text();
} else {
replyResponse.threadNo = threadNo;
replyResponse.postNo = postNo;
replyResponse.posted = true;
}
}
@Override
public void handlePost(ReplyResponse replyResponse, Response response, String result) {
// extract the data we need from matching the result
int threadNo = 0;
int postNo = 0;
Matcher res = resultPattern().matcher(result);
if (res.find()) {
threadNo = Integer.parseInt(res.group(1));
postNo = Integer.parseInt(res.group(2));
}
Matcher err = errorPattern().matcher(result);
if (err.find()) {
replyResponse.errorMessage = Jsoup.parse(err.group(1)).body().text();
} else {
replyResponse.threadNo = threadNo;
replyResponse.postNo = postNo;
replyResponse.posted = true;
}
}

public Pattern resultPattern() {
return Pattern.compile(".+url=res/(\\d+).html#(\\d+)\">");
}
public Pattern resultPattern() {
return Pattern.compile(".+url=res/(\\d+).html#(\\d+)\">");
}
//TODO: match the error pattern
public Pattern errorPattern() {
return Pattern.compile("<h1[^>]*>Error</h1>.*<h2[^>]*>(.*?)</h2>");
}

//TODO: match the error pattern
public Pattern errorPattern() {
return Pattern.compile("<h1[^>]*>Error</h1>.*<h2[^>]*>(.*?)</h2>");
}

@Override
public SiteAuthentication postAuthenticate() {
return SiteAuthentication.fromNone();
}
}
@Override
public SiteAuthentication postAuthenticate() {
return SiteAuthentication.fromNone();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public void loadCatalog(JsonReader reader, ChanReaderProcessingQueue queue) thro
reader.skipValue();
}
}

reader.endObject();
reader.endObject();
}

@Override
Expand All @@ -86,7 +85,8 @@ public void readPostObject(JsonReader reader, ChanReaderProcessingQueue queue) t
String thumbnailpath = null;
String originalName = null;

/* prevent API parse error
/* prevent API parse error

resto is not available on opening board overview the first time
so, we manually set the opId to 0, builder.op to true and builder.opId to 0 */
int opId = 0;
Expand Down Expand Up @@ -183,9 +183,16 @@ public void readPostObject(JsonReader reader, ChanReaderProcessingQueue queue) t

// The file from between the other values.
if (file != null && file.length() > 0) {
fileName = file.substring(0, file.lastIndexOf("."));
fileExt = file.substring(file.lastIndexOf(".") + 1);
Map<String, String> args = makeArgument("path", file,
if (file.contains("<iframe")) {
fileName = originalName;
fileExt = "YT";
path = file;
} else {
fileName = file.substring(0, file.lastIndexOf("."));
fileExt = file.substring(file.lastIndexOf(".") + 1);
path = file;
}
Map<String, String> args = makeArgument("path", path,
"thumbnailpath", thumbnail);
PostImage image = new PostImage.Builder()
.originalName(org.jsoup.parser.Parser.unescapeEntities(fileName, false))
Expand Down Expand Up @@ -293,9 +300,16 @@ private PostImage readPostImage(JsonReader reader, Post.Builder builder,
reader.endObject();

if (file != null && file.length() > 0) {
fileName = file.substring(0, file.lastIndexOf("."));
fileExt = file.substring(file.lastIndexOf(".") + 1);
Map<String, String> args = makeArgument("path", file,
if (file.contains("<iframe")) {
fileName = originalName;
fileExt = "YT";
path = file;
} else {
fileName = file.substring(0, file.lastIndexOf("."));
fileExt = file.substring(file.lastIndexOf(".") + 1);
path = file;
}
Map<String, String> args = makeArgument("path", path,
"thumbnailpath", thumbnail);
return new PostImage.Builder()
.originalName(org.jsoup.parser.Parser.unescapeEntities(fileName, false))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
/*
* Clover - 4chan browser https://github.com/Floens/Clover/
* Copyright (C) 2014 Floens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.floens.chan.core.site.common.tinyib;
/*
* Clover - 4chan browser https://github.com/Floens/Clover/
* Copyright (C) 2014 Floens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.floens.chan.core.site.common.tinyib;

import org.floens.chan.core.site.parser.CommentParser;
import org.floens.chan.core.site.parser.CommentParser;

import java.util.regex.Pattern;
import java.util.regex.Pattern;

public class TinyIBCommentParser extends CommentParser {
public TinyIBCommentParser() {
addDefaultRules();
setQuotePattern(Pattern.compile(".*#(\\d+)"));
setFullQuotePattern(Pattern.compile("/(\\w+)/\\w+/(\\d+)\\.html#(\\d+)"));
}
}
public class TinyIBCommentParser extends CommentParser {
public TinyIBCommentParser() {
addDefaultRules();
setQuotePattern(Pattern.compile(".*#(\\d+)"));
setFullQuotePattern(Pattern.compile("/(\\w+)/\\w+/(\\d+)\\.html#(\\d+)"));
}
}
Loading