Skip to main content

Overview

The StreamExtractor class extracts information from video/audio streaming services. It extends the base Extractor class and provides methods to retrieve stream metadata, playback URLs, and related content. Package: org.schabi.newpipe.extractor.stream Extends: Extractor

Constructor

service
StreamingService
required
The streaming service this extractor belongs to
The link handler containing URL information for this stream

Constants

NO_AGE_LIMIT
int
default:"0"
Constant indicating no age restriction on the content
UNKNOWN_SUBSCRIBER_COUNT
long
default:"-1"
Constant returned when uploader’s subscriber count is unavailable

Base Methods (Inherited from Extractor)

getId()

public String getId() throws ParsingException
Returns the unique identifier for this stream.
return
String
The stream’s unique ID

getName()

public abstract String getName() throws ParsingException
Returns the name/title of the stream.
return
String
The stream’s title

getUrl()

public String getUrl() throws ParsingException
Returns the cleaned URL for this stream.
return
String
The stream’s URL

getOriginalUrl()

public String getOriginalUrl() throws ParsingException
Returns the original URL as provided by the user.
return
String
The original URL

getBaseUrl()

public String getBaseUrl() throws ParsingException
Returns the base URL of the service.
return
String
The base URL

fetchPage()

public void fetchPage() throws IOException, ExtractionException
Fetches the page content. Must be called before accessing other data methods.

getService()

public StreamingService getService()
Returns the streaming service this extractor belongs to.
return
StreamingService
The associated streaming service

getServiceId()

public int getServiceId()
Returns the numeric ID of the streaming service.
return
int
The service ID

Stream Metadata Methods

getThumbnails()

public abstract List<Image> getThumbnails() throws ParsingException
Returns the thumbnail images for the stream.
return
List<Image>
List of thumbnail images in various resolutions

getDescription()

public Description getDescription() throws ParsingException
Returns the stream description.
return
Description
The description object, or Description.EMPTY_DESCRIPTION if not available

getLength()

public long getLength() throws ParsingException
Returns the duration of the stream in seconds.
return
long
Stream length in seconds, or 0 for livestreams

getViewCount()

public long getViewCount() throws ParsingException
Returns the number of views.
return
long
View count, or -1 if unavailable

getLikeCount()

public long getLikeCount() throws ParsingException
Returns the number of likes.
return
long
Like count, or -1 if unavailable

getDislikeCount()

public long getDislikeCount() throws ParsingException
Returns the number of dislikes.
return
long
Dislike count, or -1 if unavailable

getAgeLimit()

public int getAgeLimit() throws ParsingException
Returns the minimum age required to view the content.
return
int
Minimum age, or NO_AGE_LIMIT (0) if unrestricted

Upload Date Methods

getTextualUploadDate()

public String getTextualUploadDate() throws ParsingException
Returns the original textual date as provided by the service.
return
String
Original upload date string, or null for livestreams

getUploadDate()

public DateWrapper getUploadDate() throws ParsingException
Returns a parsed upload date.
return
DateWrapper
Parsed upload date, or null for livestreams

Uploader Information Methods

getUploaderName()

public abstract String getUploaderName() throws ParsingException
Returns the name of the content creator.
return
String
Uploader’s name, or empty string if unavailable

getUploaderUrl()

public abstract String getUploaderUrl() throws ParsingException
Returns the URL to the uploader’s channel page.
return
String
Uploader’s channel URL, or empty string if unavailable

getUploaderAvatars()

public List<Image> getUploaderAvatars() throws ParsingException
Returns the uploader’s profile pictures.
return
List<Image>
List of avatar images, or empty list if unavailable

isUploaderVerified()

public boolean isUploaderVerified() throws ParsingException
Returns whether the uploader is verified by the service.
return
boolean
true if verified, false otherwise

getUploaderSubscriberCount()

public long getUploaderSubscriberCount() throws ParsingException
Returns the subscriber count of the uploader.
return
long
Subscriber count, or UNKNOWN_SUBSCRIBER_COUNT (-1) if unavailable

Sub-Channel Methods

getSubChannelName()

public String getSubChannelName() throws ParsingException
Returns the name of the sub-channel (if applicable).
return
String
Sub-channel name, or empty string if not applicable

getSubChannelUrl()

public String getSubChannelUrl() throws ParsingException
Returns the URL to the sub-channel page.
return
String
Sub-channel URL, or empty string if not applicable

getSubChannelAvatars()

public List<Image> getSubChannelAvatars() throws ParsingException
Returns the sub-channel’s avatar images.
return
List<Image>
List of sub-channel avatars, or empty list if unavailable

Stream URL Methods

getAudioStreams()

public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException
Returns available audio-only streams.
return
List<AudioStream>
List of audio streams in various formats and qualities

getVideoStreams()

public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException
Returns video streams that contain both video and audio.
return
List<VideoStream>
List of combined video/audio streams

getVideoOnlyStreams()

public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException
Returns video-only streams without audio.
return
List<VideoStream>
List of video-only streams

getDashMpdUrl()

public String getDashMpdUrl() throws ParsingException
Returns the DASH MPD manifest URL.
return
String
DASH MPD URL, or empty string if unavailable

getHlsUrl()

public String getHlsUrl() throws ParsingException
Returns the HLS stream URL.
return
String
HLS URL, or empty string if unavailable

Subtitle Methods

getSubtitlesDefault()

public List<SubtitlesStream> getSubtitlesDefault() throws IOException, ExtractionException
Returns all available subtitle streams.
return
List<SubtitlesStream>
List of subtitle streams, or empty list if unavailable

getSubtitles()

public List<SubtitlesStream> getSubtitles(MediaFormat format) throws IOException, ExtractionException
Returns subtitle streams filtered by format.
format
MediaFormat
required
The subtitle format to filter by
return
List<SubtitlesStream>
List of subtitle streams in the specified format

Stream Type and Features

getStreamType()

public abstract StreamType getStreamType() throws ParsingException
Returns the type of stream (video, audio, live, etc.).
return
StreamType
The stream type enum value

getTimeStamp()

public long getTimeStamp() throws ParsingException
Returns the timestamp position if the URL contains a time marker.
return
long
Timestamp in seconds, or 0 if no timestamp in URL

isShortFormContent()

public boolean isShortFormContent() throws ParsingException
Returns whether this is short-form content (like YouTube Shorts, TikTok).
return
boolean
true if short-form content, false otherwise

getRelatedItems()

public InfoItemsCollector<? extends InfoItem, ? extends InfoItemExtractor> getRelatedItems() throws IOException, ExtractionException
Returns suggested/related content items.
return
InfoItemsCollector
Collector containing related items, or null if unavailable

getFrames()

public List<Frameset> getFrames() throws ExtractionException
Returns preview frames for the stream (thumbnail timeline).
return
List<Frameset>
List of frame preview sets, or empty list if unavailable

getStreamSegments()

public List<StreamSegment> getStreamSegments() throws ParsingException
Returns chapter/segment information with timestamps.
return
List<StreamSegment>
List of stream segments, or empty list if unavailable

Additional Metadata Methods

getHost()

public String getHost() throws ParsingException
Returns the host domain (for federated services like PeerTube).
return
String
Host domain, or empty string for centralized services

getPrivacy()

public Privacy getPrivacy() throws ParsingException
Returns the privacy setting of the stream.
return
Privacy
Privacy enum: PUBLIC, UNLISTED, PRIVATE, INTERNAL, or OTHER

getCategory()

public String getCategory() throws ParsingException
Returns the content category.
return
String
Category name, or empty string if unavailable

getLicence()

public String getLicence() throws ParsingException
Returns the content license.
return
String
License name, or empty string if unavailable

getLanguageInfo()

public Locale getLanguageInfo() throws ParsingException
Returns the content language.
return
Locale
Language locale, or null if unavailable

getTags()

public List<String> getTags() throws ParsingException
Returns content tags.
return
List<String>
List of tag strings, or empty list if unavailable

getSupportInfo()

public String getSupportInfo() throws ParsingException
Returns creator support/donation information.
return
String
Support information, or empty string if unavailable

getMetaInfo()

public List<MetaInfo> getMetaInfo() throws ParsingException
Returns additional meta information boxes (like COVID-19 warnings, broadcaster info).
return
List<MetaInfo>
List of meta info objects, or empty list if unavailable

getContentAvailability()

public ContentAvailability getContentAvailability() throws ParsingException
Returns the availability status of the content.
return
ContentAvailability
Content availability enum value

getErrorMessage()

public String getErrorMessage()
Returns any error message found on the page.
return
String
Error message, or null if no error detected

Localization Methods

forceLocalization()

public void forceLocalization(Localization localization)
Forces a specific localization for this extractor.
localization
Localization
required
The localization to use

forceContentCountry()

public void forceContentCountry(ContentCountry contentCountry)
Forces a specific content country for this extractor.
contentCountry
ContentCountry
required
The content country to use

Privacy Enum

The Privacy enum defines stream privacy levels:
  • PUBLIC - Publicly accessible
  • UNLISTED - Accessible via direct link only
  • PRIVATE - Only accessible to owner
  • INTERNAL - Internal/organization only
  • OTHER - Other privacy setting

Usage Example

StreamingService service = NewPipe.getService("YouTube");
StreamExtractor extractor = service.getStreamExtractor("https://youtube.com/watch?v=dQw4w9WgXcQ");

// Fetch the page first
extractor.fetchPage();

// Get stream information
String title = extractor.getName();
long views = extractor.getViewCount();
List<VideoStream> videos = extractor.getVideoStreams();
List<AudioStream> audio = extractor.getAudioStreams();

// Get uploader info
String uploaderName = extractor.getUploaderName();
boolean verified = extractor.isUploaderVerified();

Build docs developers (and LLMs) love