X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FFimfiction.java;h=77267c1188a24438bec7f46c1097219f0d20e58c;hb=82c6796bb4d08e5a6c267787bed648c3c5cacf21;hp=a6bd475fad05e3ace03df18df271384e4cc934ee;hpb=68686a37a591a767f6d1af428ea0d5f3d3a1ddc1;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/Fimfiction.java b/src/be/nikiroo/fanfix/supported/Fimfiction.java index a6bd475..77267c1 100644 --- a/src/be/nikiroo/fanfix/supported/Fimfiction.java +++ b/src/be/nikiroo/fanfix/supported/Fimfiction.java @@ -1,10 +1,10 @@ package be.nikiroo.fanfix.supported; -import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -14,6 +14,8 @@ import java.util.Scanner; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.data.MetaData; +import be.nikiroo.utils.Image; +import be.nikiroo.utils.Progress; import be.nikiroo.utils.StringUtils; /** @@ -22,17 +24,12 @@ import be.nikiroo.utils.StringUtils; * * @author niki */ -class Fimfiction extends BasicSupport { +class Fimfiction extends BasicSupport_Deprecated { @Override protected boolean isHtml() { return true; } - @Override - public String getSourceName() { - return "FimFiction.net"; - } - @Override protected MetaData getMeta(URL source, InputStream in) throws IOException { MetaData meta = new MetaData(); @@ -41,11 +38,12 @@ class Fimfiction extends BasicSupport { meta.setAuthor(getAuthor(reset(in))); meta.setDate(getDate(reset(in))); meta.setTags(getTags(reset(in))); - meta.setSource(getSourceName()); - meta.setPublisher(getSourceName()); + meta.setSource(getType().getSourceName()); + meta.setUrl(source.toString()); + meta.setPublisher(getType().getSourceName()); meta.setUuid(source.toString()); meta.setLuid(""); - meta.setLang("EN"); + meta.setLang("en"); meta.setSubject("MLP"); meta.setType(getType().toString()); meta.setImageDocument(false); @@ -68,22 +66,36 @@ class Fimfiction extends BasicSupport { @SuppressWarnings("resource") Scanner scan = new Scanner(in, "UTF-8"); scan.useDelimiter("\\n"); + boolean started = false; while (scan.hasNext()) { String line = scan.next(); - if (line.contains("story_category") && !line.contains("title=")) { - int pos = line.indexOf('>'); - if (pos >= 0) { - line = line.substring(pos + 1); - pos = line.indexOf('<'); - if (pos >= 0) { - line = line.substring(0, pos); - } + + if (!started) { + started = line.contains("\"story_container\""); + } + + if (started && line.contains("class=\"tag-")) { + if (line.contains("index.php")) { + break; // end of *this story* tags } - line = line.trim(); - if (!tags.contains(line)) { - tags.add(line); + String keyword = "title=\""; + Scanner tagScanner = new Scanner(line); + tagScanner.useDelimiter(keyword); + if (tagScanner.hasNext()) { + tagScanner.next();// Ignore first one } + while (tagScanner.hasNext()) { + String tag = tagScanner.next(); + if (tag.contains("\"")) { + tag = tag.split("\"")[0]; + tag = StringUtils.unhtml(tag).trim(); + if (!tag.isEmpty() && !tags.contains(tag)) { + tags.add(tag); + } + } + } + tagScanner.close(); } } @@ -154,12 +166,12 @@ class Fimfiction extends BasicSupport { @Override protected String getDesc(URL source, InputStream in) { // the og: meta version is the SHORT resume, this is the LONG resume - return getLine(in, "class=\"more_button hidden\"", -1); + return getLine(in, "class=\"description-text bbcode\"", 1); } - private BufferedImage getCover(InputStream in) { + private Image getCover(InputStream in) { // Note: the 'og:image' is the SMALL cover, not the full version - String cover = getLine(in, "