From 2a24d407d521cc2daf7d7366a89e5f17b92a8333 Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:00:49 +0100 Subject: [PATCH 1/2] [SoundCloud] Fix extraction of tracks like count SoundCloud is using likes_count to return the like count of a track, like it was the case before they switched to favoritings_count. --- .../soundcloud/extractors/SoundcloudStreamExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java index 150aaf8eb..22d4d4bea 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java @@ -133,7 +133,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor { @Override public long getLikeCount() { - return track.getLong("favoritings_count", -1); + return track.getLong("likes_count", -1); } @Nonnull From 676622f6dfbabab9e6b3950c5de315a90f30d822 Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:08:02 +0100 Subject: [PATCH 2/2] [SoundCloud] Fix expectedLikeCountAtLeast tests of SoundcloudStreamExtractorTest test classes As like count is now returned by the extractor, we need to assert a positive minimum like count, which is close to the actual value, in order to avoid test failures due to lower like counts than the ones excepted. --- .../soundcloud/SoundcloudStreamExtractorTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorTest.java index da2c0511d..fd0de8604 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorTest.java @@ -22,7 +22,8 @@ import java.util.List; import javax.annotation.Nullable; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; public class SoundcloudStreamExtractorTest { @@ -64,7 +65,7 @@ public class SoundcloudStreamExtractorTest { @Override public long expectedViewCountAtLeast() { return 43000; } @Nullable @Override public String expectedUploadDate() { return "2019-05-16 16:28:45.000"; } @Nullable @Override public String expectedTextualUploadDate() { return "2019-05-16 16:28:45"; } - @Override public long expectedLikeCountAtLeast() { return -1; } + @Override public long expectedLikeCountAtLeast() { return 600; } @Override public long expectedDislikeCountAtLeast() { return -1; } @Override public boolean expectedHasAudioStreams() { return false; } @Override public boolean expectedHasVideoStreams() { return false; } @@ -127,7 +128,7 @@ public class SoundcloudStreamExtractorTest { @Override public long expectedViewCountAtLeast() { return 386000; } @Nullable @Override public String expectedUploadDate() { return "2016-11-11 01:16:37.000"; } @Nullable @Override public String expectedTextualUploadDate() { return "2016-11-11 01:16:37"; } - @Override public long expectedLikeCountAtLeast() { return -1; } + @Override public long expectedLikeCountAtLeast() { return 7350; } @Override public long expectedDislikeCountAtLeast() { return -1; } @Override public boolean expectedHasAudioStreams() { return false; } @Override public boolean expectedHasVideoStreams() { return false; } @@ -170,7 +171,7 @@ public class SoundcloudStreamExtractorTest { @Override public long expectedViewCountAtLeast() { return 27000; } @Nullable @Override public String expectedUploadDate() { return "2019-03-28 13:36:18.000"; } @Nullable @Override public String expectedTextualUploadDate() { return "2019-03-28 13:36:18"; } - @Override public long expectedLikeCountAtLeast() { return -1; } + @Override public long expectedLikeCountAtLeast() { return 25; } @Override public long expectedDislikeCountAtLeast() { return -1; } @Override public boolean expectedHasVideoStreams() { return false; } @Override public boolean expectedHasSubtitles() { return false; }