Class PeertubeParsingHelper

java.lang.Object
org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper

public final class PeertubeParsingHelper extends Object
  • Field Details

  • Method Details

    • validate

      public static void validate(com.grack.nanojson.JsonObject json) throws ContentNotAvailableException
      Throws:
      ContentNotAvailableException
    • getNextPage

      public static Page getNextPage(String prevPageUrl, long total)
    • 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 information
      json - the JSOn response to retrieve data from
      baseUrl - the base URL of the instance
      sepia - if we should use PeertubeSepiaStreamInfoItemExtractor to extract streams or PeertubeStreamInfoItemExtractor otherwise
      Throws:
      ParsingException
    • getAvatarsFromOwnerAccountOrVideoChannelObject

      @Nonnull public static List<Image> getAvatarsFromOwnerAccountOrVideoChannelObject(@Nonnull String baseUrl, @Nonnull com.grack.nanojson.JsonObject ownerAccountOrVideoChannelObject)
      Get avatars from a ownerAccount or a videoChannel JsonObject.

      If the avatars JsonArray is present and non null or empty, avatars will be extracted from this array using getImagesFromAvatarOrBannerArray(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 instance
      ownerAccountOrVideoChannelObject - the ownerAccount or videoChannel JsonObject
      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 a ownerAccount or a videoChannel JsonObject.

      If the banners JsonArray is present and non null or empty, banners will be extracted from this array using getImagesFromAvatarOrBannerArray(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 instance
      ownerAccountOrVideoChannelObject - the ownerAccount or videoChannel JsonObject
      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 item JsonObject.

      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 the previewPath 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 instance
      playlistOrVideoItemObject - the playlist or the video item JsonObject, which must not be null
      Returns:
      an unmodifiable list of Images, which is never null but can be empty