mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
fix youtube icons (#658)
This commit is contained in:
@@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
import com.commafeed.backend.model.Feed;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class AbstractFaviconFetcher {
|
public abstract class AbstractFaviconFetcher {
|
||||||
|
|
||||||
@@ -16,7 +18,7 @@ public abstract class AbstractFaviconFetcher {
|
|||||||
|
|
||||||
protected static int TIMEOUT = 4000;
|
protected static int TIMEOUT = 4000;
|
||||||
|
|
||||||
public abstract byte[] fetch(String url);
|
public abstract byte[] fetch(Feed feed);
|
||||||
|
|
||||||
protected boolean isValidIconResponse(byte[] content, String contentType) {
|
protected boolean isValidIconResponse(byte[] content, String contentType) {
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.jsoup.select.Elements;
|
|||||||
import com.commafeed.backend.HttpGetter;
|
import com.commafeed.backend.HttpGetter;
|
||||||
import com.commafeed.backend.HttpGetter.HttpResult;
|
import com.commafeed.backend.HttpGetter.HttpResult;
|
||||||
import com.commafeed.backend.feed.FeedUtils;
|
import com.commafeed.backend.feed.FeedUtils;
|
||||||
|
import com.commafeed.backend.model.Feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inspired/Ported from https://github.com/potatolondon/getfavicon
|
* Inspired/Ported from https://github.com/potatolondon/getfavicon
|
||||||
@@ -27,7 +28,9 @@ public class DefaultFaviconFetcher extends AbstractFaviconFetcher {
|
|||||||
private final HttpGetter getter;
|
private final HttpGetter getter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] fetch(String url) {
|
public byte[] fetch(Feed feed) {
|
||||||
|
String url = feed.getLink() != null ? feed.getLink() : feed.getUrl();
|
||||||
|
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
log.debug("url is null");
|
log.debug("url is null");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.jsoup.select.Elements;
|
|||||||
|
|
||||||
import com.commafeed.backend.HttpGetter;
|
import com.commafeed.backend.HttpGetter;
|
||||||
import com.commafeed.backend.HttpGetter.HttpResult;
|
import com.commafeed.backend.HttpGetter.HttpResult;
|
||||||
|
import com.commafeed.backend.model.Feed;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
|
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
|
||||||
@@ -21,7 +22,9 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
|||||||
private final HttpGetter getter;
|
private final HttpGetter getter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] fetch(String url) {
|
public byte[] fetch(Feed feed) {
|
||||||
|
String url = feed.getUrl();
|
||||||
|
|
||||||
if (!url.toLowerCase().contains("://gdata.youtube.com/")) {
|
if (!url.toLowerCase().contains("://gdata.youtube.com/")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,11 +50,10 @@ public class FeedService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte[] fetchFavicon(Feed feed) {
|
public byte[] fetchFavicon(Feed feed) {
|
||||||
String url = feed.getLink() != null ? feed.getLink() : feed.getUrl();
|
|
||||||
|
|
||||||
byte[] icon = null;
|
byte[] icon = null;
|
||||||
for (AbstractFaviconFetcher faviconFetcher : faviconFetchers) {
|
for (AbstractFaviconFetcher faviconFetcher : faviconFetchers) {
|
||||||
icon = faviconFetcher.fetch(url);
|
icon = faviconFetcher.fetch(feed);
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user