From 7d2e4c51b82c186b01892170f78f5eec59e64252 Mon Sep 17 00:00:00 2001 From: Kayos Date: Tue, 26 May 2026 22:01:08 -0700 Subject: [PATCH] Drop unused Phase-1 scaffolding: page, metainfo, service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These three modules were ported from NewPipeExtractor in Phase 1 as part of the spine. Nothing in the YT extractor (channel/search/stream/ playlist/linkhandler) imports them, and the strawcore wrapper crate that consumes us doesn't re-export them either. Per the round-2 audit's cruft inventory, this is ~195 LOC of dead surface shipping to every Android APK. * page.rs — Page continuation carrier; continuation tokens flow through the codebase as plain Strings. * metainfo.rs — NPE MetaInfo info-card struct; no extractor populates it. * service.rs — StreamingService trait + ServiceInfo + LinkType; zero impls exist anywhere. Wrapper does not need to change — none of the pub use re-exports crossed the crate boundary. --- src/lib.rs | 13 ++------ src/metainfo.rs | 53 --------------------------------- src/page.rs | 79 ------------------------------------------------- src/service.rs | 63 --------------------------------------- 4 files changed, 3 insertions(+), 205 deletions(-) delete mode 100644 src/metainfo.rs delete mode 100644 src/page.rs delete mode 100644 src/service.rs diff --git a/src/lib.rs b/src/lib.rs index 9f69b84..4b466fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,18 +1,14 @@ // 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+. +// The spine ports the core NPE contract — errors, localization, the +// Downloader trait, value types, the NewPipe singleton — and then the +// YT-specific extractors live under `youtube/`. 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 mod stream; pub mod youtube; @@ -20,7 +16,4 @@ 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}; diff --git a/src/metainfo.rs b/src/metainfo.rs deleted file mode 100644 index ba0ad8c..0000000 --- a/src/metainfo.rs +++ /dev/null @@ -1,53 +0,0 @@ -// MetaInfo — mirrors NPE MetaInfo.java. -// -// Carries "info card" style data (knowledge-panel boxes, COVID/election -// warning banners, etc.) attached to a stream or search result. Paired URLs -// + URL texts — same indices. - -use url::Url; - -#[derive(Clone, Debug, Default)] -pub struct MetaInfo { - title: String, - content: String, - urls: Vec, - url_texts: Vec, -} - -impl MetaInfo { - pub fn new() -> Self { - Self::default() - } - - pub fn title(&self) -> &str { - &self.title - } - - pub fn set_title(&mut self, title: impl Into) -> &mut Self { - self.title = title.into(); - self - } - - pub fn content(&self) -> &str { - &self.content - } - - pub fn set_content(&mut self, content: impl Into) -> &mut Self { - self.content = content.into(); - self - } - - pub fn urls(&self) -> &[Url] { - &self.urls - } - - pub fn url_texts(&self) -> &[String] { - &self.url_texts - } - - pub fn add_url(&mut self, url: Url, text: impl Into) -> &mut Self { - self.urls.push(url); - self.url_texts.push(text.into()); - self - } -} diff --git a/src/page.rs b/src/page.rs deleted file mode 100644 index e9000ec..0000000 --- a/src/page.rs +++ /dev/null @@ -1,79 +0,0 @@ -// Page — continuation token carrier. Mirrors NPE Page.java. -// -// Used everywhere "the next page" is paginated through an opaque token -// (search results, channel videos, playlist videos, comments). The fields -// are deliberately a grab-bag — NPE callers stuff whatever they need to -// resume. - -use std::collections::BTreeMap; - -#[derive(Clone, Debug, Default)] -pub struct Page { - url: Option, - id: Option, - ids: Vec, - body: Option>, - cookies: BTreeMap, -} - -impl Page { - pub fn new() -> Self { - Self::default() - } - - pub fn with_url(url: impl Into) -> Self { - Self { url: Some(url.into()), ..Self::default() } - } - - pub fn url(&self) -> Option<&str> { - self.url.as_deref() - } - - pub fn set_url(&mut self, url: Option) -> &mut Self { - self.url = url; - self - } - - pub fn id(&self) -> Option<&str> { - self.id.as_deref() - } - - pub fn set_id(&mut self, id: Option) -> &mut Self { - self.id = id; - self - } - - pub fn ids(&self) -> &[String] { - &self.ids - } - - pub fn set_ids(&mut self, ids: Vec) -> &mut Self { - self.ids = ids; - self - } - - pub fn body(&self) -> Option<&[u8]> { - self.body.as_deref() - } - - pub fn set_body(&mut self, body: Option>) -> &mut Self { - self.body = body; - self - } - - pub fn cookies(&self) -> &BTreeMap { - &self.cookies - } - - pub fn set_cookies(&mut self, cookies: BTreeMap) -> &mut Self { - self.cookies = cookies; - self - } - - pub fn is_valid(&self) -> bool { - self.url.as_deref().map(|s| !s.is_empty()).unwrap_or(false) - || self.id.as_deref().map(|s| !s.is_empty()).unwrap_or(false) - || !self.ids.is_empty() - || self.body.as_ref().map(|b| !b.is_empty()).unwrap_or(false) - } -} diff --git a/src/service.rs b/src/service.rs deleted file mode 100644 index 15fdbef..0000000 --- a/src/service.rs +++ /dev/null @@ -1,63 +0,0 @@ -// StreamingService trait + ServiceInfo + LinkType. Mirrors NPE -// StreamingService.java. -// -// Phase 1 keeps this dependency-free — no extractor traits, no per-service -// linkHandler factories. YouTube's concrete impl lands in Phase 3 once the -// JS engine is in place (Phase 2). -// -// Service IDs are stable persistence keys per SPEC §3 invariant #6: -// YouTube = 0, even if we never implement another service. - -use std::fmt; - -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] -pub enum LinkType { - None, - Stream, - Channel, - Playlist, -} - -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] -pub enum MediaCapability { - Audio, - Video, - LiveStream, - Comments, -} - -#[derive(Clone, Debug)] -pub struct ServiceInfo { - name: String, - media_capabilities: Vec, -} - -impl ServiceInfo { - pub fn new(name: impl Into, media_capabilities: Vec) -> Self { - Self { name: name.into(), media_capabilities } - } - - pub fn name(&self) -> &str { - &self.name - } - - pub fn media_capabilities(&self) -> &[MediaCapability] { - &self.media_capabilities - } -} - -pub trait StreamingService: Send + Sync { - fn service_id(&self) -> u32; - fn service_info(&self) -> &ServiceInfo; - - fn base_url(&self) -> &str; -} - -impl fmt::Debug for dyn StreamingService { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("StreamingService") - .field("service_id", &self.service_id()) - .field("name", &self.service_info().name()) - .finish() - } -}