2018-05-26 19:15:45 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.youtube.extractors;
|
|
|
|
|
2022-03-27 20:51:30 +02:00
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
|
2022-03-18 15:09:06 +01:00
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
|
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonPostResponse;
|
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getKey;
|
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
|
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder;
|
2023-10-07 20:38:58 +02:00
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.ALL;
|
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.CHANNELS;
|
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.PLAYLISTS;
|
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.VIDEOS;
|
2022-03-18 15:09:06 +01:00
|
|
|
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.getSearchParameter;
|
|
|
|
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
|
|
|
|
|
|
|
import com.grack.nanojson.JsonArray;
|
|
|
|
import com.grack.nanojson.JsonBuilder;
|
|
|
|
import com.grack.nanojson.JsonObject;
|
|
|
|
import com.grack.nanojson.JsonWriter;
|
|
|
|
|
2018-05-26 19:15:45 +02:00
|
|
|
import org.schabi.newpipe.extractor.InfoItem;
|
2020-12-20 19:54:12 +01:00
|
|
|
import org.schabi.newpipe.extractor.MetaInfo;
|
2022-07-28 04:19:21 +02:00
|
|
|
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
|
2020-04-15 14:09:46 +02:00
|
|
|
import org.schabi.newpipe.extractor.Page;
|
2018-05-26 19:15:45 +02:00
|
|
|
import org.schabi.newpipe.extractor.StreamingService;
|
2019-04-28 22:03:16 +02:00
|
|
|
import org.schabi.newpipe.extractor.downloader.Downloader;
|
2018-05-26 19:15:45 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
2019-10-02 07:02:01 +02:00
|
|
|
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
|
2021-04-30 19:06:56 +02:00
|
|
|
import org.schabi.newpipe.extractor.localization.Localization;
|
2019-04-28 22:03:16 +02:00
|
|
|
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
|
2018-05-26 19:15:45 +02:00
|
|
|
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
2020-12-20 19:54:12 +01:00
|
|
|
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
|
2020-04-11 19:18:08 +02:00
|
|
|
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
2018-05-26 19:15:45 +02:00
|
|
|
|
2021-02-07 22:12:22 +01:00
|
|
|
import java.io.IOException;
|
2022-07-28 04:19:21 +02:00
|
|
|
import java.nio.charset.StandardCharsets;
|
2021-02-07 22:12:22 +01:00
|
|
|
import java.util.List;
|
2023-10-07 21:02:28 +02:00
|
|
|
import java.util.Objects;
|
2020-07-26 10:01:03 +02:00
|
|
|
|
2022-03-18 15:09:06 +01:00
|
|
|
import javax.annotation.Nonnull;
|
2022-06-18 16:07:32 +02:00
|
|
|
import javax.annotation.Nullable;
|
2020-02-27 17:39:23 +01:00
|
|
|
|
2018-07-01 16:21:40 +02:00
|
|
|
/*
|
|
|
|
* Created by Christian Schabesberger on 22.07.2018
|
|
|
|
*
|
2023-09-23 00:10:15 +02:00
|
|
|
* Copyright (C) 2018 Christian Schabesberger <chris.schabesberger@mailbox.org>
|
|
|
|
* YoutubeSearchExtractor.java is part of NewPipe Extractor.
|
2018-07-01 16:21:40 +02:00
|
|
|
*
|
2023-09-23 00:10:15 +02:00
|
|
|
* NewPipe Extractor is free software: you can redistribute it and/or modify
|
2018-07-01 16:21:40 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2023-09-23 00:10:15 +02:00
|
|
|
* NewPipe Extractor is distributed in the hope that it will be useful,
|
2018-07-01 16:21:40 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-09-23 00:10:15 +02:00
|
|
|
* along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.
|
2018-07-01 16:21:40 +02:00
|
|
|
*/
|
|
|
|
|
2018-05-26 19:15:45 +02:00
|
|
|
public class YoutubeSearchExtractor extends SearchExtractor {
|
2023-10-07 20:38:58 +02:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private final String searchType;
|
|
|
|
private final boolean extractVideoResults;
|
|
|
|
private final boolean extractChannelResults;
|
|
|
|
private final boolean extractPlaylistResults;
|
|
|
|
|
2020-02-22 23:51:02 +01:00
|
|
|
private JsonObject initialData;
|
2018-05-26 19:15:45 +02:00
|
|
|
|
2021-04-15 18:58:59 +02:00
|
|
|
public YoutubeSearchExtractor(final StreamingService service,
|
|
|
|
final SearchQueryHandler linkHandler) {
|
2019-04-28 22:03:16 +02:00
|
|
|
super(service, linkHandler);
|
2023-10-07 20:38:58 +02:00
|
|
|
final List<String> contentFilters = linkHandler.getContentFilters();
|
|
|
|
searchType = isNullOrEmpty(contentFilters) ? null : contentFilters.get(0);
|
|
|
|
// Save whether we should extract video, channel and playlist results depending on the
|
|
|
|
// requested search type, as YouTube returns sometimes videos inside channel search results
|
|
|
|
// If no search type is provided or ALL filter is requested, extract everything
|
|
|
|
extractVideoResults = searchType == null || ALL.equals(searchType)
|
|
|
|
|| VIDEOS.equals(searchType);
|
|
|
|
extractChannelResults = searchType == null || ALL.equals(searchType)
|
|
|
|
|| CHANNELS.equals(searchType);
|
|
|
|
extractPlaylistResults = searchType == null || ALL.equals(searchType)
|
|
|
|
|| PLAYLISTS.equals(searchType);
|
2018-05-26 19:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-04-15 18:58:59 +02:00
|
|
|
public void onFetchPage(@Nonnull final Downloader downloader) throws IOException,
|
|
|
|
ExtractionException {
|
2021-04-09 17:00:38 +02:00
|
|
|
final String query = super.getSearchString();
|
2021-04-30 19:06:56 +02:00
|
|
|
final Localization localization = getExtractorLocalization();
|
2023-10-07 20:38:58 +02:00
|
|
|
final String params = getSearchParameter(searchType);
|
2020-02-26 09:01:57 +01:00
|
|
|
|
Rebase + some code improvements + fix extraction of age-restricted videos + update clients version
Here is now the requests which will be made by the `onFetchPage` method of `YoutubeStreamExtractor`:
- the desktop API is fetched.
If there is no streaming data, the desktop player API with the embed client screen will be fetched (and also the player code), then the Android mobile API.
- if there is no streaming data, a `ContentNotAvailableException` will be thrown by using the message provided in playability status
If the video is age restricted, a request to the next endpoint of the desktop player with the embed client screen will be sent.
Otherwise, the next endpoint will be fetched normally, if the content is available.
If the video is not age-restricted, a request to the player endpoint of the Android mobile API will be made.
We can get more streams by using the Android mobile API but some streams may be not available on this API, so the streaming data of the Android mobile API will be first used to get itags and then the streaming data of the desktop internal API will be used.
If the parsing of the Android mobile API went wrong, only the streams of the desktop API will be used.
Other code changes:
- `prepareJsonBuilder` in `YoutubeParsingHelper` was renamed to `prepareDesktopJsonBuilder`
- `prepareMobileJsonBuilder` in `YoutubeParsingHelper` was renamed to `prepareAndroidMobileJsonBuilder`
- two new methods in `YoutubeParsingHelper` were added: `prepareDesktopEmbedVideoJsonBuilder` and `prepareAndroidMobileEmbedVideoJsonBuilder`
- `createPlayerBodyWithSts` is now public and was moved to `YoutubeParsingHelper`
- a new method in `YoutubeJavaScriptExtractor` was added: `resetJavaScriptCode`, which was needed for the method `resetDebofuscationCode` of `YoutubeStreamExtractor`
- `areHardcodedClientVersionAndKeyValid` in `YoutubeParsingHelper` returns now a `boolean` instead of an `Optional<Boolean>`
- the `fetchVideoInfoPage` method of `YoutubeStreamExtractor` was removed because YouTube returns now 404 for every client with the `get_video_info` page
- some unused objects and some warnings in `YoutubeStreamExtractor` were removed and fixed
Co-authored-by: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com>
2021-07-28 23:55:09 +02:00
|
|
|
final JsonBuilder<JsonObject> jsonBody = prepareDesktopJsonBuilder(localization,
|
2021-06-24 18:39:16 +02:00
|
|
|
getExtractorContentCountry())
|
|
|
|
.value("query", query);
|
2021-04-09 17:00:38 +02:00
|
|
|
if (!isNullOrEmpty(params)) {
|
2021-06-24 18:39:16 +02:00
|
|
|
jsonBody.value("params", params);
|
2021-04-09 17:00:38 +02:00
|
|
|
}
|
|
|
|
|
2022-07-28 04:19:21 +02:00
|
|
|
final byte[] body = JsonWriter.string(jsonBody.done()).getBytes(StandardCharsets.UTF_8);
|
2021-06-24 18:39:16 +02:00
|
|
|
|
2021-04-30 19:06:56 +02:00
|
|
|
initialData = getJsonPostResponse("search", body, localization);
|
2018-05-26 19:15:45 +02:00
|
|
|
}
|
|
|
|
|
2019-04-28 22:03:16 +02:00
|
|
|
@Nonnull
|
2018-10-25 15:46:47 +02:00
|
|
|
@Override
|
|
|
|
public String getUrl() throws ParsingException {
|
2019-04-28 22:03:16 +02:00
|
|
|
return super.getUrl() + "&gl=" + getExtractorContentCountry().getCountryCode();
|
2018-10-25 15:46:47 +02:00
|
|
|
}
|
|
|
|
|
2020-04-12 16:06:52 +02:00
|
|
|
@Nonnull
|
2018-05-26 19:15:45 +02:00
|
|
|
@Override
|
2020-02-29 22:57:25 +01:00
|
|
|
public String getSearchSuggestion() throws ParsingException {
|
2020-04-12 16:06:52 +02:00
|
|
|
final JsonObject itemSectionRenderer = initialData.getObject("contents")
|
2022-06-18 16:07:32 +02:00
|
|
|
.getObject("twoColumnSearchResultsRenderer")
|
|
|
|
.getObject("primaryContents")
|
|
|
|
.getObject("sectionListRenderer")
|
|
|
|
.getArray("contents")
|
|
|
|
.getObject(0)
|
2020-04-12 16:06:52 +02:00
|
|
|
.getObject("itemSectionRenderer");
|
2022-06-18 16:07:32 +02:00
|
|
|
final JsonObject didYouMeanRenderer = itemSectionRenderer.getArray("contents")
|
|
|
|
.getObject(0)
|
2020-04-11 19:18:08 +02:00
|
|
|
.getObject("didYouMeanRenderer");
|
2020-04-12 16:06:52 +02:00
|
|
|
|
2020-05-07 15:32:25 +02:00
|
|
|
if (!didYouMeanRenderer.isEmpty()) {
|
2021-04-15 18:58:59 +02:00
|
|
|
return JsonUtils.getString(didYouMeanRenderer,
|
|
|
|
"correctedQueryEndpoint.searchEndpoint.query");
|
2018-05-26 19:15:45 +02:00
|
|
|
}
|
2023-10-07 21:02:28 +02:00
|
|
|
|
|
|
|
return Objects.requireNonNullElse(
|
|
|
|
getTextFromObject(itemSectionRenderer.getArray("contents")
|
|
|
|
.getObject(0)
|
|
|
|
.getObject("showingResultsForRenderer")
|
|
|
|
.getObject("correctedQuery")), "");
|
2020-04-11 19:18:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isCorrectedSearch() {
|
|
|
|
final JsonObject showingResultsForRenderer = initialData.getObject("contents")
|
|
|
|
.getObject("twoColumnSearchResultsRenderer").getObject("primaryContents")
|
|
|
|
.getObject("sectionListRenderer").getArray("contents").getObject(0)
|
|
|
|
.getObject("itemSectionRenderer").getArray("contents").getObject(0)
|
|
|
|
.getObject("showingResultsForRenderer");
|
2020-05-07 15:32:25 +02:00
|
|
|
return !showingResultsForRenderer.isEmpty();
|
2018-05-26 19:15:45 +02:00
|
|
|
}
|
|
|
|
|
2022-03-17 16:25:49 +01:00
|
|
|
@Nonnull
|
2020-12-20 19:54:12 +01:00
|
|
|
@Override
|
|
|
|
public List<MetaInfo> getMetaInfo() throws ParsingException {
|
|
|
|
return YoutubeParsingHelper.getMetaInfo(
|
2022-06-18 16:07:32 +02:00
|
|
|
initialData.getObject("contents")
|
|
|
|
.getObject("twoColumnSearchResultsRenderer")
|
|
|
|
.getObject("primaryContents")
|
|
|
|
.getObject("sectionListRenderer")
|
2021-04-15 18:58:59 +02:00
|
|
|
.getArray("contents"));
|
2020-12-20 19:54:12 +01:00
|
|
|
}
|
|
|
|
|
2018-05-26 19:15:45 +02:00
|
|
|
@Nonnull
|
|
|
|
@Override
|
2020-07-26 12:00:56 +02:00
|
|
|
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
|
2022-02-02 19:18:20 +01:00
|
|
|
final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
|
2020-02-28 08:57:44 +01:00
|
|
|
|
2021-04-15 18:58:59 +02:00
|
|
|
final JsonArray sections = initialData.getObject("contents")
|
2022-06-18 16:07:32 +02:00
|
|
|
.getObject("twoColumnSearchResultsRenderer")
|
|
|
|
.getObject("primaryContents")
|
|
|
|
.getObject("sectionListRenderer")
|
|
|
|
.getArray("contents");
|
2020-03-17 11:33:39 +01:00
|
|
|
|
2020-04-15 14:09:46 +02:00
|
|
|
Page nextPage = null;
|
2020-04-10 10:25:53 +02:00
|
|
|
|
2020-07-26 10:01:03 +02:00
|
|
|
for (final Object section : sections) {
|
2022-06-18 16:07:32 +02:00
|
|
|
final JsonObject sectionJsonObject = (JsonObject) section;
|
|
|
|
if (sectionJsonObject.has("itemSectionRenderer")) {
|
|
|
|
final JsonObject itemSectionRenderer =
|
|
|
|
sectionJsonObject.getObject("itemSectionRenderer");
|
2020-02-24 18:24:36 +01:00
|
|
|
|
2020-07-26 10:01:03 +02:00
|
|
|
collectStreamsFrom(collector, itemSectionRenderer.getArray("contents"));
|
2022-06-18 16:07:32 +02:00
|
|
|
} else if (sectionJsonObject.has("continuationItemRenderer")) {
|
|
|
|
nextPage = getNextPageFrom(
|
|
|
|
sectionJsonObject.getObject("continuationItemRenderer"));
|
2020-07-26 10:01:03 +02:00
|
|
|
}
|
2020-04-10 10:25:53 +02:00
|
|
|
}
|
|
|
|
|
2020-04-15 14:09:46 +02:00
|
|
|
return new InfoItemsPage<>(collector, nextPage);
|
2018-05-26 19:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-04-15 18:58:59 +02:00
|
|
|
public InfoItemsPage<InfoItem> getPage(final Page page) throws IOException,
|
|
|
|
ExtractionException {
|
2020-05-11 15:25:18 +02:00
|
|
|
if (page == null || isNullOrEmpty(page.getUrl())) {
|
|
|
|
throw new IllegalArgumentException("Page doesn't contain an URL");
|
|
|
|
}
|
|
|
|
|
2021-04-30 19:06:56 +02:00
|
|
|
final Localization localization = getExtractorLocalization();
|
2022-02-02 19:18:20 +01:00
|
|
|
final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
|
2020-02-26 09:01:57 +01:00
|
|
|
|
2021-05-30 17:23:51 +02:00
|
|
|
// @formatter:off
|
Rebase + some code improvements + fix extraction of age-restricted videos + update clients version
Here is now the requests which will be made by the `onFetchPage` method of `YoutubeStreamExtractor`:
- the desktop API is fetched.
If there is no streaming data, the desktop player API with the embed client screen will be fetched (and also the player code), then the Android mobile API.
- if there is no streaming data, a `ContentNotAvailableException` will be thrown by using the message provided in playability status
If the video is age restricted, a request to the next endpoint of the desktop player with the embed client screen will be sent.
Otherwise, the next endpoint will be fetched normally, if the content is available.
If the video is not age-restricted, a request to the player endpoint of the Android mobile API will be made.
We can get more streams by using the Android mobile API but some streams may be not available on this API, so the streaming data of the Android mobile API will be first used to get itags and then the streaming data of the desktop internal API will be used.
If the parsing of the Android mobile API went wrong, only the streams of the desktop API will be used.
Other code changes:
- `prepareJsonBuilder` in `YoutubeParsingHelper` was renamed to `prepareDesktopJsonBuilder`
- `prepareMobileJsonBuilder` in `YoutubeParsingHelper` was renamed to `prepareAndroidMobileJsonBuilder`
- two new methods in `YoutubeParsingHelper` were added: `prepareDesktopEmbedVideoJsonBuilder` and `prepareAndroidMobileEmbedVideoJsonBuilder`
- `createPlayerBodyWithSts` is now public and was moved to `YoutubeParsingHelper`
- a new method in `YoutubeJavaScriptExtractor` was added: `resetJavaScriptCode`, which was needed for the method `resetDebofuscationCode` of `YoutubeStreamExtractor`
- `areHardcodedClientVersionAndKeyValid` in `YoutubeParsingHelper` returns now a `boolean` instead of an `Optional<Boolean>`
- the `fetchVideoInfoPage` method of `YoutubeStreamExtractor` was removed because YouTube returns now 404 for every client with the `get_video_info` page
- some unused objects and some warnings in `YoutubeStreamExtractor` were removed and fixed
Co-authored-by: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com>
2021-07-28 23:55:09 +02:00
|
|
|
final byte[] json = JsonWriter.string(prepareDesktopJsonBuilder(localization,
|
2021-05-30 17:23:51 +02:00
|
|
|
getExtractorContentCountry())
|
|
|
|
.value("continuation", page.getId())
|
|
|
|
.done())
|
2022-07-28 04:19:21 +02:00
|
|
|
.getBytes(StandardCharsets.UTF_8);
|
2021-05-30 17:23:51 +02:00
|
|
|
// @formatter:on
|
|
|
|
|
2022-06-18 16:07:32 +02:00
|
|
|
final JsonObject ajaxJson = getJsonPostResponse("search", json, localization);
|
2020-03-17 11:33:39 +01:00
|
|
|
|
2021-05-30 17:23:51 +02:00
|
|
|
final JsonArray continuationItems = ajaxJson.getArray("onResponseReceivedCommands")
|
2022-06-18 16:07:32 +02:00
|
|
|
.getObject(0)
|
|
|
|
.getObject("appendContinuationItemsAction")
|
2021-05-30 17:23:51 +02:00
|
|
|
.getArray("continuationItems");
|
2020-03-17 11:33:39 +01:00
|
|
|
|
2021-05-30 17:23:51 +02:00
|
|
|
final JsonArray contents = continuationItems.getObject(0)
|
2022-06-18 16:07:32 +02:00
|
|
|
.getObject("itemSectionRenderer")
|
|
|
|
.getArray("contents");
|
2021-05-30 17:23:51 +02:00
|
|
|
collectStreamsFrom(collector, contents);
|
2020-07-26 10:01:03 +02:00
|
|
|
|
2021-05-30 17:23:51 +02:00
|
|
|
return new InfoItemsPage<>(collector, getNextPageFrom(continuationItems.getObject(1)
|
|
|
|
.getObject("continuationItemRenderer")));
|
2018-05-26 19:15:45 +02:00
|
|
|
}
|
|
|
|
|
2022-02-02 19:18:20 +01:00
|
|
|
private void collectStreamsFrom(final MultiInfoItemsCollector collector,
|
2022-06-18 16:07:32 +02:00
|
|
|
@Nonnull final JsonArray contents)
|
2023-10-07 20:38:58 +02:00
|
|
|
throws NothingFoundException {
|
2019-04-28 22:03:16 +02:00
|
|
|
final TimeAgoParser timeAgoParser = getTimeAgoParser();
|
2018-05-26 19:15:45 +02:00
|
|
|
|
2021-05-29 14:43:50 +02:00
|
|
|
for (final Object content : contents) {
|
2021-03-31 13:30:06 +02:00
|
|
|
final JsonObject item = (JsonObject) content;
|
|
|
|
if (item.has("backgroundPromoRenderer")) {
|
2022-06-18 16:07:32 +02:00
|
|
|
throw new NothingFoundException(
|
|
|
|
getTextFromObject(item.getObject("backgroundPromoRenderer")
|
|
|
|
.getObject("bodyText")));
|
2023-10-07 20:38:58 +02:00
|
|
|
} else if (extractVideoResults && item.has("videoRenderer")) {
|
2022-06-18 16:07:32 +02:00
|
|
|
collector.commit(new YoutubeStreamInfoItemExtractor(
|
|
|
|
item.getObject("videoRenderer"), timeAgoParser));
|
2023-10-07 20:38:58 +02:00
|
|
|
} else if (extractChannelResults && item.has("channelRenderer")) {
|
2022-06-18 16:07:32 +02:00
|
|
|
collector.commit(new YoutubeChannelInfoItemExtractor(
|
|
|
|
item.getObject("channelRenderer")));
|
2023-10-07 20:38:58 +02:00
|
|
|
} else if (extractPlaylistResults && item.has("playlistRenderer")) {
|
2022-06-18 16:07:32 +02:00
|
|
|
collector.commit(new YoutubePlaylistInfoItemExtractor(
|
|
|
|
item.getObject("playlistRenderer")));
|
2018-05-26 19:15:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-22 20:19:41 +01:00
|
|
|
|
2022-06-18 16:07:32 +02:00
|
|
|
@Nullable
|
2021-05-30 17:23:51 +02:00
|
|
|
private Page getNextPageFrom(final JsonObject continuationItemRenderer) throws IOException,
|
2021-04-15 18:58:59 +02:00
|
|
|
ExtractionException {
|
2020-07-26 10:01:03 +02:00
|
|
|
if (isNullOrEmpty(continuationItemRenderer)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
final String token = continuationItemRenderer.getObject("continuationEndpoint")
|
2022-06-18 16:07:32 +02:00
|
|
|
.getObject("continuationCommand")
|
|
|
|
.getString("token");
|
2020-07-26 10:01:03 +02:00
|
|
|
|
2022-03-15 11:46:12 +01:00
|
|
|
final String url = YOUTUBEI_V1_URL + "search?key=" + getKey()
|
|
|
|
+ DISABLE_PRETTY_PRINT_PARAMETER;
|
2020-07-26 10:01:03 +02:00
|
|
|
|
|
|
|
return new Page(url, token);
|
|
|
|
}
|
2018-05-26 19:15:45 +02:00
|
|
|
}
|