X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FYiffStar.java;h=4f4e8d693271814bb645eb9c9a6ae3b81b1b5f7e;hp=e9c10c9f06eb4d2d333976e039d09e8adfb37305;hb=6e06d2cc9bf068a8ec4ad105aaef955a6eb509a1;hpb=a4143cd74a90e17a811a4581cbeb213fed1f6304 diff --git a/src/be/nikiroo/fanfix/supported/YiffStar.java b/src/be/nikiroo/fanfix/supported/YiffStar.java index e9c10c9..4f4e8d6 100644 --- a/src/be/nikiroo/fanfix/supported/YiffStar.java +++ b/src/be/nikiroo/fanfix/supported/YiffStar.java @@ -5,12 +5,14 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; import be.nikiroo.fanfix.Instance; +import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.utils.StringUtils; @@ -65,12 +67,21 @@ class YiffStar extends BasicSupport { } @Override - public Map getCookies() { - // TODO - // Cookies will actually be retained by the cache manager once logged in - // But we need to connect here and notify the cache manager + public void login() throws IOException { + Map post = new HashMap(); + post.put("LoginForm[sfLoginUsername]", + Instance.getConfig().getString(Config.LOGIN_YIFFSTAR_USER)); + post.put("LoginForm[sfLoginPassword]", + Instance.getConfig().getString(Config.LOGIN_YIFFSTAR_PASS)); + post.put("YII_CSRF_TOKEN", ""); - return super.getCookies(); + // Cookies will actually be retained by the cache manager once logged in + // TODO: not working yet, once fixed can be removed (adding "/guest" to + // URLs fix the access problem!): + /* + * Instance.getCache() .openNoCache(new + * URL("https://www.sofurry.com/user/login"), this, post).close(); + */ } @Override @@ -78,11 +89,13 @@ class YiffStar extends BasicSupport { if (source.getPath().startsWith("/view")) { InputStream in = Instance.getCache().open(source, this, false); String line = getLine(in, "/browse/folder/", 0); - String[] tab = line.split("\""); - if (tab.length > 1) { - String groupUrl = source.getProtocol() + "://" - + source.getHost() + tab[1]; - return new URL(groupUrl); + if (line != null) { + String[] tab = line.split("\""); + if (tab.length > 1) { + String groupUrl = source.getProtocol() + "://" + + source.getHost() + tab[1]; + return new URL(groupUrl); + } } }