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