mirror of
https://github.com/Athou/commafeed.git
synced 2026-11-03 19:05:03 +00:00
use google java formatter to avoid downloading eclipse during build
This commit is contained in:
@@ -2,11 +2,8 @@ package com.commafeed.backend.urlprovider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tries to find a feed url given the url and page content
|
||||
*/
|
||||
/** Tries to find a feed url given the url and page content */
|
||||
public interface FeedURLProvider {
|
||||
|
||||
List<String> get(String url, String urlContent);
|
||||
|
||||
List<String> get(String url, String urlContent);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
package com.commafeed.backend.urlprovider;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
@Singleton
|
||||
public class InPageReferenceFeedURLProvider implements FeedURLProvider {
|
||||
|
||||
@Override
|
||||
public List<String> get(String url, String urlContent) {
|
||||
Document doc = Jsoup.parse(urlContent, url);
|
||||
if (!"html".equals(doc.children().getFirst().tagName())) {
|
||||
return List.of();
|
||||
}
|
||||
return Stream.concat(doc.select("link[type=application/atom+xml]").stream(), doc.select("link[type=application/rss+xml]").stream())
|
||||
.map(node -> node.attr("abs:href"))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> get(String url, String urlContent) {
|
||||
Document doc = Jsoup.parse(urlContent, url);
|
||||
if (!"html".equals(doc.children().getFirst().tagName())) {
|
||||
return List.of();
|
||||
}
|
||||
return Stream.concat(
|
||||
doc.select("link[type=application/atom+xml]").stream(),
|
||||
doc.select("link[type=application/rss+xml]").stream())
|
||||
.map(node -> node.attr("abs:href"))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
package com.commafeed.backend.urlprovider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.Strings;
|
||||
|
||||
/**
|
||||
* Workaround for Youtube channels
|
||||
*
|
||||
* converts the channel URL https://www.youtube.com/channel/CHANNEL_ID to the valid feed URL
|
||||
*
|
||||
* <p>converts the channel URL https://www.youtube.com/channel/CHANNEL_ID to the valid feed URL
|
||||
* https://www.youtube.com/feeds/videos.xml?channel_id=CHANNEL_ID
|
||||
*/
|
||||
@Singleton
|
||||
public class YoutubeFeedURLProvider implements FeedURLProvider {
|
||||
|
||||
private static final String PREFIX = "https://www.youtube.com/channel/";
|
||||
private static final String REPLACEMENT_PREFIX = "https://www.youtube.com/feeds/videos.xml?channel_id=";
|
||||
private static final String PREFIX = "https://www.youtube.com/channel/";
|
||||
private static final String REPLACEMENT_PREFIX =
|
||||
"https://www.youtube.com/feeds/videos.xml?channel_id=";
|
||||
|
||||
@Override
|
||||
public List<String> get(String url, String urlContent) {
|
||||
if (!Strings.CI.startsWith(url, PREFIX)) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
return List.of(REPLACEMENT_PREFIX + url.substring(PREFIX.length()));
|
||||
}
|
||||
@Override
|
||||
public List<String> get(String url, String urlContent) {
|
||||
if (!Strings.CI.startsWith(url, PREFIX)) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
return List.of(REPLACEMENT_PREFIX + url.substring(PREFIX.length()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user