SearchItem gains live (none, live now, upcoming, past), live_text ("141
watching", "3 waiting") and start_time (an upcoming stream's start in
Unix seconds). A search result the site marks live is live now.
channel_live and channel_live_continuation fetch a channel's Live tab
through strawcore's channel_live, one request per page; they take only
a UC channel id. ChannelInfo.has_live_tab says whether there is one,
from the response channel_info already gets.
enrich_feed_item now makes the feed lookup through
stream_metadata_live: the same one request, which also says whether the
video is live now, upcoming (with its start time) or has just ended. An
upcoming stream is an answer instead of an error.
62 lines
2.3 KiB
Rust
62 lines
2.3 KiB
Rust
// strawcore (wrapper) — UniFFI surface for the Straw Android app.
|
|
//
|
|
// Thin layer over the new Sulkta-OSS/strawcore-core crate. All extractor
|
|
// logic (InnerTube, JS deobf, stream parsing, search, channel, playlist)
|
|
// lives in core. This file:
|
|
// * re-exports the DTOs Kotlin expects under their familiar names
|
|
// * exposes #[uniffi::export] async fns that bridge Kotlin suspend funs
|
|
// to the core's blocking calls via tokio::task::spawn_blocking
|
|
// * owns init_logging() — also initializes the core Downloader
|
|
|
|
use std::sync::Once;
|
|
|
|
mod channel;
|
|
mod error;
|
|
mod feed;
|
|
mod net;
|
|
mod runtime;
|
|
mod search;
|
|
mod stream;
|
|
|
|
// Re-exports so UniFFI sees the types at the crate root for macro discovery.
|
|
pub use channel::ChannelInfo;
|
|
pub use error::StrawcoreError;
|
|
pub use net::{RydVotes, SponsorSegment};
|
|
pub use search::{LiveKind, Page, SearchItem};
|
|
pub use stream::{AudioStreamItem, ResolvedStreams, StreamInfo, VideoStreamItem};
|
|
|
|
/// Initialize Android logging + the strawcore-core HTTP downloader.
|
|
/// Kotlin calls this from StrawApp.onCreate(). Idempotent.
|
|
#[uniffi::export]
|
|
pub fn init_logging() {
|
|
static ONCE: Once = Once::new();
|
|
ONCE.call_once(|| {
|
|
android_logger::init_once(
|
|
android_logger::Config::default()
|
|
// Debug (not Info) so the extractor's DEBUG tier — per-request
|
|
// HTTP breadcrumbs, cache/lexer-fallback internals — is live in
|
|
// this dogfood/debug build. WARN/INFO were already emitted; this
|
|
// unlocks the chatty diagnostics behind them.
|
|
.with_max_level(log::LevelFilter::Debug)
|
|
.with_tag("strawcore"),
|
|
);
|
|
log::info!("strawcore initialized");
|
|
});
|
|
runtime::ensure_initialized();
|
|
}
|
|
|
|
/// Smoke-test entry point — round-trip a string through JNI.
|
|
/// Used during the initial UniFFI bring-up; kept for future smoke
|
|
/// debugging. Logs shape only — the `name` value never hits logcat
|
|
/// because a future caller might pass a real user-supplied string.
|
|
#[uniffi::export]
|
|
pub fn hello_from_rust(name: String) -> String {
|
|
log::info!("hello_from_rust called name_len={}", name.len());
|
|
format!(
|
|
"hello {} from rust 🦀 (strawcore v{})",
|
|
name,
|
|
env!("CARGO_PKG_VERSION")
|
|
)
|
|
}
|
|
|
|
uniffi::setup_scaffolding!();
|