[Soundcloud] Fix checkstyle issues

This commit is contained in:
Stypox 2022-03-18 11:12:45 +01:00 committed by litetex
parent 9ab32cb2e7
commit 9dc17cd1ca
13 changed files with 127 additions and 74 deletions

View File

@ -44,7 +44,7 @@ import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class SoundcloudParsingHelper { public final class SoundcloudParsingHelper {
private static String clientId; private static String clientId;
public static final String SOUNDCLOUD_API_V2_URL = "https://api-v2.soundcloud.com/"; public static final String SOUNDCLOUD_API_V2_URL = "https://api-v2.soundcloud.com/";
@ -52,7 +52,9 @@ public class SoundcloudParsingHelper {
} }
public static synchronized String clientId() throws ExtractionException, IOException { public static synchronized String clientId() throws ExtractionException, IOException {
if (!isNullOrEmpty(clientId)) return clientId; if (!isNullOrEmpty(clientId)) {
return clientId;
}
final Downloader dl = NewPipe.getDownloader(); final Downloader dl = NewPipe.getDownloader();
@ -109,7 +111,7 @@ public class SoundcloudParsingHelper {
public static JsonObject resolveFor(@Nonnull final Downloader downloader, final String url) public static JsonObject resolveFor(@Nonnull final Downloader downloader, final String url)
throws IOException, ExtractionException { throws IOException, ExtractionException {
final String apiUrl = SOUNDCLOUD_API_V2_URL + "resolve" final String apiUrl = SOUNDCLOUD_API_V2_URL + "resolve"
+ "?url=" + URLEncoder.encode(url, UTF_8) + "?url=" + URLEncoder.encode(url, UTF_8)
+ "&client_id=" + clientId(); + "&client_id=" + clientId();
try { try {
@ -142,18 +144,20 @@ public class SoundcloudParsingHelper {
* *
* @return the resolved id * @return the resolved id
*/ */
public static String resolveIdWithWidgetApi(String urlString) throws IOException, public static String resolveIdWithWidgetApi(final String urlString) throws IOException,
ParsingException { ParsingException {
// Remove the tailing slash from URLs due to issues with the SoundCloud API // Remove the tailing slash from URLs due to issues with the SoundCloud API
if (urlString.charAt(urlString.length() - 1) == '/') urlString = urlString.substring(0, String fixedUrl = urlString;
urlString.length() - 1); if (fixedUrl.charAt(fixedUrl.length() - 1) == '/') {
fixedUrl = fixedUrl.substring(0, fixedUrl.length() - 1);
}
// Make URL lower case and remove m. and www. if it exists. // Make URL lower case and remove m. and www. if it exists.
// Without doing this, the widget API does not recognize the URL. // Without doing this, the widget API does not recognize the URL.
urlString = Utils.removeMAndWWWFromUrl(urlString.toLowerCase()); fixedUrl = Utils.removeMAndWWWFromUrl(fixedUrl.toLowerCase());
final URL url; final URL url;
try { try {
url = Utils.stringToURL(urlString); url = Utils.stringToURL(fixedUrl);
} catch (final MalformedURLException e) { } catch (final MalformedURLException e) {
throw new IllegalArgumentException("The given URL is not valid"); throw new IllegalArgumentException("The given URL is not valid");
} }
@ -225,8 +229,9 @@ public class SoundcloudParsingHelper {
String nextPageUrl; String nextPageUrl;
try { try {
nextPageUrl = responseObject.getString("next_href"); nextPageUrl = responseObject.getString("next_href");
if (!nextPageUrl.contains("client_id=")) nextPageUrl += "&client_id=" if (!nextPageUrl.contains("client_id=")) {
+ SoundcloudParsingHelper.clientId(); nextPageUrl += "&client_id=" + SoundcloudParsingHelper.clientId();
}
} catch (final Exception ignored) { } catch (final Exception ignored) {
nextPageUrl = ""; nextPageUrl = "";
} }
@ -291,8 +296,9 @@ public class SoundcloudParsingHelper {
String nextPageUrl; String nextPageUrl;
try { try {
nextPageUrl = responseObject.getString("next_href"); nextPageUrl = responseObject.getString("next_href");
if (!nextPageUrl.contains("client_id=")) nextPageUrl += "&client_id=" if (!nextPageUrl.contains("client_id=")) {
+ SoundcloudParsingHelper.clientId(); nextPageUrl += "&client_id=" + SoundcloudParsingHelper.clientId();
}
} catch (final Exception ignored) { } catch (final Exception ignored) {
nextPageUrl = ""; nextPageUrl = "";
} }

View File

@ -1,25 +1,42 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
import static java.util.Arrays.asList;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.comments.CommentsExtractor; import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.kiosk.KioskList; import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.extractor.linkhandler.*; import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;
import org.schabi.newpipe.extractor.localization.ContentCountry; import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.*; import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.*; import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChartsExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudCommentsExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudPlaylistExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudSearchExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudStreamExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudSubscriptionExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudSuggestionExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudChannelLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudChartsLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudCommentsLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudPlaylistLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory;
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudStreamLinkHandlerFactory;
import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
import java.util.List; import java.util.List;
import static java.util.Arrays.asList;
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
public class SoundcloudService extends StreamingService { public class SoundcloudService extends StreamingService {
public SoundcloudService(final int id) { public SoundcloudService(final int id) {

View File

@ -21,7 +21,6 @@ import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsing
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING; import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
@SuppressWarnings("WeakerAccess")
public class SoundcloudChannelExtractor extends ChannelExtractor { public class SoundcloudChannelExtractor extends ChannelExtractor {
private String userId; private String userId;
private JsonObject user; private JsonObject user;

View File

@ -25,9 +25,8 @@ public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtrac
@Override @Override
public String getThumbnailUrl() { public String getThumbnailUrl() {
String avatarUrl = itemObject.getString("avatar_url", EMPTY_STRING);
// An avatar URL with a better resolution // An avatar URL with a better resolution
return avatarUrl.replace("large.jpg", "crop.jpg"); return itemObject.getString("avatar_url", EMPTY_STRING).replace("large.jpg", "crop.jpg");
} }
@Override @Override

View File

@ -46,7 +46,7 @@ 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)) {
String artworkUrl = trackObject.getString(ARTWORK_URL_KEY, EMPTY_STRING); final String artworkUrl = trackObject.getString(ARTWORK_URL_KEY, EMPTY_STRING);
if (!artworkUrl.isEmpty()) { if (!artworkUrl.isEmpty()) {
// An artwork URL with a better resolution // An artwork URL with a better resolution
return artworkUrl.replace("large.jpg", "crop.jpg"); return artworkUrl.replace("large.jpg", "crop.jpg");
@ -56,7 +56,9 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
// Then look for track creator avatar url // Then look for track creator avatar url
final JsonObject creator = trackObject.getObject(USER_KEY); final JsonObject creator = trackObject.getObject(USER_KEY);
final String creatorAvatar = creator.getString(AVATAR_URL_KEY, EMPTY_STRING); final String creatorAvatar = creator.getString(AVATAR_URL_KEY, EMPTY_STRING);
if (!creatorAvatar.isEmpty()) return creatorAvatar; if (!creatorAvatar.isEmpty()) {
return creatorAvatar;
}
} }
} catch (final Exception ignored) { } catch (final Exception ignored) {
// Try other method // Try other method

View File

@ -4,7 +4,13 @@ import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException; import com.grack.nanojson.JsonParserException;
import org.schabi.newpipe.extractor.*;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.InfoItemExtractor;
import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader; import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
@ -76,9 +82,9 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
throw new ParsingException("Could not parse json response", e); throw new ParsingException("Could not parse json response", e);
} }
return new InfoItemsPage<>( return new InfoItemsPage<>(collectItems(searchCollection),
collectItems(searchCollection), getNextPageFromCurrentUrl(page.getUrl(),
getNextPageFromCurrentUrl(page.getUrl(), currentOffset -> currentOffset + ITEMS_PER_PAGE)); currentOffset -> currentOffset + ITEMS_PER_PAGE));
} }
@Override @Override
@ -103,7 +109,10 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId()); final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
for (final Object result : searchCollection) { for (final Object result : searchCollection) {
if (!(result instanceof JsonObject)) continue; if (!(result instanceof JsonObject)) {
continue;
}
final JsonObject searchResult = (JsonObject) result; final JsonObject searchResult = (JsonObject) result;
final String kind = searchResult.getString("kind", EMPTY_STRING); final String kind = searchResult.getString("kind", EMPTY_STRING);
switch (kind) { switch (kind) {
@ -122,7 +131,8 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
return collector; return collector;
} }
private Page getNextPageFromCurrentUrl(final String currentUrl, final IntUnaryOperator newPageOffsetCalculator) private Page getNextPageFromCurrentUrl(final String currentUrl,
final IntUnaryOperator newPageOffsetCalculator)
throws MalformedURLException, UnsupportedEncodingException { throws MalformedURLException, UnsupportedEncodingException {
final int currentPageOffset = Integer.parseInt( final int currentPageOffset = Integer.parseInt(
Parser.compatParseMap(new URL(currentUrl).getQuery()).get("offset")); Parser.compatParseMap(new URL(currentUrl).getQuery()).get("offset"));

View File

@ -1,11 +1,17 @@
package org.schabi.newpipe.extractor.services.soundcloud.extractors; package org.schabi.newpipe.extractor.services.soundcloud.extractors;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.SOUNDCLOUD_API_V2_URL;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException; import com.grack.nanojson.JsonParserException;
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader; import org.schabi.newpipe.extractor.downloader.Downloader;
@ -18,20 +24,22 @@ import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusContentException;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper; import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
import org.schabi.newpipe.extractor.stream.*; import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.stream.VideoStream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.SOUNDCLOUD_API_V2_URL; import javax.annotation.Nonnull;
import static org.schabi.newpipe.extractor.utils.Utils.*; import javax.annotation.Nullable;
public class SoundcloudStreamExtractor extends StreamExtractor { public class SoundcloudStreamExtractor extends StreamExtractor {
private JsonObject track; private JsonObject track;
@ -53,8 +61,10 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
if (policy.equals("SNIP")) { if (policy.equals("SNIP")) {
throw new SoundCloudGoPlusContentException(); throw new SoundCloudGoPlusContentException();
} }
if (policy.equals("BLOCK")) throw new GeographicRestrictionException( if (policy.equals("BLOCK")) {
throw new GeographicRestrictionException(
"This track is not available in user's country"); "This track is not available in user's country");
}
throw new ContentNotAvailableException("Content not available: policy " + policy); throw new ContentNotAvailableException("Content not available: policy " + policy);
} }
} }
@ -152,7 +162,9 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
// Streams can be streamable and downloadable - or explicitly not. // Streams can be streamable and downloadable - or explicitly not.
// For playing the track, it is only necessary to have a streamable track. // For playing the track, it is only necessary to have a streamable track.
// If this is not the case, this track might not be published yet. // If this is not the case, this track might not be published yet.
if (!track.getBoolean("streamable") || !isAvailable) return audioStreams; if (!track.getBoolean("streamable") || !isAvailable) {
return audioStreams;
}
try { try {
final JsonArray transcodings = track.getObject("media").getArray("transcodings"); final JsonArray transcodings = track.getObject("media").getArray("transcodings");
@ -172,8 +184,8 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
boolean presence = false; boolean presence = false;
for (final Object transcoding : transcodings) { for (final Object transcoding : transcodings) {
final JsonObject transcodingJsonObject = (JsonObject) transcoding; final JsonObject transcodingJsonObject = (JsonObject) transcoding;
if (transcodingJsonObject.getString("preset").contains("mp3") && if (transcodingJsonObject.getString("preset").contains("mp3")
transcodingJsonObject.getObject("format").getString("protocol") && transcodingJsonObject.getObject("format").getString("protocol")
.equals("progressive")) { .equals("progressive")) {
presence = true; presence = true;
break; break;
@ -345,10 +357,9 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
final List<String> tags = new ArrayList<>(); final List<String> tags = new ArrayList<>();
String escapedTag = ""; String escapedTag = "";
boolean isEscaped = false; boolean isEscaped = false;
for (int i = 0; i < tagList.length; i++) { for (final String tag : tagList) {
String tag = tagList[i];
if (tag.startsWith("\"")) { if (tag.startsWith("\"")) {
escapedTag += tagList[i].replace("\"", ""); escapedTag += tag.replace("\"", "");
isEscaped = true; isEscaped = true;
} else if (isEscaped) { } else if (isEscaped) {
if (tag.endsWith("\"")) { if (tag.endsWith("\"")) {
@ -358,7 +369,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
} else { } else {
escapedTag += " " + tag; escapedTag += " " + tag;
} }
} else if (!tag.isEmpty()){ } else if (!tag.isEmpty()) {
tags.add(tag); tags.add(tag);
} }
} }

View File

@ -34,7 +34,9 @@ public class SoundcloudSubscriptionExtractor extends SubscriptionExtractor {
@Override @Override
public List<SubscriptionItem> fromChannelUrl(final String channelUrl) throws IOException, public List<SubscriptionItem> fromChannelUrl(final String channelUrl) throws IOException,
ExtractionException { ExtractionException {
if (channelUrl == null) throw new InvalidSourceException("Channel url is null"); if (channelUrl == null) {
throw new InvalidSourceException("Channel url is null");
}
final String id; final String id;
try { try {
@ -53,18 +55,15 @@ public class SoundcloudSubscriptionExtractor extends SubscriptionExtractor {
return toSubscriptionItems(collector.getItems()); return toSubscriptionItems(collector.getItems());
} }
private String getUrlFrom(String channelUrl) { private String getUrlFrom(final String channelUrl) {
channelUrl = replaceHttpWithHttps(channelUrl); final String fixedUrl = replaceHttpWithHttps(channelUrl);
if (fixedUrl.startsWith(HTTPS)) {
if (!channelUrl.startsWith(HTTPS)) { return channelUrl;
if (!channelUrl.contains("soundcloud.com/")) { } else if (!fixedUrl.contains("soundcloud.com/")) {
channelUrl = "https://soundcloud.com/" + channelUrl; return "https://soundcloud.com/" + fixedUrl;
} else { } else {
channelUrl = HTTPS + channelUrl; return HTTPS + fixedUrl;
}
} }
return channelUrl;
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////

View File

@ -39,8 +39,9 @@ public class SoundcloudSuggestionExtractor extends SuggestionExtractor {
try { try {
final JsonArray collection = JsonParser.object().from(response).getArray("collection"); final JsonArray collection = JsonParser.object().from(response).getArray("collection");
for (final Object suggestion : collection) { for (final Object suggestion : collection) {
if (suggestion instanceof JsonObject) suggestions.add(((JsonObject) suggestion) if (suggestion instanceof JsonObject) {
.getString("query")); suggestions.add(((JsonObject) suggestion).getString("query"));
}
} }
return suggestions; return suggestions;

View File

@ -8,14 +8,17 @@ import org.schabi.newpipe.extractor.utils.Utils;
import java.util.List; import java.util.List;
public class SoundcloudChannelLinkHandlerFactory extends ListLinkHandlerFactory { public final class SoundcloudChannelLinkHandlerFactory extends ListLinkHandlerFactory {
private static final SoundcloudChannelLinkHandlerFactory instance = private static final SoundcloudChannelLinkHandlerFactory INSTANCE
new SoundcloudChannelLinkHandlerFactory(); = new SoundcloudChannelLinkHandlerFactory();
private static final String URL_PATTERN ="^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" private static final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+"
+ "(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$"; + "(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$";
private SoundcloudChannelLinkHandlerFactory() {
}
public static SoundcloudChannelLinkHandlerFactory getInstance() { public static SoundcloudChannelLinkHandlerFactory getInstance() {
return instance; return INSTANCE;
} }

View File

@ -9,13 +9,16 @@ import java.util.List;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.clientId; import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.clientId;
public class SoundcloudCommentsLinkHandlerFactory extends ListLinkHandlerFactory { public final class SoundcloudCommentsLinkHandlerFactory extends ListLinkHandlerFactory {
private static final SoundcloudCommentsLinkHandlerFactory instance = private static final SoundcloudCommentsLinkHandlerFactory INSTANCE =
new SoundcloudCommentsLinkHandlerFactory(); new SoundcloudCommentsLinkHandlerFactory();
private SoundcloudCommentsLinkHandlerFactory() {
}
public static SoundcloudCommentsLinkHandlerFactory getInstance() { public static SoundcloudCommentsLinkHandlerFactory getInstance() {
return instance; return INSTANCE;
} }
@Override @Override

View File

@ -8,14 +8,17 @@ import org.schabi.newpipe.extractor.utils.Utils;
import java.util.List; import java.util.List;
public class SoundcloudPlaylistLinkHandlerFactory extends ListLinkHandlerFactory { public final class SoundcloudPlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
private static final SoundcloudPlaylistLinkHandlerFactory instance = private static final SoundcloudPlaylistLinkHandlerFactory INSTANCE =
new SoundcloudPlaylistLinkHandlerFactory(); new SoundcloudPlaylistLinkHandlerFactory();
private static final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" private static final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+"
+ "/sets/[0-9a-z_-]+/?([#?].*)?$"; + "/sets/[0-9a-z_-]+/?([#?].*)?$";
private SoundcloudPlaylistLinkHandlerFactory() {
}
public static SoundcloudPlaylistLinkHandlerFactory getInstance() { public static SoundcloudPlaylistLinkHandlerFactory getInstance() {
return instance; return INSTANCE;
} }
@Override @Override

View File

@ -6,9 +6,9 @@ import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser;
import org.schabi.newpipe.extractor.utils.Utils; import org.schabi.newpipe.extractor.utils.Utils;
public class SoundcloudStreamLinkHandlerFactory extends LinkHandlerFactory { public final class SoundcloudStreamLinkHandlerFactory extends LinkHandlerFactory {
private static final SoundcloudStreamLinkHandlerFactory instance = private static final SoundcloudStreamLinkHandlerFactory INSTANCE
new SoundcloudStreamLinkHandlerFactory(); = new SoundcloudStreamLinkHandlerFactory();
private static final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" private static final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+"
+ "/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$"; + "/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$";
@ -16,7 +16,7 @@ public class SoundcloudStreamLinkHandlerFactory extends LinkHandlerFactory {
} }
public static SoundcloudStreamLinkHandlerFactory getInstance() { public static SoundcloudStreamLinkHandlerFactory getInstance() {
return instance; return INSTANCE;
} }
@Override @Override