mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 06:10:33 +05:30
[SoundCloud] Improve thumbnail url extraction in playlists
Prevent NullPointerExceptions and remove duplicate code
This commit is contained in:
parent
f3095713f9
commit
d0e66cc600
@ -66,6 +66,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
|||||||
return playlist.getString("title");
|
return playlist.getString("title");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String getThumbnailUrl() {
|
public String getThumbnailUrl() {
|
||||||
String artworkUrl = playlist.getString("artwork_url");
|
String artworkUrl = playlist.getString("artwork_url");
|
||||||
@ -75,21 +76,20 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
|||||||
// if it also fails, return null
|
// if it also fails, return null
|
||||||
try {
|
try {
|
||||||
final InfoItemsPage<StreamInfoItem> infoItems = getInitialPage();
|
final InfoItemsPage<StreamInfoItem> infoItems = getInitialPage();
|
||||||
if (infoItems.getItems().isEmpty()) return null;
|
|
||||||
|
|
||||||
for (StreamInfoItem item : infoItems.getItems()) {
|
for (StreamInfoItem item : infoItems.getItems()) {
|
||||||
final String thumbnailUrl = item.getThumbnailUrl();
|
artworkUrl = item.getThumbnailUrl();
|
||||||
if (thumbnailUrl == null || thumbnailUrl.isEmpty()) continue;
|
if (artworkUrl != null && !artworkUrl.isEmpty()) break;
|
||||||
|
|
||||||
String thumbnailUrlBetterResolution = thumbnailUrl.replace("large.jpg", "crop.jpg");
|
|
||||||
return thumbnailUrlBetterResolution;
|
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (artworkUrl == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String artworkUrlBetterResolution = artworkUrl.replace("large.jpg", "crop.jpg");
|
return artworkUrl.replace("large.jpg", "crop.jpg");
|
||||||
return artworkUrlBetterResolution;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user