Class PeertubeParsingHelper
- java.lang.Object
-
- org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper
-
public final class PeertubeParsingHelper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOUNT_KEYstatic intITEMS_PER_PAGEstatic java.lang.StringSTART_KEYstatic java.lang.StringSTART_PATTERN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcollectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, java.lang.String baseUrl)static voidcollectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, java.lang.String baseUrl, boolean sepia)Collect items from the given JSON object with the given collector.static java.util.List<Image>getAvatarsFromOwnerAccountOrVideoChannelObject(java.lang.String baseUrl, com.grack.nanojson.JsonObject ownerAccountOrVideoChannelObject)Get avatars from aownerAccountor avideoChannelJsonObject.static java.util.List<Image>getBannersFromAccountOrVideoChannelObject(java.lang.String baseUrl, com.grack.nanojson.JsonObject ownerAccountOrVideoChannelObject)Get banners from aownerAccountor avideoChannelJsonObject.static PagegetNextPage(java.lang.String prevPageUrl, long total)static java.util.List<Image>getThumbnailsFromPlaylistOrVideoItem(java.lang.String baseUrl, com.grack.nanojson.JsonObject playlistOrVideoItemObject)Get thumbnails from a playlist or a video itemJsonObject.static java.time.OffsetDateTimeparseDateFrom(java.lang.String textualUploadDate)static voidvalidate(com.grack.nanojson.JsonObject json)
-
-
-
Field Detail
-
START_KEY
public static final java.lang.String START_KEY
- See Also:
- Constant Field Values
-
COUNT_KEY
public static final java.lang.String COUNT_KEY
- See Also:
- Constant Field Values
-
ITEMS_PER_PAGE
public static final int ITEMS_PER_PAGE
- See Also:
- Constant Field Values
-
START_PATTERN
public static final java.lang.String START_PATTERN
- See Also:
- Constant Field Values
-
-
Method Detail
-
validate
public static void validate(com.grack.nanojson.JsonObject json) throws ContentNotAvailableException- Throws:
ContentNotAvailableException
-
parseDateFrom
public static java.time.OffsetDateTime parseDateFrom(java.lang.String textualUploadDate) throws ParsingException- Throws:
ParsingException
-
getNextPage
public static Page getNextPage(java.lang.String prevPageUrl, long total)
-
collectItemsFrom
public static void collectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, java.lang.String baseUrl) throws ParsingException
- Throws:
ParsingException
-
collectItemsFrom
public static void collectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, java.lang.String baseUrl, boolean sepia) throws ParsingException
Collect items from the given JSON object with the given collector.Supported info item types are streams with their Sepia variant, channels and playlists.
- Parameters:
collector- the collector used to collect informationjson- the JSOn response to retrieve data frombaseUrl- the base URL of the instancesepia- if we should usePeertubeSepiaStreamInfoItemExtractorto extract streams orPeertubeStreamInfoItemExtractorotherwise- Throws:
ParsingException
-
getAvatarsFromOwnerAccountOrVideoChannelObject
@Nonnull public static java.util.List<Image> getAvatarsFromOwnerAccountOrVideoChannelObject(@Nonnull java.lang.String baseUrl, @Nonnull com.grack.nanojson.JsonObject ownerAccountOrVideoChannelObject)
Get avatars from aownerAccountor avideoChannelJsonObject.If the
avatarsJsonArrayis present and non null or empty, avatars will be extracted from this array usinggetImagesFromAvatarOrBannerArray(String, JsonArray).If that's not the case, an avatar will extracted using the
avatarJsonObject.Note that only images for which paths are not null and not empty will be added to the unmodifiable
Imagelist returned.- Parameters:
baseUrl- the base URL of the PeerTube instanceownerAccountOrVideoChannelObject- theownerAccountorvideoChannelJsonObject- Returns:
- an unmodifiable list of
Images, which may be empty but never null
-
getBannersFromAccountOrVideoChannelObject
@Nonnull public static java.util.List<Image> getBannersFromAccountOrVideoChannelObject(@Nonnull java.lang.String baseUrl, @Nonnull com.grack.nanojson.JsonObject ownerAccountOrVideoChannelObject)
Get banners from aownerAccountor avideoChannelJsonObject.If the
bannersJsonArrayis present and non null or empty, banners will be extracted from this array usinggetImagesFromAvatarOrBannerArray(String, JsonArray).If that's not the case, a banner will extracted using the
bannerJsonObject.Note that only images for which paths are not null and not empty will be added to the unmodifiable
Imagelist returned.- Parameters:
baseUrl- the base URL of the PeerTube instanceownerAccountOrVideoChannelObject- theownerAccountorvideoChannelJsonObject- Returns:
- an unmodifiable list of
Images, which may be empty but never null
-
getThumbnailsFromPlaylistOrVideoItem
@Nonnull public static java.util.List<Image> getThumbnailsFromPlaylistOrVideoItem(@Nonnull java.lang.String baseUrl, @Nonnull com.grack.nanojson.JsonObject playlistOrVideoItemObject)
Get thumbnails from a playlist or a video itemJsonObject.PeerTube provides two thumbnails in its API: a low one, represented by the value of the
thumbnailPathkey, and a medium one, represented by the value of thepreviewPathkey.If a value is not null or empty, an
Imagewill be added to the list returned with the URL to the thumbnail (baseUrl + value), a height and a width unknown and the corresponding resolution level (see above).- Parameters:
baseUrl- the base URL of the PeerTube instanceplaylistOrVideoItemObject- the playlist or the video itemJsonObject, which must not be null- Returns:
- an unmodifiable list of
Images, which is never null but can be empty
-
-