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
The streaming service this extractor belongs to
The link handler containing URL information for this stream
Constants
Constant indicating no age restriction on the content
Constant returned when uploader’s subscriber count is unavailable
getId()
public String getId() throws ParsingException
Returns the unique identifier for this stream.
getName()
public abstract String getName() throws ParsingException
Returns the name/title of the stream.
getUrl()
public String getUrl() throws ParsingException
Returns the cleaned URL for this stream.
getOriginalUrl()
public String getOriginalUrl() throws ParsingException
Returns the original URL as provided by the user.
getBaseUrl()
public String getBaseUrl() throws ParsingException
Returns the base URL of the service.
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.
The associated streaming service
getServiceId()
public int getServiceId()
Returns the numeric ID of the streaming service.
getThumbnails()
public abstract List<Image> getThumbnails() throws ParsingException
Returns the thumbnail images for the stream.
List of thumbnail images in various resolutions
getDescription()
public Description getDescription() throws ParsingException
Returns the stream 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.
Stream length in seconds, or 0 for livestreams
getViewCount()
public long getViewCount() throws ParsingException
Returns the number of views.
View count, or -1 if unavailable
getLikeCount()
public long getLikeCount() throws ParsingException
Returns the number of likes.
Like count, or -1 if unavailable
getDislikeCount()
public long getDislikeCount() throws ParsingException
Returns the number of dislikes.
Dislike count, or -1 if unavailable
getAgeLimit()
public int getAgeLimit() throws ParsingException
Returns the minimum age required to view the content.
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.
Original upload date string, or null for livestreams
getUploadDate()
public DateWrapper getUploadDate() throws ParsingException
Returns a parsed upload date.
Parsed upload date, or null for livestreams
getUploaderName()
public abstract String getUploaderName() throws ParsingException
Returns the name of the content creator.
Uploader’s name, or empty string if unavailable
getUploaderUrl()
public abstract String getUploaderUrl() throws ParsingException
Returns the URL to the uploader’s channel page.
Uploader’s channel URL, or empty string if unavailable
getUploaderAvatars()
public List<Image> getUploaderAvatars() throws ParsingException
Returns the uploader’s profile pictures.
List of avatar images, or empty list if unavailable
isUploaderVerified()
public boolean isUploaderVerified() throws ParsingException
Returns whether the uploader is verified by the service.
true if verified, false otherwise
getUploaderSubscriberCount()
public long getUploaderSubscriberCount() throws ParsingException
Returns the subscriber count of the uploader.
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).
Sub-channel name, or empty string if not applicable
getSubChannelUrl()
public String getSubChannelUrl() throws ParsingException
Returns the URL to the sub-channel page.
Sub-channel URL, or empty string if not applicable
getSubChannelAvatars()
public List<Image> getSubChannelAvatars() throws ParsingException
Returns the sub-channel’s avatar images.
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.
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.
List of combined video/audio streams
getVideoOnlyStreams()
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException
Returns video-only streams without audio.
List of video-only streams
getDashMpdUrl()
public String getDashMpdUrl() throws ParsingException
Returns the DASH MPD manifest URL.
DASH MPD URL, or empty string if unavailable
getHlsUrl()
public String getHlsUrl() throws ParsingException
Returns the HLS stream URL.
HLS URL, or empty string if unavailable
Subtitle Methods
getSubtitlesDefault()
public List<SubtitlesStream> getSubtitlesDefault() throws IOException, ExtractionException
Returns all available subtitle streams.
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.
The subtitle format to filter by
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.).
The stream type enum value
getTimeStamp()
public long getTimeStamp() throws ParsingException
Returns the timestamp position if the URL contains a time marker.
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).
true if short-form content, false otherwise
Related Content Methods
public InfoItemsCollector<? extends InfoItem, ? extends InfoItemExtractor> getRelatedItems() throws IOException, ExtractionException
Returns suggested/related content items.
Collector containing related items, or null if unavailable
getFrames()
public List<Frameset> getFrames() throws ExtractionException
Returns preview frames for the stream (thumbnail timeline).
List of frame preview sets, or empty list if unavailable
getStreamSegments()
public List<StreamSegment> getStreamSegments() throws ParsingException
Returns chapter/segment information with timestamps.
List of stream segments, or empty list if unavailable
getHost()
public String getHost() throws ParsingException
Returns the host domain (for federated services like PeerTube).
Host domain, or empty string for centralized services
getPrivacy()
public Privacy getPrivacy() throws ParsingException
Returns the privacy setting of the stream.
Privacy enum: PUBLIC, UNLISTED, PRIVATE, INTERNAL, or OTHER
getCategory()
public String getCategory() throws ParsingException
Returns the content category.
Category name, or empty string if unavailable
getLicence()
public String getLicence() throws ParsingException
Returns the content license.
License name, or empty string if unavailable
getLanguageInfo()
public Locale getLanguageInfo() throws ParsingException
Returns the content language.
Language locale, or null if unavailable
public List<String> getTags() throws ParsingException
Returns content tags.
List of tag strings, or empty list if unavailable
getSupportInfo()
public String getSupportInfo() throws ParsingException
Returns creator support/donation information.
Support information, or empty string if unavailable
public List<MetaInfo> getMetaInfo() throws ParsingException
Returns additional meta information boxes (like COVID-19 warnings, broadcaster info).
List of meta info objects, or empty list if unavailable
getContentAvailability()
public ContentAvailability getContentAvailability() throws ParsingException
Returns the availability status of the content.
Content availability enum value
getErrorMessage()
public String getErrorMessage()
Returns any error message found on the page.
Error message, or null if no error detected
Localization Methods
forceLocalization()
public void forceLocalization(Localization localization)
Forces a specific localization for this extractor.
forceContentCountry()
public void forceContentCountry(ContentCountry contentCountry)
Forces a specific content country for this extractor.
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();