Move SoundcloudExtractorHelper methods to SoundcloudParsingHelper
This commit is contained in:
parent
7716b14378
commit
c08cef9331
|
@ -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", "");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -21,9 +21,14 @@ import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class SoundcloudParsingHelper {
|
public class SoundcloudParsingHelper {
|
||||||
private static String clientId;
|
private static String clientId;
|
||||||
|
|
||||||
|
private static final String HTTP = "http://";
|
||||||
|
private static final String HTTPS = "https://";
|
||||||
|
|
||||||
private SoundcloudParsingHelper() {
|
private SoundcloudParsingHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,4 +163,27 @@ public class SoundcloudParsingHelper {
|
||||||
public static String getStreamsFromApi(StreamInfoItemCollector collector, String apiUrl) throws ReCaptchaException, ParsingException, IOException {
|
public static String getStreamsFromApi(StreamInfoItemCollector collector, String apiUrl) throws ReCaptchaException, ParsingException, IOException {
|
||||||
return getStreamsFromApi(collector, apiUrl, false);
|
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", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,17 +68,17 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderUrl() {
|
public String getUploaderUrl() {
|
||||||
return SoundcloudExtractorHelper.getUploaderUrl(playlist);
|
return SoundcloudParsingHelper.getUploaderUrl(playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderName() {
|
public String getUploaderName() {
|
||||||
return SoundcloudExtractorHelper.getUploaderName(playlist);
|
return SoundcloudParsingHelper.getUploaderName(playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderAvatarUrl() {
|
public String getUploaderAvatarUrl() {
|
||||||
return SoundcloudExtractorHelper.getAvatarUrl(playlist);
|
return SoundcloudParsingHelper.getAvatarUrl(playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -102,19 +102,19 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderUrl() {
|
public String getUploaderUrl() {
|
||||||
return SoundcloudExtractorHelper.getUploaderUrl(track);
|
return SoundcloudParsingHelper.getUploaderUrl(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderName() {
|
public String getUploaderName() {
|
||||||
return SoundcloudExtractorHelper.getUploaderName(track);
|
return SoundcloudParsingHelper.getUploaderName(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderAvatarUrl() {
|
public String getUploaderAvatarUrl() {
|
||||||
return SoundcloudExtractorHelper.getAvatarUrl(track);
|
return SoundcloudParsingHelper.getAvatarUrl(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue