private SupportType type;
private URL currentReferer; // with only one 'r', as in 'HTTP'...
- /**
- * The name of this support class.
- *
- * @return the name
- */
- protected abstract String getSourceName();
-
/**
* Check if the given resource is supported by this {@link BasicSupport}.
*
* the type
* @param url
* the {@link URL} to support (can be NULL to get an
- * "abstract support")
+ * "abstract support"; if not NULL, will be used as the source
+ * URL)
*
* @return an implementation that supports it, or NULL
*/
return url.toString().toLowerCase().endsWith(".cbz");
}
- @Override
- public String getSourceName() {
- return "cbz";
- }
-
@Override
protected String getDataPrefix() {
return "";
* @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();
meta.setAuthor(getAuthor(source, reset(in)));
meta.setDate("");
meta.setTags(getTags(source, reset(in), false));
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(source.toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(source.toString());
meta.setLuid("");
meta.setLang("en");
* @author niki
*/
class EHentai extends BasicSupport_Deprecated {
- @Override
- public String getSourceName() {
- return "e-hentai.org";
- }
-
@Override
protected MetaData getMeta(URL source, InputStream in) throws IOException {
MetaData meta = new MetaData();
meta.setAuthor(getAuthor(reset(in)));
meta.setDate(getDate(reset(in)));
meta.setTags(getTags(reset(in)));
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(source.toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(source.toString());
meta.setLuid("");
meta.setLang(getLang(reset(in)));
private URL fakeSource;
private InputStream fakeIn;
- @Override
- public String getSourceName() {
- return "epub";
- }
-
public File getSourceFileOriginal() {
return super.getSourceFile();
}
meta = new MetaData();
meta.setLang("en");
meta.setTags(new ArrayList<String>());
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUuid(url);
meta.setUrl(url);
meta.setTitle(title);
return true;
}
- @Override
- public String getSourceName() {
- return "Fanfiction.net";
- }
-
@Override
protected MetaData getMeta(URL source, InputStream in) throws IOException {
MetaData meta = new MetaData();
meta.setAuthor(getAuthor(reset(in)));
meta.setDate(getDate(reset(in)));
meta.setTags(getTags(reset(in)));
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(source.toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(source.toString());
meta.setLuid("");
meta.setLang("en"); // TODO!
return true;
}
- @Override
- public String getSourceName() {
- return "FimFiction.net";
- }
-
@Override
protected MetaData getMeta(URL source, InputStream in) throws IOException {
MetaData meta = new MetaData();
meta.setAuthor(getAuthor(reset(in)));
meta.setDate(getDate(reset(in)));
meta.setTags(getTags(reset(in)));
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(source.toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(source.toString());
meta.setLuid("");
meta.setLang("en");
return true;
}
- @Override
- public String getSourceName() {
- return "FimFiction.net";
- }
-
/**
* Extract the full JSON data we will later use to build the {@link Story}.
*
meta.setAuthor(getKeyJson(json, 0, "type", "user", "name"));
meta.setDate(getKeyJson(json, 0, "type", "story", "date_published"));
meta.setTags(getTags());
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(getSource().toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(getSource().toString());
meta.setLuid("");
meta.setLang("en");
* @author niki
*/
class Html extends InfoText {
- @Override
- public String getSourceName() {
- return "html";
- }
-
@Override
protected boolean supports(URL url) {
try {
* @author niki
*/
class InfoText extends Text {
- @Override
- public String getSourceName() {
- return "info-text";
- }
-
protected File getInfoFile() {
return new File(assureNoTxt(getSourceFile()).getPath() + ".info");
}
return true;
}
- @Override
- public String getSourceName() {
- return "MangaFox.me";
- }
-
@Override
protected MetaData getMeta() throws IOException {
MetaData meta = new MetaData();
meta.setDate(StringUtils.unhtml(table.get(0).text()).trim());
meta.setTags(explode(table.get(3).text()));
}
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(getSource().toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(getSource().toString());
meta.setLuid("");
meta.setLang("en");
return true;
}
- @Override
- public String getSourceName() {
- return "MangaLel.com";
- }
-
@Override
protected MetaData getMeta() throws IOException {
MetaData meta = new MetaData();
meta.setAuthor(authorDateTag[0]);
meta.setDate(authorDateTag[1]);
meta.setTags(explode(authorDateTag[2]));
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(getSource().toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(getSource().toString());
meta.setLuid("");
meta.setLang("fr");
HTML;
/**
- * A description of this support type (more information than the
- * {@link BasicSupport#getSourceName()}).
+ * The name of this support type (a short version).
+ *
+ * @return the name
+ */
+ public String getSourceName() {
+ switch (this) {
+ case CBZ:
+ return "cbz";
+ case E621:
+ return "e621.net";
+ case E_HENTAI:
+ return "e-hentai.org";
+ case EPUB:
+ return "epub";
+ case FANFICTION:
+ return "Fanfiction.net";
+ case FIMFICTION:
+ return "FimFiction.net";
+ case HTML:
+ return "html";
+ case INFO_TEXT:
+ return "info-text";
+ case MANGA_LEL:
+ return "MangaLel.com";
+ case MANGAFOX:
+ return "MangaFox.me";
+ case TEXT:
+ return "text";
+ case YIFFSTAR:
+ return "YiffStar";
+ }
+
+ return "";
+ }
+
+ /**
+ * A description of this support type (more information than
+ * {@link SupportType#getSourceName()}).
*
* @return the description
*/
return desc;
}
- /**
- * The name of this support type (a short version).
- *
- * @return the name
- */
- public String getSourceName() {
- BasicSupport support = BasicSupport.getSupport(this, null);
- if (support != null) {
- return support.getSourceName();
- }
-
- return null;
- }
-
@Override
public String toString() {
return super.toString().toLowerCase();
return false;
}
- @Override
- public String getSourceName() {
- return "text";
- }
-
@Override
protected Document loadDocument(URL source) throws IOException {
try {
meta.setAuthor(getAuthor());
meta.setDate(getDate());
meta.setTags(new ArrayList<String>());
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(getSourceFile().toURI().toURL().toString());
meta.setPublisher("");
meta.setUuid(getSourceFile().toString());
* @author niki
*/
class YiffStar extends BasicSupport_Deprecated {
-
- @Override
- public String getSourceName() {
- return "YiffStar";
- }
-
@Override
protected MetaData getMeta(URL source, InputStream in) throws IOException {
MetaData meta = new MetaData();
meta.setAuthor(getAuthor(reset(in)));
meta.setDate("");
meta.setTags(getTags(reset(in)));
- meta.setSource(getSourceName());
+ meta.setSource(getType().getSourceName());
meta.setUrl(source.toString());
- meta.setPublisher(getSourceName());
+ meta.setPublisher(getType().getSourceName());
meta.setUuid(source.toString());
meta.setLuid("");
meta.setLang("en");