Class PeertubeParsingHelper
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcollectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, String baseUrl) static voidcollectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, String baseUrl, boolean sepia) Collect items from the given JSON object with the given collector.getAvatarsFromOwnerAccountOrVideoChannelObject(String baseUrl, com.grack.nanojson.JsonObject ownerAccountOrVideoChannelObject) Get avatars from aownerAccountor avideoChannelJsonObject.getBannersFromAccountOrVideoChannelObject(String baseUrl, com.grack.nanojson.JsonObject ownerAccountOrVideoChannelObject) Get banners from aownerAccountor avideoChannelJsonObject.static PagegetNextPage(String prevPageUrl, long total) getThumbnailsFromPlaylistOrVideoItem(String baseUrl, com.grack.nanojson.JsonObject playlistOrVideoItemObject) Get thumbnails from a playlist or a video itemJsonObject.static voidvalidate(com.grack.nanojson.JsonObject json)
-
Field Details
-
START_KEY
- See Also:
-
COUNT_KEY
- See Also:
-
ITEMS_PER_PAGE
public static final int ITEMS_PER_PAGE- See Also:
-
START_PATTERN
- See Also:
-
-
Method Details
-
validate
- Throws:
ContentNotAvailableException
-
getNextPage
-
collectItemsFrom
public static void collectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, String baseUrl) throws ParsingException - Throws:
ParsingException
-
collectItemsFrom
public static void collectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, 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 List<Image> getAvatarsFromOwnerAccountOrVideoChannelObject(@Nonnull 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 List<Image> getBannersFromAccountOrVideoChannelObject(@Nonnull 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 List<Image> getThumbnailsFromPlaylistOrVideoItem(@Nonnull 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
-