Drop unused Phase-1 scaffolding: page, metainfo, service
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.
This commit is contained in:
parent
7c7151186e
commit
7d2e4c51b8
4 changed files with 3 additions and 205 deletions
13
src/lib.rs
13
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};
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
url_texts: Vec<String>,
|
||||
}
|
||||
|
||||
impl MetaInfo {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn title(&self) -> &str {
|
||||
&self.title
|
||||
}
|
||||
|
||||
pub fn set_title(&mut self, title: impl Into<String>) -> &mut Self {
|
||||
self.title = title.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn content(&self) -> &str {
|
||||
&self.content
|
||||
}
|
||||
|
||||
pub fn set_content(&mut self, content: impl Into<String>) -> &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<String>) -> &mut Self {
|
||||
self.urls.push(url);
|
||||
self.url_texts.push(text.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
79
src/page.rs
79
src/page.rs
|
|
@ -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<String>,
|
||||
id: Option<String>,
|
||||
ids: Vec<String>,
|
||||
body: Option<Vec<u8>>,
|
||||
cookies: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
impl Page {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn with_url(url: impl Into<String>) -> 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<String>) -> &mut Self {
|
||||
self.url = url;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&str> {
|
||||
self.id.as_deref()
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: Option<String>) -> &mut Self {
|
||||
self.id = id;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn ids(&self) -> &[String] {
|
||||
&self.ids
|
||||
}
|
||||
|
||||
pub fn set_ids(&mut self, ids: Vec<String>) -> &mut Self {
|
||||
self.ids = ids;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn body(&self) -> Option<&[u8]> {
|
||||
self.body.as_deref()
|
||||
}
|
||||
|
||||
pub fn set_body(&mut self, body: Option<Vec<u8>>) -> &mut Self {
|
||||
self.body = body;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn cookies(&self) -> &BTreeMap<String, String> {
|
||||
&self.cookies
|
||||
}
|
||||
|
||||
pub fn set_cookies(&mut self, cookies: BTreeMap<String, String>) -> &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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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<MediaCapability>,
|
||||
}
|
||||
|
||||
impl ServiceInfo {
|
||||
pub fn new(name: impl Into<String>, media_capabilities: Vec<MediaCapability>) -> 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()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue