Merge branch 'dev' of github.com:TeamNewPipe/NewPipeExtractor into channel-tabs

This commit is contained in:
ThetaDev 2023-05-01 17:56:52 +02:00
commit d868746e50
5 changed files with 22 additions and 21 deletions

View File

@ -35,7 +35,7 @@ jobs:
# See gradle file for difference between downloaders # See gradle file for difference between downloaders
- name: Build and run Tests - name: Build and run Tests
run: | run: |
if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then if [[ "$GITHUB_EVENT_NAME" == 'schedule' ]]; then
echo running with real downloader echo running with real downloader
./gradlew check --stacktrace -Ddownloader=REAL ./gradlew check --stacktrace -Ddownloader=REAL
else else

View File

@ -18,13 +18,13 @@ import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChanne
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelTabLinkHandlerFactory; import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelTabLinkHandlerFactory;
import org.schabi.newpipe.extractor.utils.JsonUtils; import org.schabi.newpipe.extractor.utils.JsonUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull;
public class PeertubeAccountExtractor extends ChannelExtractor { public class PeertubeAccountExtractor extends ChannelExtractor {
private JsonObject json; private JsonObject json;
private final String baseUrl; private final String baseUrl;
@ -86,13 +86,10 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
return subscribersCount; return subscribersCount;
} }
@Nullable
@Override @Override
public String getDescription() { public String getDescription() {
try { return json.getString("description");
return JsonUtils.getString(json, "description");
} catch (final ParsingException e) {
return "No description";
}
} }
@Override @Override

View File

@ -16,13 +16,13 @@ import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChanne
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelTabLinkHandlerFactory; import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelTabLinkHandlerFactory;
import org.schabi.newpipe.extractor.utils.JsonUtils; import org.schabi.newpipe.extractor.utils.JsonUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull;
public class PeertubeChannelExtractor extends ChannelExtractor { public class PeertubeChannelExtractor extends ChannelExtractor {
private JsonObject json; private JsonObject json;
private final String baseUrl; private final String baseUrl;
@ -59,13 +59,10 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
return json.getLong("followersCount"); return json.getLong("followersCount");
} }
@Nullable
@Override @Override
public String getDescription() { public String getDescription() {
try { return json.getString("description");
return JsonUtils.getString(json, "description");
} catch (final ParsingException e) {
return "No description";
}
} }
@Override @Override

View File

@ -13,7 +13,11 @@ import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeAccount
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
@ -76,7 +80,7 @@ public class PeertubeAccountExtractorTest {
@Test @Test
@Override @Override
public void testDescription() throws ParsingException { public void testDescription() throws ParsingException {
assertNotNull(extractor.getDescription()); assertNull(extractor.getDescription());
} }
@Test @Test

View File

@ -28,7 +28,7 @@ public class YouTubeChannelTabExtractorTest {
YoutubeTestsUtils.ensureStateless(); YoutubeTestsUtils.ensureStateless();
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "playlists")); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "playlists"));
extractor = (YoutubeChannelTabExtractor) YouTube.getChannelTabExtractorFromId( extractor = (YoutubeChannelTabExtractor) YouTube.getChannelTabExtractorFromId(
"UC2DjFE7Xf11URZqWBigcVOQ", ChannelTabs.PLAYLISTS); "channel/UC2DjFE7Xf11URZqWBigcVOQ", ChannelTabs.PLAYLISTS);
extractor.fetchPage(); extractor.fetchPage();
} }
@ -87,7 +87,8 @@ public class YouTubeChannelTabExtractorTest {
public static void setUp() throws IOException, ExtractionException { public static void setUp() throws IOException, ExtractionException {
YoutubeTestsUtils.ensureStateless(); YoutubeTestsUtils.ensureStateless();
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "channels")); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "channels"));
extractor = (YoutubeChannelTabExtractor) YouTube.getChannelTabExtractorFromId("UC2DjFE7Xf11URZqWBigcVOQ", ChannelTabs.CHANNELS); extractor = (YoutubeChannelTabExtractor) YouTube.getChannelTabExtractorFromId(
"channel/UC2DjFE7Xf11URZqWBigcVOQ", ChannelTabs.CHANNELS);
extractor.fetchPage(); extractor.fetchPage();
} }
@ -145,7 +146,8 @@ public class YouTubeChannelTabExtractorTest {
public static void setUp() throws IOException, ExtractionException { public static void setUp() throws IOException, ExtractionException {
YoutubeTestsUtils.ensureStateless(); YoutubeTestsUtils.ensureStateless();
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "livestreams")); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "livestreams"));
extractor = (YoutubeChannelTabExtractor) YouTube.getChannelTabExtractorFromId("UCR-DXc1voovS8nhAvccRZhg", ChannelTabs.LIVESTREAMS); extractor = (YoutubeChannelTabExtractor) YouTube.getChannelTabExtractorFromId(
"channel/UCR-DXc1voovS8nhAvccRZhg", ChannelTabs.LIVESTREAMS);
extractor.fetchPage(); extractor.fetchPage();
} }
@ -203,7 +205,8 @@ public class YouTubeChannelTabExtractorTest {
public static void setUp() throws IOException, ExtractionException { public static void setUp() throws IOException, ExtractionException {
YoutubeTestsUtils.ensureStateless(); YoutubeTestsUtils.ensureStateless();
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "shorts")); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "shorts"));
extractor = (YoutubeChannelTabExtractor) YouTube.getChannelTabExtractorFromId("UCh8gHdtzO2tXd593_bjErWg", ChannelTabs.SHORTS); extractor = (YoutubeChannelTabExtractor) YouTube.getChannelTabExtractorFromId(
"channel/UCh8gHdtzO2tXd593_bjErWg", ChannelTabs.SHORTS);
extractor.fetchPage(); extractor.fetchPage();
} }