Core Architecture
The library follows a layered architecture with three main components:Services
Service implementations for each platform (YouTube, SoundCloud, etc.)
Extractors
Data extraction logic for different content types
Link Handlers
URL parsing and ID extraction utilities
Design Principles
Service Abstraction
Each streaming platform is represented by aStreamingService implementation that defines:
- Available content types (streams, channels, playlists)
- Link handler factories for URL processing
- Extractor factories for data extraction
- Supported localizations and content countries
Factory Pattern
The library extensively uses the Factory pattern to create:- Link Handlers: Parse URLs and extract IDs
- Extractors: Fetch and parse content data
- Kiosks: Trending/featured content sections
Lazy Loading
Extractors implement a two-phase loading pattern:- Initialization: Create extractor with URL/ID
- Fetch: Call
fetchPage()to download and parse data
Entry Point
TheNewPipe class serves as the main entry point:
You must call
NewPipe.init() before using any extractor functionality. This initializes the downloader and localization settings.Initialization Example
Service Discovery
The library automatically detects which service can handle a URL:Content Types
The library supports multiple content types:- Streams
- Channels
- Playlists
- Search
- Comments
- Kiosks
Video or audio streams (individual content items)Extractor:
StreamExtractorLink Handler: LinkHandlerData Flow
- URL Input: User provides a URL or ID
- Link Handler Creation: Factory parses URL and creates LinkHandler
- Extractor Creation: Service creates appropriate extractor
- Page Fetch: Extractor downloads content via Downloader
- Data Parsing: Extractor parses HTML/JSON response
- Data Access: Client calls getter methods for specific data
Error Handling
The library uses specific exceptions for different error cases:ParsingException: Failed to parse data from responseExtractionException: General extraction errorsContentNotAvailableException: Content is blocked or removedContentNotSupportedException: Feature not supported by service
Thread Safety
Next Steps
Services
Learn about StreamingService implementations
Extractors
Understand the Extractor pattern
Link Handlers
Master URL parsing and validation
Localization
Configure language and region settings