mirror of https://github.com/readrops/Readrops.git
Merge branch 'master' into develop
This commit is contained in:
commit
90071f5830
|
@ -71,7 +71,7 @@ public class RSSQuery {
|
|||
if (type == RSSType.RSS_UNKNOWN) {
|
||||
RSSType contentType = getContentRSSType(response.body().string());
|
||||
return contentType != RSSType.RSS_UNKNOWN;
|
||||
} else return type != null;
|
||||
} else return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
@ -103,17 +103,16 @@ public class RSSQuery {
|
|||
switch (header) {
|
||||
case LibUtils.RSS_DEFAULT_CONTENT_TYPE:
|
||||
return RSSType.RSS_2;
|
||||
case LibUtils.RSS_TEXT_CONTENT_TYPE:
|
||||
case LibUtils.HTML_CONTENT_TYPE:
|
||||
case LibUtils.RSS_APPLICATION_CONTENT_TYPE:
|
||||
return RSSType.RSS_UNKNOWN;
|
||||
case LibUtils.ATOM_CONTENT_TYPE:
|
||||
return RSSType.RSS_ATOM;
|
||||
case LibUtils.JSON_CONTENT_TYPE:
|
||||
return RSSType.RSS_JSON;
|
||||
case LibUtils.RSS_TEXT_CONTENT_TYPE:
|
||||
case LibUtils.HTML_CONTENT_TYPE:
|
||||
case LibUtils.RSS_APPLICATION_CONTENT_TYPE:
|
||||
default:
|
||||
Log.d(TAG, "bad content type : " + contentType);
|
||||
return null;
|
||||
return RSSType.RSS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.jsoup.select.Elements;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -33,10 +34,12 @@ public final class HtmlParser {
|
|||
* @param url url to request
|
||||
* @return a list of rss urls with their title
|
||||
*/
|
||||
public static List<ParsingResult> getFeedLink(String url) throws Exception {
|
||||
public static List<ParsingResult> getFeedLink(String url) {
|
||||
List<ParsingResult> results = new ArrayList<>();
|
||||
|
||||
Document document = Jsoup.parse(getHTMLHeadFromUrl(url), url);
|
||||
String head = getHTMLHeadFromUrl(url);
|
||||
if (head != null) {
|
||||
Document document = Jsoup.parse(head, url);
|
||||
|
||||
Elements elements = document.select("link");
|
||||
|
||||
|
@ -52,6 +55,9 @@ public final class HtmlParser {
|
|||
}
|
||||
|
||||
return results;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isTypeRssFeed(String type) {
|
||||
|
|
|
@ -54,8 +54,9 @@ public class AddFeedsViewModel extends AndroidViewModel {
|
|||
ParsingResult parsingResult = new ParsingResult(url, null);
|
||||
results.add(parsingResult);
|
||||
|
||||
} else
|
||||
} else {
|
||||
results.addAll(HtmlParser.getFeedLink(url));
|
||||
}
|
||||
|
||||
emitter.onSuccess(results);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue