Fetch better quality thumbnails
and fallback to avatar thumbnail if track thumbnail isn't found
This commit is contained in:
parent
d22786b817
commit
c7974b2aed
|
@ -24,7 +24,9 @@ public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtrac
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getThumbnailUrl() {
|
public String getThumbnailUrl() {
|
||||||
return itemObject.getString("avatar_url", "");
|
String avatarUrl = itemObject.getString("avatar_url", "");
|
||||||
|
String avatarUrlBetterResolution = avatarUrl.replace("large.jpg", "crop.jpg");
|
||||||
|
return avatarUrlBetterResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -71,13 +71,15 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
||||||
final String thumbnailUrl = item.getThumbnailUrl();
|
final String thumbnailUrl = item.getThumbnailUrl();
|
||||||
if (thumbnailUrl == null || thumbnailUrl.isEmpty()) continue;
|
if (thumbnailUrl == null || thumbnailUrl.isEmpty()) continue;
|
||||||
|
|
||||||
return thumbnailUrl;
|
String thumbnailUrlBetterResolution = thumbnailUrl.replace("large.jpg", "crop.jpg");
|
||||||
|
return thumbnailUrlBetterResolution;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return artworkUrl;
|
String artworkUrlBetterResolution = artworkUrl.replace("large.jpg", "crop.jpg");
|
||||||
|
return artworkUrlBetterResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,7 +32,10 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
|
||||||
// Over-engineering at its finest
|
// Over-engineering at its finest
|
||||||
if (itemObject.isString(ARTWORK_URL_KEY)) {
|
if (itemObject.isString(ARTWORK_URL_KEY)) {
|
||||||
final String artworkUrl = itemObject.getString(ARTWORK_URL_KEY, "");
|
final String artworkUrl = itemObject.getString(ARTWORK_URL_KEY, "");
|
||||||
if (!artworkUrl.isEmpty()) return artworkUrl;
|
if (!artworkUrl.isEmpty()) {
|
||||||
|
String artworkUrlBetterResolution = artworkUrl.replace("large.jpg", "crop.jpg");
|
||||||
|
return artworkUrlBetterResolution;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -42,8 +45,11 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
|
||||||
|
|
||||||
// First look for track artwork url
|
// First look for track artwork url
|
||||||
if (trackObject.isString(ARTWORK_URL_KEY)) {
|
if (trackObject.isString(ARTWORK_URL_KEY)) {
|
||||||
final String url = trackObject.getString(ARTWORK_URL_KEY, "");
|
String artworkUrl = trackObject.getString(ARTWORK_URL_KEY, "");
|
||||||
if (!url.isEmpty()) return url;
|
if (!artworkUrl.isEmpty()) {
|
||||||
|
String artworkUrlBetterResolution = artworkUrl.replace("large.jpg", "crop.jpg");
|
||||||
|
return artworkUrlBetterResolution;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then look for track creator avatar url
|
// Then look for track creator avatar url
|
||||||
|
|
|
@ -57,7 +57,12 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getThumbnailUrl() {
|
public String getThumbnailUrl() {
|
||||||
return track.getString("artwork_url", "");
|
String artworkUrl = track.getString("artwork_url", "");
|
||||||
|
if (artworkUrl.isEmpty()) {
|
||||||
|
artworkUrl = track.getObject("user").getString("avatar_url", "");
|
||||||
|
}
|
||||||
|
String artworkUrlBetterResolution = artworkUrl.replace("large.jpg", "crop.jpg");
|
||||||
|
return artworkUrlBetterResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
|
@ -52,7 +52,12 @@ public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtracto
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getThumbnailUrl() {
|
public String getThumbnailUrl() {
|
||||||
return itemObject.getString("artwork_url");
|
String artworkUrl = itemObject.getString("artwork_url", "");
|
||||||
|
if (artworkUrl.isEmpty()) {
|
||||||
|
artworkUrl = itemObject.getObject("user").getString("avatar_url");
|
||||||
|
}
|
||||||
|
String artworkUrlBetterResolution = artworkUrl.replace("large.jpg", "crop.jpg");
|
||||||
|
return artworkUrlBetterResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue