git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge commit '738dd8c426dcc6ed2508d68b7985f68d66549889'
[nikiroo-utils.git]
/
src
/
be
/
nikiroo
/
fanfix
/
supported
/
E621.java
diff --git
a/src/be/nikiroo/fanfix/supported/E621.java
b/src/be/nikiroo/fanfix/supported/E621.java
index aa3084f210cf99140d53d3878f326de46172d6f2..dfa9e5ed6a60e4694fc8494dcf196b4328259ee6 100644
(file)
--- a/
src/be/nikiroo/fanfix/supported/E621.java
+++ b/
src/be/nikiroo/fanfix/supported/E621.java
@@
-6,14
+6,11
@@
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
-import java.net.URLEncoder;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.AbstractMap;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.Scanner;
@@
-36,11
+33,6
@@
import be.nikiroo.utils.StringUtils;
* @author niki
*/
class E621 extends BasicSupport_Deprecated {
* @author niki
*/
class E621 extends BasicSupport_Deprecated {
- @Override
- public String getSourceName() {
- return "e621.net";
- }
-
@Override
protected MetaData getMeta(URL source, InputStream in) throws IOException {
MetaData meta = new MetaData();
@Override
protected MetaData getMeta(URL source, InputStream in) throws IOException {
MetaData meta = new MetaData();
@@
-49,9
+41,9
@@
class E621 extends BasicSupport_Deprecated {
meta.setAuthor(getAuthor(source, reset(in)));
meta.setDate("");
meta.setTags(getTags(source, reset(in), false));
meta.setAuthor(getAuthor(source, reset(in)));
meta.setDate("");
meta.setTags(getTags(source, reset(in), false));
- meta.setSource(getSourceName());
+ meta.setSource(get
Type().get
SourceName());
meta.setUrl(source.toString());
meta.setUrl(source.toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(get
Type().get
SourceName());
meta.setUuid(source.toString());
meta.setLuid("");
meta.setLang("en");
meta.setUuid(source.toString());
meta.setLuid("");
meta.setLang("en");
@@
-380,19
+372,28
@@
class E621 extends BasicSupport_Deprecated {
protected URL getCanonicalUrl(URL source) {
if (isSearch(source)) {
// /post?tags=tag1+tag2 -> ../post/index/1/tag1%32tag2
protected URL getCanonicalUrl(URL source) {
if (isSearch(source)) {
// /post?tags=tag1+tag2 -> ../post/index/1/tag1%32tag2
- String key = "
post
?tags=";
+ String key = "?tags=";
if (source.toString().contains(key)) {
int pos = source.toString().indexOf(key);
String tags = source.toString().substring(pos + key.length());
tags = tags.replace("+", "%20");
if (source.toString().contains(key)) {
int pos = source.toString().indexOf(key);
String tags = source.toString().substring(pos + key.length());
tags = tags.replace("+", "%20");
+
+ String base = source.toString().substring(0, pos);
+ if (!base.endsWith("/")) {
+ base += "/";
+ }
+ if (base.endsWith("/search/")) {
+ base = base.substring(0, base.indexOf("/search/") + 1);
+ }
+
try {
try {
- return new URL(source.toString().substring(0, pos)
- + "post/index/1/" + tags);
+ return new URL(base + "index/1/" + tags);
} catch (MalformedURLException e) {
Instance.getTraceHandler().error(e);
}
}
}
} catch (MalformedURLException e) {
Instance.getTraceHandler().error(e);
}
}
}
+
return super.getCanonicalUrl(source);
}
return super.getCanonicalUrl(source);
}
@@
-402,7
+403,7
@@
class E621 extends BasicSupport_Deprecated {
private boolean isSearch(URL url) {
return url.getPath().startsWith("/post/index/")
private boolean isSearch(URL url) {
return url.getPath().startsWith("/post/index/")
- || (url.getPath().equals("/post
") && url.getQuery().startsWith(
- "tags="));
+ || (url.getPath().equals("/post
/search") && url.getQuery()
+
.startsWith(
"tags="));
}
}
}
}