[SoundCloud] Migrate StreamExtractor to api-v2

This commit is contained in:
Stypox 2020-03-17 18:06:13 +01:00
parent 5e4ddb368f
commit 4389fd3b7b
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
3 changed files with 7 additions and 5 deletions

View File

@ -108,7 +108,7 @@ public class SoundcloudParsingHelper {
* See https://developers.soundcloud.com/docs/api/reference#resolve
*/
public static JsonObject resolveFor(Downloader downloader, String url) throws IOException, ExtractionException {
String apiUrl = "https://api.soundcloud.com/resolve"
String apiUrl = "https://api-v2.soundcloud.com/resolve"
+ "?url=" + URLEncoder.encode(url, "UTF-8")
+ "&client_id=" + clientId();

View File

@ -19,6 +19,8 @@ import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -55,14 +57,14 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
@Nonnull
@Override
public String getTextualUploadDate() {
return track.getString("created_at");
public String getTextualUploadDate() throws ParsingException {
return track.getString("created_at").replace("T"," ").replace("Z", "");
}
@Nonnull
@Override
public DateWrapper getUploadDate() throws ParsingException {
return new DateWrapper(SoundcloudParsingHelper.parseDate(getTextualUploadDate()));
return new DateWrapper(SoundcloudParsingHelper.parseDate(track.getString("created_at")));
}
@Nonnull

View File

@ -74,7 +74,7 @@ public class SoundcloudStreamExtractorDefaultTest {
@Test
public void testGetTextualUploadDate() throws ParsingException {
Assert.assertEquals("2016/07/31 18:18:07 +0000", extractor.getTextualUploadDate());
Assert.assertEquals("2016-07-31 18:18:07", extractor.getTextualUploadDate());
}
@Test