1 package be
.nikiroo
.fanfix
.supported
;
4 import java
.io
.IOException
;
5 import java
.net
.MalformedURLException
;
7 import java
.util
.ArrayList
;
8 import java
.util
.HashMap
;
11 import java
.util
.Map
.Entry
;
13 import org
.jsoup
.helper
.DataUtil
;
14 import org
.jsoup
.nodes
.Document
;
16 import be
.nikiroo
.fanfix
.Instance
;
17 import be
.nikiroo
.fanfix
.bundles
.Config
;
18 import be
.nikiroo
.fanfix
.data
.MetaData
;
19 import be
.nikiroo
.utils
.IOUtils
;
20 import be
.nikiroo
.utils
.Progress
;
23 * Support class for <a href="https://sofurry.com/">SoFurry.com</a>, a Furry
24 * website supporting images and stories (we only retrieve the stories).
28 class YiffStar2
extends BasicSupport
{
30 protected String
getSourceName() {
35 protected void login() throws IOException
{
36 // Note: this is not necessary anymore for NSFW
37 // (the "/guest" trick is enough)
38 // ...but still required for RegUsersOnly pages
39 String login
= Instance
.getConfig().getString(
40 Config
.LOGIN_YIFFSTAR_USER
);
41 String password
= Instance
.getConfig().getString(
42 Config
.LOGIN_YIFFSTAR_PASS
);
44 if (login
!= null && !login
.isEmpty() && password
!= null
45 && !password
.isEmpty()) {
46 Map
<String
, String
> post
= new HashMap
<String
, String
>();
47 post
.put("YII_CSRF_TOKEN", "");
48 post
.put("LoginForm[sfLoginUsername]", login
);
49 post
.put("LoginForm[sfLoginPassword]", password
);
50 post
.put("returnUrl", "/");
51 post
.put("yt1", "Login");
53 // Cookies will actually be retained by the cache manager once
55 setCurrentReferer(null);
57 .openNoCache(new URL("https://www.sofurry.com/user/login"),
58 this, post
, null, null).close();
63 protected Document
loadDocument(URL source
) throws IOException
{
64 String url
= getCanonicalUrl(source
).toString();
66 .load(Instance
.getCache().openNoCache(source
, this, null, null,
67 null), "UTF-8", url
.toString());
71 protected boolean isHtml() {
76 protected MetaData
getMeta() throws IOException
{
78 IOUtils
.writeSmallFile(new File("/tmp/node.html"), getSourceNode()
81 MetaData meta
= new MetaData();
86 meta
.setTags(new ArrayList
<String
>());
87 meta
.setSource(getSourceName());
88 meta
.setUrl(getSource().toString());
89 meta
.setPublisher(getSourceName());
90 meta
.setUuid(getSource().toString());
93 meta
.setSubject("Furry");
94 meta
.setType(getType().toString());
95 meta
.setImageDocument(false);
102 protected String
getDesc() throws IOException
{
103 // TODO Auto-generated method stub
108 protected List
<Entry
<String
, URL
>> getChapters(Progress pg
)
110 // TODO Auto-generated method stub
111 return new ArrayList
<Map
.Entry
<String
, URL
>>();
115 protected String
getChapterContent(URL chapUrl
, int number
, Progress pg
)
117 // TODO Auto-generated method stub
122 protected boolean supports(URL url
) {
123 String host
= url
.getHost();
124 if (host
.startsWith("www.")) {
125 host
= host
.substring("www.".length());
128 return "sofurry.com".equals(host
);
132 * Return a {@link URL} from the given link, but add the "/guest" part to it
133 * to make sure we don't need to be logged-in to see it.
138 * @return the {@link URL}
140 * @throws MalformedURLException
141 * in case of data error
143 static private URL
guestUrl(String link
) throws MalformedURLException
{
146 return new URL(link
);
148 if (link
.contains("?")) {
149 if (link
.contains("/?")) {
150 return new URL(link
.replace("?", "guest?"));
153 return new URL(link
.replace("?", "/guest?"));
156 return new URL(link
+ "/guest");