Skip to main content

Overview

The StreamingService class is an abstract base class that defines the interface for all streaming service implementations in NewPipe Extractor. Each supported service (YouTube, SoundCloud, etc.) extends this class. This class provides:
  • Service identification and metadata
  • Factory methods for creating extractors
  • Link handler factories for different content types
  • Localization support
  • URL type detection

Constructor

StreamingService()

Create a new streaming service instance.
id
int
required
The unique identifier for this service
name
String
required
The name of the service
capabilities
Set<ServiceInfo.MediaCapability>
required
The media capabilities this service supports (AUDIO, VIDEO, LIVE, COMMENTS)

Service Information

getServiceId()

Get the unique identifier of this service.
return
int
The service ID
StreamingService youtube = NewPipe.getService("YouTube");
int id = youtube.getServiceId(); // Returns 0 for YouTube

getServiceInfo()

Get metadata about this service.
return
ServiceInfo
Service information including name and capabilities
StreamingService service = NewPipe.getService("YouTube");
ServiceInfo info = service.getServiceInfo();
System.out.println("Name: " + info.getName());
System.out.println("Capabilities: " + info.getMediaCapabilities());

getBaseUrl()

Get the base URL of this service.
return
String
The base URL (e.g., “https://www.youtube.com”)
String baseUrl = service.getBaseUrl();

getStreamLHFactory()

Get the link handler factory for streams/videos.
return
LinkHandlerFactory
Factory for creating stream link handlers
LinkHandlerFactory factory = service.getStreamLHFactory();
LinkHandler handler = factory.fromUrl("https://youtube.com/watch?v=...");

getChannelLHFactory()

Get the link handler factory for channels.
return
ListLinkHandlerFactory
Factory for creating channel link handlers, or null if not supported
ListLinkHandlerFactory factory = service.getChannelLHFactory();
if (factory != null) {
    ListLinkHandler handler = factory.fromUrl(channelUrl);
}

getChannelTabLHFactory()

Get the link handler factory for channel tabs.
return
ListLinkHandlerFactory
Factory for creating channel tab link handlers, or null if not supported
ListLinkHandlerFactory factory = service.getChannelTabLHFactory();

getPlaylistLHFactory()

Get the link handler factory for playlists.
return
ListLinkHandlerFactory
Factory for creating playlist link handlers, or null if not supported
ListLinkHandlerFactory factory = service.getPlaylistLHFactory();

getSearchQHFactory()

Get the search query handler factory.
return
SearchQueryHandlerFactory
Factory for creating search query handlers
SearchQueryHandlerFactory factory = service.getSearchQHFactory();

getCommentsLHFactory()

Get the link handler factory for comments.
return
ListLinkHandlerFactory
Factory for creating comment link handlers
ListLinkHandlerFactory factory = service.getCommentsLHFactory();

Extractor Creation

getSearchExtractor()

Create a search extractor.
queryHandler
SearchQueryHandler
required
The search query handler specifying keywords and filters
return
SearchExtractor
A new search extractor instance
SearchQueryHandler handler = service.getSearchQHFactory()
    .fromQuery("cat videos");
SearchExtractor extractor = service.getSearchExtractor(handler);

getSearchExtractor() with Parameters

Create a search extractor with explicit parameters.
query
String
required
The search query
contentFilter
List<String>
required
Content filters to apply
sortFilter
String
required
Sort filter to apply
return
SearchExtractor
A new search extractor instance
throws
ExtractionException
If the extractor cannot be created
List<String> filters = Arrays.asList("video");
SearchExtractor extractor = service.getSearchExtractor(
    "cat videos",
    filters,
    "relevance"
);

getSearchExtractor() Simple

Create a search extractor with just a query.
query
String
required
The search query
return
SearchExtractor
A new search extractor instance
throws
ExtractionException
If the extractor cannot be created
SearchExtractor extractor = service.getSearchExtractor("cat videos");
extractor.fetchPage();
for (InfoItem item : extractor.getInitialPage().getItems()) {
    System.out.println(item.getName());
}

getStreamExtractor()

Create a stream/video extractor.
The link handler for the stream
return
StreamExtractor
A new stream extractor instance
throws
ExtractionException
If the extractor cannot be created
LinkHandler handler = service.getStreamLHFactory()
    .fromUrl("https://youtube.com/watch?v=...");
StreamExtractor extractor = service.getStreamExtractor(handler);

getStreamExtractor() by URL

Create a stream extractor from a URL.
url
String
required
The stream URL
return
StreamExtractor
A new stream extractor instance
throws
ExtractionException
If the extractor cannot be created
StreamExtractor extractor = service.getStreamExtractor(
    "https://youtube.com/watch?v=dQw4w9WgXcQ"
);
extractor.fetchPage();
System.out.println("Title: " + extractor.getName());
System.out.println("Duration: " + extractor.getLength());

getChannelExtractor()

Create a channel extractor.
The link handler for the channel
return
ChannelExtractor
A new channel extractor instance
throws
ExtractionException
If the extractor cannot be created
ListLinkHandler handler = service.getChannelLHFactory()
    .fromUrl(channelUrl);
ChannelExtractor extractor = service.getChannelExtractor(handler);

getChannelExtractor() by URL

Create a channel extractor from a URL.
url
String
required
The channel URL
return
ChannelExtractor
A new channel extractor instance
throws
ExtractionException
If the extractor cannot be created
ChannelExtractor extractor = service.getChannelExtractor(channelUrl);
extractor.fetchPage();
System.out.println("Channel: " + extractor.getName());
System.out.println("Subscribers: " + extractor.getSubscriberCount());

getChannelTabExtractor()

Create a channel tab extractor.
The link handler for the channel tab
return
ChannelTabExtractor
A new channel tab extractor instance
throws
ExtractionException
If the extractor cannot be created
ListLinkHandler handler = service.getChannelTabLHFactory()
    .fromQuery(channelId, Collections.singletonList("videos"), "");
ChannelTabExtractor extractor = service.getChannelTabExtractor(handler);

getChannelTabExtractorFromId()

Create a channel tab extractor from channel ID and tab name.
id
String
required
The channel ID
tab
String
required
The tab name (e.g., “videos”, “playlists”)
return
ChannelTabExtractor
A new channel tab extractor instance
throws
ExtractionException
If the extractor cannot be created
ChannelTabExtractor extractor = service.getChannelTabExtractorFromId(
    "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
    "videos"
);

getPlaylistExtractor()

Create a playlist extractor.
The link handler for the playlist
return
PlaylistExtractor
A new playlist extractor instance
throws
ExtractionException
If the extractor cannot be created
ListLinkHandler handler = service.getPlaylistLHFactory()
    .fromUrl(playlistUrl);
PlaylistExtractor extractor = service.getPlaylistExtractor(handler);

getPlaylistExtractor() by URL

Create a playlist extractor from a URL.
url
String
required
The playlist URL
return
PlaylistExtractor
A new playlist extractor instance
throws
ExtractionException
If the extractor cannot be created
PlaylistExtractor extractor = service.getPlaylistExtractor(playlistUrl);
extractor.fetchPage();
System.out.println("Playlist: " + extractor.getName());
System.out.println("Videos: " + extractor.getStreamCount());

getCommentsExtractor()

Create a comments extractor.
The link handler for the comments
return
CommentsExtractor
A new comments extractor instance
throws
ExtractionException
If the extractor cannot be created
ListLinkHandler handler = service.getCommentsLHFactory()
    .fromUrl(videoUrl);
CommentsExtractor extractor = service.getCommentsExtractor(handler);

getCommentsExtractor() by URL

Create a comments extractor from a URL.
url
String
required
The video URL
return
CommentsExtractor
A new comments extractor instance, or null if not supported
throws
ExtractionException
If the extractor cannot be created
CommentsExtractor extractor = service.getCommentsExtractor(videoUrl);
if (extractor != null) {
    extractor.fetchPage();
    for (CommentsInfoItem comment : extractor.getInitialPage().getItems()) {
        System.out.println(comment.getCommentText());
    }
}

getSuggestionExtractor()

Create a suggestion extractor for search suggestions.
return
SuggestionExtractor
A new suggestion extractor instance
SuggestionExtractor extractor = service.getSuggestionExtractor();
List<String> suggestions = extractor.suggestionList("cat");

getKioskList()

Get the kiosk list for this service.
return
KioskList
The kiosk list containing trending/featured content
throws
ExtractionException
If the kiosk list cannot be created
KioskList kioskList = service.getKioskList();
ListExtractor<StreamInfoItem> trending = kioskList.getDefaultKioskExtractor();

getFeedExtractor()

Get a feed extractor for subscription feeds.
url
String
required
The feed URL
return
FeedExtractor
A feed extractor instance, or null if not supported
throws
ExtractionException
If the extractor cannot be created
FeedExtractor extractor = service.getFeedExtractor(feedUrl);
if (extractor != null) {
    extractor.fetchPage();
}

URL Utilities

getLinkTypeByUrl()

Determine what type of content a URL points to.
url
String
required
The URL to check
return
LinkType
The link type: STREAM, CHANNEL, PLAYLIST, or NONE
throws
ParsingException
If the URL cannot be parsed
try {
    LinkType type = service.getLinkTypeByUrl(
        "https://youtube.com/watch?v=..."
    );
    
    switch (type) {
        case STREAM:
            System.out.println("This is a video");
            break;
        case CHANNEL:
            System.out.println("This is a channel");
            break;
        case PLAYLIST:
            System.out.println("This is a playlist");
            break;
        case NONE:
            System.out.println("Unknown URL type");
            break;
    }
} catch (ParsingException e) {
    e.printStackTrace();
}

Localization

getSupportedLocalizations()

Get all localizations supported by this service.
return
List<Localization>
List of supported localizations
List<Localization> localizations = service.getSupportedLocalizations();
for (Localization loc : localizations) {
    System.out.println(loc.getLanguageCode());
}

getSupportedCountries()

Get all content countries supported by this service.
return
List<ContentCountry>
List of supported content countries
List<ContentCountry> countries = service.getSupportedCountries();

getLocalization()

Get the active localization for this service based on user preferences.
return
Localization
The active localization
Localization locale = service.getLocalization();

getContentCountry()

Get the active content country for this service based on user preferences.
return
ContentCountry
The active content country
ContentCountry country = service.getContentCountry();

getTimeAgoParser()

Get a time ago parser for the specified localization.
localization
Localization
required
The localization to get a parser for
return
TimeAgoParser
A time ago parser instance
throws
IllegalArgumentException
If the localization is not supported
TimeAgoParser parser = service.getTimeAgoParser(
    new Localization("en", "US")
);

Enums

LinkType

Represents the type of content a URL points to.
  • NONE - URL is not recognized
  • STREAM - URL points to a video/stream
  • CHANNEL - URL points to a channel
  • PLAYLIST - URL points to a playlist

ServiceInfo.MediaCapability

Represents media capabilities of a service.
  • AUDIO - Service supports audio content
  • VIDEO - Service supports video content
  • LIVE - Service supports live streaming
  • COMMENTS - Service supports comments

Usage Example

import org.schabi.newpipe.extractor.*;
import org.schabi.newpipe.extractor.stream.StreamExtractor;

public class StreamingServiceExample {
    public static void main(String[] args) throws Exception {
        // Initialize NewPipe
        NewPipe.init(new DownloaderTestImpl());
        
        // Get YouTube service
        StreamingService service = NewPipe.getService("YouTube");
        
        // Check URL type
        String url = "https://youtube.com/watch?v=dQw4w9WgXcQ";
        LinkType type = service.getLinkTypeByUrl(url);
        
        if (type == StreamingService.LinkType.STREAM) {
            // Extract video information
            StreamExtractor extractor = service.getStreamExtractor(url);
            extractor.fetchPage();
            
            System.out.println("Title: " + extractor.getName());
            System.out.println("Uploader: " + extractor.getUploaderName());
            System.out.println("Duration: " + extractor.getLength() + " seconds");
            System.out.println("Views: " + extractor.getViewCount());
        }
    }
}

Build docs developers (and LLMs) love