Phase 1 — Foundation

Mirror NPE's dependency-free spine in Rust:

* exceptions   — NetworkError + ParsingError + ContentUnavailable
                 + ExtractionError tree, with reqwest/serde_json conversions
* localization — Localization + ContentCountry, default (en, GB)
* downloader/  — Downloader trait, Request builder, Response,
                 reqwest blocking default impl
* page         — continuation-token carrier
* image        — Image + ImageSet + ResolutionLevel
                 (HEIGHT_UNKNOWN/WIDTH_UNKNOWN = -1)
* metainfo     — title/content/url/url_text grab-bag
* service      — StreamingService trait + LinkType + ServiceInfo
* newpipe      — process-global Downloader / Localization /
                 ContentCountry singleton

Foundational invariants nailed down (per SPEC §3):
* HTTP non-2xx returns Ok(Response); only 429 throws NetworkError::Recaptcha
* Response header keys lowercase-normalized
* Request.add_header PARITY with NPE bug (silent overwrite);
  append_header is our clean addition
* default Localization is en-GB
* No cookie jar in the default downloader

Tests: 7 unit + 7 live smoke against httpbin.org (gated on
'online-tests' feature). All green.
This commit is contained in:
Sulkta 2026-05-24 16:32:36 -07:00
parent 6340b54ad3
commit 2a2367a3d0
16 changed files with 2689 additions and 1 deletions

24
src/lib.rs Normal file
View file

@ -0,0 +1,24 @@
// Rust port of NewPipeExtractor (YT-only).
//
// Phase 1 lays the dependency-free spine that everything else builds on:
// errors, localization, the Downloader contract, value types, the
// StreamingService trait, and the NewPipe singleton. None of this module
// tree knows anything about YouTube yet — that lands in Phase 3+.
pub mod downloader;
pub mod exceptions;
pub mod image;
pub mod localization;
pub mod metainfo;
pub mod newpipe;
pub mod page;
pub mod service;
pub use downloader::{Downloader, Request, Response};
pub use exceptions::{ExtractionError, NetworkError, ParsingError};
pub use image::{Image, ImageSet, ResolutionLevel};
pub use localization::{ContentCountry, Localization};
pub use metainfo::MetaInfo;
pub use newpipe::NewPipe;
pub use page::Page;
pub use service::{LinkType, ServiceInfo, StreamingService};