Skip to content

Latest commit

Β 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NewPipeExtractor-KMP

This repository is a Compose Multiplatform-compatible adaptation of the NewPipeExtractor. The migration started from v0.24.5 and includes selected service-compatibility fixes from newer upstream versions. It is intended for extracting YouTube and SoundCloud content within Kotlin Multiplatform projects.


πŸ“Œ Overview

  • Migrated to Kotlin (Multiplatform).
  • Migration base: NewPipeExtractor v0.24.5, with targeted current-service compatibility fixes.
  • Internal modules have been refactored and improved for better readability, structure, and platform compatibility.
  • Replaced nanojson with a pure Kotlin implementation.
  • Public APIs and function call patterns remain unchanged to ensure compatibility with the original usage.
  • βœ… Audio stream extraction supports both YouTube and SoundCloud.
  • βœ… YouTube progressive and video-only stream extraction is available.
  • This project aims to serve as a foundation for integrating content extraction logic into Compose Multiplatform applications.

πŸš€ Usage

1. Add Dependency

implementation("io.github.yushosei:newpipe-extractor-kmp:1.3.0")

2. Initialization

NewPipe.init(DefaultDownloaderImpl.initDefault())

3. Search

ExtractorHelper.searchFor(
    SERVICE_ID, searchText, listOf("videos"),
    "",
)

4. Get More Search Items

ExtractorHelper.getMoreSearchItems(
    SERVICE_ID, searchText, listOf("videos"), "", page
)

5. Search Suggestions

ExtractorHelper.suggestionsFor(SERVICE_ID, searchText)

6. Stream Extraction

val info = ExtractorHelper.getStreamInfo(SERVICE_ID, item.url)

val audioStreams = info.audioStreams
val progressiveVideoStreams = info.videoStreams // video + audio
val adaptiveVideoStreams = info.videoOnlyStreams // pair with an audio stream

For more details, refer to the sampleApp.

πŸŽ₯ Demo Video

Android & iOS

recording.mp4

Web

2025-08-13.181218.mp4

Desktop

2025-08-13.184911.mp4

βœ… The sample supports audio and video playback modes. YouTube uses progressive video streams with embedded audio, while SoundCloud remains audio-only. Platform video surfaces are implemented for Android (Media3), iOS (AVPlayer), desktop (VLCJ), and Wasm (HTML video). All core logic is written in pure Kotlin, making it platform-independent and theoretically usable across desktop and web environments too.

The current implementation has been verified on Android and iOS targets using Compose Multiplatform UI.

πŸ“¦ We plan to release a cleaned-up and library-ready version of the module in the near future to facilitate reuse and integration !

⚠️ Note on nanojson Replacement

This project includes a reimplementation of nanojson in pure Kotlin, rewritten from scratch to work within the Kotlin Multiplatform (NewPipeExtractor).

  • βœ… The implementation has been tested in conjunction with NewPipe and verified to extract data correctly.
  • ⚠ However, this Kotlin version of nanojson is an interim solution. It was built for functional compatibility and does not guarantee performance parity with the original Java version.
  • It exists only to enable current operation and may be replaced in the future with a more robust or performant JSON parser tailored for KMP.

βœ… Migration Themes & Checklist

Java Dependency Removal

  • Remove core Java-only APIs (e.g. Serializable, Optional, Pattern, URL, Objects)
  • Replace Java collections, streams, and IO with Kotlin equivalents

Rhino JavaScript Handling

  • Decide on Rhino integration approach (e.g. maintain, isolate, or replace)

Custom Kotlin Object Replacement

  • Convert Java utility classes (Pair, ManifestCache, etc.) to idiomatic Kotlin

Serialization Strategy Change

  • Replace Serializable with @Serializable and kotlinx.serialization

Lightweight JSON Optimization

  • Remove nanojson dependency
  • Reimplement nanojson using pure Kotlin logic
  • Evaluate long-term direction for JSON handling:
    • Convert to a pure Kotlin @Serializable-based structure
    • More faithfully replicate original nanojson behavior for performance and features

Feature Migration Status (NewPipeExtractor Modules)

Core functionality has been migrated but not yet fully cleaned or published.

  • Search functionality migrated to Kotlin
  • Search suggestion handling migrated to Kotlin
  • Stream extraction (YouTube video info) migrated to Kotlin
  • Audio stream extraction (YouTube, SoundCloud) migrated to Kotlin
  • Progressive and video-only stream extraction (YouTube) migrated to Kotlin
  • Compose Multiplatform sample video playback surfaces
  • Code cleanup and module publishing pending

πŸ§ͺ Testing & Integration

  • Add shared commonTest cases
  • Use runBlocking and mock data for multiplatform testability
  • Include a Compose Multiplatform audio/video demo

Run deterministic tests with:

./gradlew :newpipe-KMP:desktopTest

Run opt-in live service smoke tests with:

./gradlew :newpipe-KMP:desktopTest -Dnewpipe.liveTests=true

πŸ“¦ Module Info

  • Forked by: @yushosei
  • Migration base: NewPipeExtractor v0.24.5
  • Library version: 1.3.0

πŸ“„ License & Copyright

This project is licensed under the GNU General Public License v3 or (at your option) any later version.

  • New files and contributions in this repository are Β© 2025 @yushosei.
  • All original content from the forked NewPipeExtractor remains Β© the NewPipe Team.

About

NewPipeExtractor for extracting YouTube videos and comments in Compose Multiplatform projects

Topics

Resources

Stars

19 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages