11package org .schabi .newpipe .extractor .services .soundcloud ;
22
3- import static org .schabi .newpipe .extractor .ServiceList .SoundCloud ;
4- import static org .schabi .newpipe .extractor .utils .Utils .isNullOrEmpty ;
5- import static org .schabi .newpipe .extractor .utils .Utils .replaceHttpWithHttps ;
6-
73import com .grack .nanojson .JsonArray ;
84import com .grack .nanojson .JsonObject ;
95import com .grack .nanojson .JsonParser ;
106import com .grack .nanojson .JsonParserException ;
11-
127import org .jsoup .Jsoup ;
138import org .jsoup .nodes .Document ;
149import org .jsoup .nodes .Element ;
2823import org .schabi .newpipe .extractor .utils .Parser .RegexException ;
2924import org .schabi .newpipe .extractor .utils .Utils ;
3025
26+ import javax .annotation .Nonnull ;
3127import java .io .IOException ;
3228import java .net .MalformedURLException ;
3329import java .net .URL ;
3834import java .util .List ;
3935import java .util .Map ;
4036
41- import javax .annotation .Nonnull ;
37+ import static org .schabi .newpipe .extractor .ServiceList .SoundCloud ;
38+ import static org .schabi .newpipe .extractor .utils .Utils .isNullOrEmpty ;
39+ import static org .schabi .newpipe .extractor .utils .Utils .replaceHttpWithHttps ;
4240
4341public final class SoundcloudParsingHelper {
4442 private static String clientId ;
@@ -200,6 +198,7 @@ public static String getUsersFromApiMinItems(final int minItems,
200198 *
201199 * @return the next streams url, empty if don't have
202200 */
201+ @ Nonnull
203202 public static String getUsersFromApi (final ChannelInfoItemsCollector collector ,
204203 final String apiUrl ) throws IOException ,
205204 ReCaptchaException , ParsingException {
@@ -221,17 +220,7 @@ public static String getUsersFromApi(final ChannelInfoItemsCollector collector,
221220 }
222221 }
223222
224- String nextPageUrl ;
225- try {
226- nextPageUrl = responseObject .getString ("next_href" );
227- if (!nextPageUrl .contains ("client_id=" )) {
228- nextPageUrl += "&client_id=" + SoundcloudParsingHelper .clientId ();
229- }
230- } catch (final Exception ignored ) {
231- nextPageUrl = "" ;
232- }
233-
234- return nextPageUrl ;
223+ return getNextPageUrl (responseObject );
235224 }
236225
237226 /**
@@ -261,6 +250,7 @@ public static String getStreamsFromApiMinItems(final int minItems,
261250 *
262251 * @return the next streams url, empty if don't have
263252 */
253+ @ Nonnull
264254 public static String getStreamsFromApi (final StreamInfoItemsCollector collector ,
265255 final String apiUrl ,
266256 final boolean charts ) throws IOException ,
@@ -288,17 +278,20 @@ public static String getStreamsFromApi(final StreamInfoItemsCollector collector,
288278 }
289279 }
290280
291- String nextPageUrl ;
281+ return getNextPageUrl (responseObject );
282+ }
283+
284+ @ Nonnull
285+ private static String getNextPageUrl (@ Nonnull final JsonObject response ) {
292286 try {
293- nextPageUrl = responseObject .getString ("next_href" );
287+ String nextPageUrl = response .getString ("next_href" );
294288 if (!nextPageUrl .contains ("client_id=" )) {
295289 nextPageUrl += "&client_id=" + SoundcloudParsingHelper .clientId ();
296290 }
291+ return nextPageUrl ;
297292 } catch (final Exception ignored ) {
298- nextPageUrl = "" ;
293+ return "" ;
299294 }
300-
301- return nextPageUrl ;
302295 }
303296
304297 public static String getStreamsFromApi (final StreamInfoItemsCollector collector ,
0 commit comments