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.String
COUNT_KEY
static int
ITEMS_PER_PAGE
static java.lang.String
START_KEY
static java.lang.String
START_PATTERN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
collectItemsFrom(InfoItemsCollector collector, com.grack.nanojson.JsonObject json, java.lang.String baseUrl)
static void
collectItemsFrom(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 aownerAccount
or avideoChannel
JsonObject
.static java.util.List<Image>
getBannersFromAccountOrVideoChannelObject(java.lang.String baseUrl, com.grack.nanojson.JsonObject ownerAccountOrVideoChannelObject)
Get banners from aownerAccount
or avideoChannel
JsonObject
.static Page
getNextPage(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.OffsetDateTime
parseDateFrom(java.lang.String textualUploadDate)
static void
validate(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 usePeertubeSepiaStreamInfoItemExtractor
to extract streams orPeertubeStreamInfoItemExtractor
otherwise- 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 aownerAccount
or avideoChannel
JsonObject
.If the
avatars
JsonArray
is 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
avatar
JsonObject
.Note that only images for which paths are not null and not empty will be added to the unmodifiable
Image
list returned.- Parameters:
baseUrl
- the base URL of the PeerTube instanceownerAccountOrVideoChannelObject
- theownerAccount
orvideoChannel
JsonObject
- Returns:
- an unmodifiable list of
Image
s, 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 aownerAccount
or avideoChannel
JsonObject
.If the
banners
JsonArray
is 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
banner
JsonObject
.Note that only images for which paths are not null and not empty will be added to the unmodifiable
Image
list returned.- Parameters:
baseUrl
- the base URL of the PeerTube instanceownerAccountOrVideoChannelObject
- theownerAccount
orvideoChannel
JsonObject
- Returns:
- an unmodifiable list of
Image
s, 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
thumbnailPath
key, and a medium one, represented by the value of thepreviewPath
key.If a value is not null or empty, an
Image
will 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
Image
s, which is never null but can be empty
-
-