Fix date/language meta data on e-hentai
authorNiki Roo <niki@nikiroo.be>
Tue, 18 Apr 2017 18:34:49 +0000 (20:34 +0200)
committerNiki Roo <niki@nikiroo.be>
Tue, 18 Apr 2017 18:34:49 +0000 (20:34 +0200)
changelog.md
src/be/nikiroo/fanfix/supported/EHentai.java

index 53fa25e549957d013d0922cbba1e33c84e16520d..09b457c4a07f4aa2fa16f9ed9f24e8509d7739ce 100644 (file)
@@ -1,5 +1,8 @@
 # Fanfix
 
+## Version WIP
+- fix some meta data that were missing on e-Hentai
+
 ## Version 1.5.0
 - New website supported following a request: e-hentai.org
 - Library: perf improvement when retrieving the stories (cover not loaded when not needed)
index eae377c81d9feb53d5bdb2dcdda21623227d348d..363635488e35a514f0b5bbb0929b85b5ef605bae 100644 (file)
@@ -35,15 +35,15 @@ class EHentai extends BasicSupport {
 
                meta.setTitle(getTitle(reset(in)));
                meta.setAuthor(getAuthor(reset(in)));
-               meta.setDate("");
+               meta.setDate(getDate(reset(in)));
                meta.setTags(getTags(reset(in)));
                meta.setSource(getSourceName());
                meta.setUrl(source.toString());
                meta.setPublisher(getSourceName());
                meta.setUuid(source.toString());
                meta.setLuid("");
-               meta.setLang("EN");
-               meta.setSubject("Furry");
+               meta.setLang(getLang(reset(in)));
+               meta.setSubject("Hentai");
                meta.setType(getType().toString());
                meta.setImageDocument(true);
                meta.setCover(getCover(source, reset(in)));
@@ -101,6 +101,45 @@ class EHentai extends BasicSupport {
                return author;
        }
 
+       private String getLang(InputStream in) {
+               String lang = null;
+
+               String langLine = getKeyLine(in, "class=\"gdt1\">Language",
+                               "class=\"gdt2\"", "</td>");
+               if (langLine != null) {
+                       langLine = StringUtils.unhtml(langLine).trim();
+                       if (langLine.equalsIgnoreCase("English")) {
+                               lang = "EN";
+                       } else if (langLine.equalsIgnoreCase("Japanese")) {
+                               lang = "JP";
+                       } else if (langLine.equalsIgnoreCase("French")) {
+                               lang = "FR";
+                       } else {
+                               // TODO find the code?
+                               lang = langLine;
+                       }
+               }
+
+               return lang;
+       }
+
+       private String getDate(InputStream in) {
+               String date = null;
+
+               String dateLine = getKeyLine(in, "class=\"gdt1\">Posted",
+                               "class=\"gdt2\"", "</td>");
+               if (dateLine != null) {
+                       dateLine = StringUtils.unhtml(dateLine).trim();
+                       if (dateLine.length() > 10) {
+                               dateLine = dateLine.substring(0, 10).trim();
+                       }
+
+                       date = dateLine;
+               }
+
+               return date;
+       }
+
        private List<String> getTags(InputStream in) {
                List<String> tags = new ArrayList<String>();
                List<String> tagsAuthor = getTagsAuthor(in);