@@ -0,0 +1,57 @@
|
||||
//! Constants for `youtube-feeder`.
|
||||
|
||||
/// User-Agent for outbound HTTP.
|
||||
///
|
||||
/// ⚠ **Not cosmetic.** Several upstreams reject a generic or absent
|
||||
/// User-Agent, and a 403 there looks exactly like a rate-limit — easy to
|
||||
/// misdiagnose. Identify the application and carry contact information.
|
||||
pub const USER_AGENT: &str = concat!(
|
||||
"youtube-feeder/",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
" ( https://github.com/worph/meta-feeder-youtube )"
|
||||
);
|
||||
|
||||
/// Piped instances, tried in order, rotating past a dead one.
|
||||
///
|
||||
/// **A pool, not a hostname — measured.** Of four instances tried during the
|
||||
/// study, one returned `502`, two `301`-redirected away, and one answered in
|
||||
/// ~1 s. That is the failure profile to design for. It is cheap to survive
|
||||
/// because we take only the 11-character video id: a dead instance is a retry,
|
||||
/// not a broken stream (contrast the *bytes* argument against Piped in
|
||||
/// `youtube-source-integration-study.md` §2.2, which does not apply here).
|
||||
pub const PIPED_INSTANCES: &[&str] = &[
|
||||
"https://api.piped.private.coffee",
|
||||
"https://pipedapi.kavin.rocks",
|
||||
"https://pipedapi.adminforge.de",
|
||||
"https://api.piped.yt",
|
||||
];
|
||||
/// Per-request timeout against a Piped instance.
|
||||
pub const PIPED_TIMEOUT_SECS: u64 = 15;
|
||||
/// Artwork for a YouTube rendition. `hqdefault` exists for every video, unlike
|
||||
/// `maxresdefault`, which 404s on anything not uploaded in HD — and a 404 here
|
||||
/// is **silent**, gating the record out with no error anywhere.
|
||||
pub const YT_THUMB_BASE: &str = "https://i.ytimg.com/vi";
|
||||
/// How far a candidate's runtime may sit from the MusicBrainz recording length
|
||||
/// and still be the same recording.
|
||||
///
|
||||
/// ±10 s is what the study measured at, and it is doing two jobs: absorbing
|
||||
/// fade-in/out and pre-gap differences between a CD master and an uploaded
|
||||
/// Art Track, while staying tight enough to separate a radio edit (249 s) from
|
||||
/// an album cut (370 s).
|
||||
pub const YT_DURATION_TOLERANCE_SECS: i64 = 10;
|
||||
/// Ceiling on Piped `music_songs` candidates examined per track.
|
||||
pub const YT_CANDIDATES_PER_TRACK: usize = 8;
|
||||
/// How many ranked YouTube references one recording may carry.
|
||||
///
|
||||
/// §3's mitigation for reference rot: the video **id** is immutable, but its
|
||||
/// *availability* is not — takedowns, geo-blocks and embed-disabled uploads all
|
||||
/// kill a reference whose CID stays valid forever. One reference per recording
|
||||
/// means a takedown kills the track; several let the client fall through.
|
||||
///
|
||||
/// Three rather than "all of them" because each is a record replicated across
|
||||
/// the mesh, and the tail past three is candidates the resolver already ranked
|
||||
/// as worse matches.
|
||||
pub const MAX_REFS_PER_RECORDING: usize = 3;
|
||||
|
||||
// MusicBrainz's published rate ceiling, from the crate that owns that client.
|
||||
pub use musicbrainz_feeder::consts::{MB_BURST, MB_RATE_PER_SEC, MB_TIMEOUT_SECS};
|
||||
Reference in New Issue
Block a user