11package org .schabi .newpipe .extractor .services .soundcloud .extractors ;
22
3+ import static org .schabi .newpipe .extractor .services .soundcloud .SoundcloudParsingHelper .SOUNDCLOUD_API_V2_URL ;
4+ import static org .schabi .newpipe .extractor .services .soundcloud .SoundcloudParsingHelper .getAllImagesFromArtworkOrAvatarUrl ;
5+ import static org .schabi .newpipe .extractor .services .soundcloud .SoundcloudParsingHelper .getAvatarUrl ;
6+ import static org .schabi .newpipe .extractor .utils .Utils .isNullOrEmpty ;
7+
38import com .grack .nanojson .JsonArray ;
49import com .grack .nanojson .JsonObject ;
510import com .grack .nanojson .JsonParser ;
611import com .grack .nanojson .JsonParserException ;
12+
13+ import org .schabi .newpipe .extractor .Image ;
714import org .schabi .newpipe .extractor .NewPipe ;
815import org .schabi .newpipe .extractor .Page ;
916import org .schabi .newpipe .extractor .StreamingService ;
2431import java .util .List ;
2532import java .util .Objects ;
2633
27- import static org .schabi .newpipe .extractor .services .soundcloud .SoundcloudParsingHelper .SOUNDCLOUD_API_V2_URL ;
28- import static org .schabi .newpipe .extractor .utils .Utils .isNullOrEmpty ;
29-
3034public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
3135 private static final int STREAMS_PER_REQUESTED_PAGE = 15 ;
3236
@@ -68,30 +72,28 @@ public String getName() {
6872
6973 @ Nonnull
7074 @ Override
71- public String getThumbnailUrl () {
72- String artworkUrl = playlist .getString ("artwork_url" );
73-
74- if (artworkUrl == null ) {
75- // If the thumbnail is null, traverse the items list and get a valid one,
76- // if it also fails, return null
77- try {
78- final InfoItemsPage <StreamInfoItem > infoItems = getInitialPage ();
79-
80- for (final StreamInfoItem item : infoItems .getItems ()) {
81- artworkUrl = item .getThumbnailUrl ();
82- if (!isNullOrEmpty (artworkUrl )) {
83- break ;
84- }
85- }
86- } catch (final Exception ignored ) {
87- }
75+ public List <Image > getThumbnails () {
76+ final String artworkUrl = playlist .getString ("artwork_url" );
77+
78+ if (!isNullOrEmpty (artworkUrl )) {
79+ return getAllImagesFromArtworkOrAvatarUrl (artworkUrl );
80+ }
8881
89- if (artworkUrl == null ) {
90- return "" ;
82+ // If the thumbnail is null or empty, traverse the items list and get a valid one
83+ // If it also fails, return an empty list
84+ try {
85+ final InfoItemsPage <StreamInfoItem > infoItems = getInitialPage ();
86+
87+ for (final StreamInfoItem item : infoItems .getItems ()) {
88+ final List <Image > thumbnails = item .getThumbnails ();
89+ if (!isNullOrEmpty (thumbnails )) {
90+ return thumbnails ;
91+ }
9192 }
93+ } catch (final Exception ignored ) {
9294 }
9395
94- return artworkUrl . replace ( "large.jpg" , "crop.jpg" );
96+ return List . of ( );
9597 }
9698
9799 @ Override
@@ -104,9 +106,10 @@ public String getUploaderName() {
104106 return SoundcloudParsingHelper .getUploaderName (playlist );
105107 }
106108
109+ @ Nonnull
107110 @ Override
108- public String getUploaderAvatarUrl () {
109- return SoundcloudParsingHelper . getAvatarUrl (playlist );
111+ public List < Image > getUploaderAvatars () {
112+ return getAllImagesFromArtworkOrAvatarUrl ( getAvatarUrl (playlist ) );
110113 }
111114
112115 @ Override
0 commit comments