mirror of
https://github.com/Athou/commafeed.git
synced 2026-09-23 12:35:07 +00:00
add even more integration tests
This commit is contained in:
@@ -32,6 +32,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Singleton
|
||||
public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
|
||||
private static final String PART_SNIPPET = "snippet";
|
||||
|
||||
private static final JsonPointer CHANNEL_THUMBNAIL_URL = JsonPointer.compile("/items/0/snippet/thumbnails/default/url");
|
||||
private static final JsonPointer PLAYLIST_CHANNEL_ID = JsonPointer.compile("/items/0/snippet/channelId");
|
||||
|
||||
@@ -86,7 +88,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
bytes = iconResult.getContent();
|
||||
contentType = iconResult.getContentType();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to retrieve YouTube icon", e);
|
||||
log.debug("Failed to retrieve YouTube icon", e);
|
||||
}
|
||||
|
||||
if (!isValidIconResponse(bytes, contentType)) {
|
||||
@@ -98,7 +100,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
private byte[] fetchForUser(String googleAuthKey, String userId)
|
||||
throws IOException, NotModifiedException, TooManyRequestsException, HostNotAllowedException, SchemeNotAllowedException {
|
||||
URI uri = UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/channels")
|
||||
.queryParam("part", "snippet")
|
||||
.queryParam("part", PART_SNIPPET)
|
||||
.queryParam("key", googleAuthKey)
|
||||
.queryParam("forUsername", userId)
|
||||
.build();
|
||||
@@ -108,7 +110,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
private byte[] fetchForChannel(String googleAuthKey, String channelId)
|
||||
throws IOException, NotModifiedException, TooManyRequestsException, HostNotAllowedException, SchemeNotAllowedException {
|
||||
URI uri = UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/channels")
|
||||
.queryParam("part", "snippet")
|
||||
.queryParam("part", PART_SNIPPET)
|
||||
.queryParam("key", googleAuthKey)
|
||||
.queryParam("id", channelId)
|
||||
.build();
|
||||
@@ -118,7 +120,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
private byte[] fetchForPlaylist(String googleAuthKey, String playlistId)
|
||||
throws IOException, NotModifiedException, TooManyRequestsException, HostNotAllowedException, SchemeNotAllowedException {
|
||||
URI uri = UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/playlists")
|
||||
.queryParam("part", "snippet")
|
||||
.queryParam("part", PART_SNIPPET)
|
||||
.queryParam("key", googleAuthKey)
|
||||
.queryParam("id", playlistId)
|
||||
.build();
|
||||
|
||||
@@ -26,10 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class FeedUtils {
|
||||
|
||||
public static String truncate(String string, int length) {
|
||||
if (string != null) {
|
||||
string = string.substring(0, Math.min(length, string.length()));
|
||||
}
|
||||
return string;
|
||||
return StringUtils.truncate(string, length);
|
||||
}
|
||||
|
||||
public static boolean isRTL(String title, String content) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import jakarta.persistence.Table;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
|
||||
import com.commafeed.backend.feed.FeedUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -99,15 +98,4 @@ public class FeedEntryContent extends AbstractModel {
|
||||
.append(mediaThumbnailHeight, c.mediaThumbnailHeight)
|
||||
.build();
|
||||
}
|
||||
|
||||
public boolean isRTL() {
|
||||
if (direction == Direction.RTL) {
|
||||
return true;
|
||||
} else if (direction == Direction.LTR) {
|
||||
return false;
|
||||
} else {
|
||||
// detect on the fly for content that was inserted before the direction field was added
|
||||
return FeedUtils.isRTL(title, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user