From c08cef9331a4357b5afeafb63bccbf7e0648d2ac Mon Sep 17 00:00:00 2001 From: wb9688 Date: Wed, 21 Feb 2018 09:23:57 +0100 Subject: [PATCH] Move SoundcloudExtractorHelper methods to SoundcloudParsingHelper --- .../soundcloud/SoundcloudExtractorHelper.java | 35 ------------------- .../soundcloud/SoundcloudParsingHelper.java | 28 +++++++++++++++ .../SoundcloudPlaylistExtractor.java | 6 ++-- .../soundcloud/SoundcloudStreamExtractor.java | 6 ++-- 4 files changed, 34 insertions(+), 41 deletions(-) delete mode 100644 src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudExtractorHelper.java diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudExtractorHelper.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudExtractorHelper.java deleted file mode 100644 index 7ac81edd5..000000000 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudExtractorHelper.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.schabi.newpipe.extractor.services.soundcloud; - -import com.grack.nanojson.JsonObject; - -import javax.annotation.Nonnull; - -public class SoundcloudExtractorHelper { - - private static final String HTTP = "http://"; - private static final String HTTPS = "https://"; - - - private static String replaceHttpWithHttps(final String url) { - if(!url.isEmpty() && url.startsWith(HTTP)) { - return HTTPS + url.substring(HTTP.length()); - } - return url; - } - - @Nonnull - static String getUploaderUrl(JsonObject object) { - String url = object.getObject("user").getString("permalink_url", ""); - return replaceHttpWithHttps(url); - } - - @Nonnull - static String getAvatarUrl(JsonObject object) { - String url = object.getObject("user", new JsonObject()).getString("avatar_url", ""); - return replaceHttpWithHttps(url); - } - - public static String getUploaderName(JsonObject object) { - return object.getObject("user").getString("username", ""); - } -} diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java index f68fff07a..633f82028 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java @@ -21,9 +21,14 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import javax.annotation.Nonnull; + public class SoundcloudParsingHelper { private static String clientId; + private static final String HTTP = "http://"; + private static final String HTTPS = "https://"; + private SoundcloudParsingHelper() { } @@ -158,4 +163,27 @@ public class SoundcloudParsingHelper { public static String getStreamsFromApi(StreamInfoItemCollector collector, String apiUrl) throws ReCaptchaException, ParsingException, IOException { return getStreamsFromApi(collector, apiUrl, false); } + + private static String replaceHttpWithHttps(final String url) { + if(!url.isEmpty() && url.startsWith(HTTP)) { + return HTTPS + url.substring(HTTP.length()); + } + return url; + } + + @Nonnull + static String getUploaderUrl(JsonObject object) { + String url = object.getObject("user").getString("permalink_url", ""); + return replaceHttpWithHttps(url); + } + + @Nonnull + static String getAvatarUrl(JsonObject object) { + String url = object.getObject("user", new JsonObject()).getString("avatar_url", ""); + return replaceHttpWithHttps(url); + } + + public static String getUploaderName(JsonObject object) { + return object.getObject("user").getString("username", ""); + } } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java index e0ea4a011..a5391db73 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java @@ -68,17 +68,17 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { @Override public String getUploaderUrl() { - return SoundcloudExtractorHelper.getUploaderUrl(playlist); + return SoundcloudParsingHelper.getUploaderUrl(playlist); } @Override public String getUploaderName() { - return SoundcloudExtractorHelper.getUploaderName(playlist); + return SoundcloudParsingHelper.getUploaderName(playlist); } @Override public String getUploaderAvatarUrl() { - return SoundcloudExtractorHelper.getAvatarUrl(playlist); + return SoundcloudParsingHelper.getAvatarUrl(playlist); } @Override diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java index 027ee6999..9672c63cd 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java @@ -102,19 +102,19 @@ public class SoundcloudStreamExtractor extends StreamExtractor { @Nonnull @Override public String getUploaderUrl() { - return SoundcloudExtractorHelper.getUploaderUrl(track); + return SoundcloudParsingHelper.getUploaderUrl(track); } @Nonnull @Override public String getUploaderName() { - return SoundcloudExtractorHelper.getUploaderName(track); + return SoundcloudParsingHelper.getUploaderName(track); } @Nonnull @Override public String getUploaderAvatarUrl() { - return SoundcloudExtractorHelper.getAvatarUrl(track); + return SoundcloudParsingHelper.getAvatarUrl(track); } @Override