[SoundCloud] Use final when possible, ide refactorings

This commit is contained in:
Stypox 2020-04-11 17:18:05 +02:00
parent 06430c4749
commit 55bc01d1ce
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 44 additions and 38 deletions

View File

@ -68,8 +68,10 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
@Nonnull @Nonnull
@Override @Override
public String getTextualUploadDate() throws ParsingException { public String getTextualUploadDate() {
return track.getString("created_at").replace("T"," ").replace("Z", ""); return track.getString("created_at")
.replace("T"," ")
.replace("Z", "");
} }
@Nonnull @Nonnull
@ -85,10 +87,10 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
if (artworkUrl.isEmpty()) { if (artworkUrl.isEmpty()) {
artworkUrl = track.getObject("user").getString("avatar_url", EMPTY_STRING); artworkUrl = track.getObject("user").getString("avatar_url", EMPTY_STRING);
} }
String artworkUrlBetterResolution = artworkUrl.replace("large.jpg", "crop.jpg"); return artworkUrl.replace("large.jpg", "crop.jpg");
return artworkUrlBetterResolution;
} }
@Nonnull
@Override @Override
public Description getDescription() { public Description getDescription() {
return new Description(track.getString("description"), Description.PLAIN_TEXT); return new Description(track.getString("description"), Description.PLAIN_TEXT);
@ -144,19 +146,19 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
@Nonnull @Nonnull
@Override @Override
public String getSubChannelUrl() throws ParsingException { public String getSubChannelUrl() {
return ""; return "";
} }
@Nonnull @Nonnull
@Override @Override
public String getSubChannelName() throws ParsingException { public String getSubChannelName() {
return ""; return "";
} }
@Nonnull @Nonnull
@Override @Override
public String getSubChannelAvatarUrl() throws ParsingException { public String getSubChannelAvatarUrl() {
return ""; return "";
} }
@ -168,14 +170,14 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
@Nonnull @Nonnull
@Override @Override
public String getHlsUrl() throws ParsingException { public String getHlsUrl() {
return ""; return "";
} }
@Override @Override
public List<AudioStream> getAudioStreams() throws IOException, ExtractionException { public List<AudioStream> getAudioStreams() throws IOException, ExtractionException {
List<AudioStream> audioStreams = new ArrayList<>(); List<AudioStream> audioStreams = new ArrayList<>();
Downloader dl = NewPipe.getDownloader(); final Downloader dl = NewPipe.getDownloader();
// 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.
@ -183,12 +185,12 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
if (!track.getBoolean("streamable")) return audioStreams; if (!track.getBoolean("streamable")) return audioStreams;
try { try {
JsonArray transcodings = track.getObject("media").getArray("transcodings"); final JsonArray transcodings = track.getObject("media").getArray("transcodings");
// get information about what stream formats are available // get information about what stream formats are available
for (Object transcoding : transcodings) { for (Object transcoding : transcodings) {
JsonObject t = (JsonObject) transcoding; final JsonObject t = (JsonObject) transcoding;
String url = t.getString("url"); String url = t.getString("url");
if (!isNullOrEmpty(url)) { if (!isNullOrEmpty(url)) {
@ -200,7 +202,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
// This url points to the endpoint which generates a unique and short living url to the stream. // This url points to the endpoint which generates a unique and short living url to the stream.
// TODO: move this to a separate method to generate valid urls when needed (e.g. resuming a paused stream) // TODO: move this to a separate method to generate valid urls when needed (e.g. resuming a paused stream)
url += "?client_id=" + SoundcloudParsingHelper.clientId(); url += "?client_id=" + SoundcloudParsingHelper.clientId();
String res = dl.get(url).responseBody(); final String res = dl.get(url).responseBody();
try { try {
JsonObject mp3UrlObject = JsonParser.object().from(res); JsonObject mp3UrlObject = JsonParser.object().from(res);
@ -234,24 +236,24 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
} }
@Override @Override
public List<VideoStream> getVideoStreams() throws IOException, ExtractionException { public List<VideoStream> getVideoStreams() {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override @Override
public List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException { public List<VideoStream> getVideoOnlyStreams() {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override @Override
@Nonnull @Nonnull
public List<SubtitlesStream> getSubtitlesDefault() throws IOException, ExtractionException { public List<SubtitlesStream> getSubtitlesDefault() {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override @Override
@Nonnull @Nonnull
public List<SubtitlesStream> getSubtitles(MediaFormat format) throws IOException, ExtractionException { public List<SubtitlesStream> getSubtitles(MediaFormat format) {
return Collections.emptyList(); return Collections.emptyList();
} }
@ -262,10 +264,10 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
@Override @Override
public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException { public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException {
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
String apiUrl = "https://api-v2.soundcloud.com/tracks/" + urlEncode(getId()) + "/related" final String apiUrl = "https://api-v2.soundcloud.com/tracks/" + urlEncode(getId())
+ "?client_id=" + urlEncode(SoundcloudParsingHelper.clientId()); + "/related?client_id=" + urlEncode(SoundcloudParsingHelper.clientId());
SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl); SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl);
return collector; return collector;
@ -276,40 +278,44 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
return null; return null;
} }
@Nonnull
@Override @Override
public String getHost() throws ParsingException { public String getHost() {
return "";
}
@Nonnull
@Override
public String getPrivacy() {
return "";
}
@Nonnull
@Override
public String getCategory() {
return "";
}
@Nonnull
@Override
public String getLicence() {
return ""; return "";
} }
@Override @Override
public String getPrivacy() throws ParsingException { public Locale getLanguageInfo() {
return "";
}
@Override
public String getCategory() throws ParsingException {
return "";
}
@Override
public String getLicence() throws ParsingException {
return "";
}
@Override
public Locale getLanguageInfo() throws ParsingException {
return null; return null;
} }
@Nonnull @Nonnull
@Override @Override
public List<String> getTags() throws ParsingException { public List<String> getTags() {
return Collections.emptyList(); return Collections.emptyList();
} }
@Nonnull @Nonnull
@Override @Override
public String getSupportInfo() throws ParsingException { public String getSupportInfo() {
return ""; return "";
} }
} }