All checks were successful
release / release (push) Successful in 10m13s
Replaces the web app (youtube.com/tv in Chromium) with a native Rust + Slint client on sf-ui, built on Netflex TV's page engine. - InnerTube: web client for public pages, the TV client with the account's OAuth token for personal ones, visionOS (direct URLs) for streams, the TV client with yt-dlp's ejs solver (QuickJS) as fallback. - One version, no ads: ad breaks are never requested, ad renderers are skipped in feeds. SponsorBlock skips sponsored parts. - Sign-in with a QR code / youtube.com/activate (OAuth device flow). - Signed out: subscriptions and history on the TV; a home filled with this week's popular Hungarian videos when YouTube's is empty. - Playback: one-quality DASH manifest for GStreamer, H.264 up to 1080p or AV1 up to 4K, captions, quality switching, up next, resume. - Release builds for x86-64 and the Raspberry Pi (aarch64). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
165 lines
6.2 KiB
Rust
165 lines
6.2 KiB
Rust
//! Feliratkozások. Signed in: the account's subscriptions feed. Signed out:
|
|
//! the channels followed on this TV and their latest videos (from each
|
|
//! channel's RSS feed, newest first).
|
|
|
|
use std::any::Any;
|
|
|
|
use crate::app::{Cx, Screen};
|
|
use crate::page::{C, Frame, GRID_YT, L, Spec, grid_lines};
|
|
use crate::screens::{self, Load, Paged, video_card};
|
|
use crate::yt::{Item, Video};
|
|
|
|
pub struct Subs {
|
|
feed: Paged,
|
|
local: Option<Load<Vec<Video>>>,
|
|
}
|
|
|
|
impl Subs {
|
|
pub fn new() -> Subs {
|
|
Subs { feed: Paged::new("subs", false, true), local: None }
|
|
}
|
|
|
|
fn paged(s: &mut Subs) -> &mut Paged {
|
|
&mut s.feed
|
|
}
|
|
|
|
fn load_local(&mut self, cx: &Cx) {
|
|
if self.local.is_some() {
|
|
return;
|
|
}
|
|
let ids: Vec<String> = cx.library().subs.iter().map(|s| s.id.clone()).collect();
|
|
if ids.is_empty() {
|
|
self.local = Some(Load::Ready(Vec::new()));
|
|
return;
|
|
}
|
|
self.local = Some(Load::Loading);
|
|
let client = cx.client();
|
|
cx.spawn::<Subs, _>(
|
|
move || {
|
|
let mut all: Vec<(String, Video)> = Vec::new();
|
|
let mut err = None;
|
|
// A few channels at a time.
|
|
for chunk in ids.chunks(8) {
|
|
let handles: Vec<_> = chunk
|
|
.iter()
|
|
.map(|id| {
|
|
let (c, id) = (client.clone(), id.clone());
|
|
std::thread::spawn(move || crate::yt::extras::channel_feed(&c, &id))
|
|
})
|
|
.collect();
|
|
for h in handles {
|
|
match h.join() {
|
|
Ok(Ok(v)) => all.extend(v),
|
|
Ok(Err(e)) => err = Some(e),
|
|
Err(_) => {}
|
|
}
|
|
}
|
|
}
|
|
if all.is_empty() {
|
|
if let Some(e) = err {
|
|
return Err(e);
|
|
}
|
|
}
|
|
all.sort_by(|a, b| b.0.cmp(&a.0));
|
|
Ok(all.into_iter().map(|(_, v)| v).take(120).collect())
|
|
},
|
|
|s, cx, r| s.local = Some(Load::from(r, cx)),
|
|
);
|
|
}
|
|
|
|
fn local_items(&self) -> Vec<Item> {
|
|
match &self.local {
|
|
Some(Load::Ready(v)) => v.iter().cloned().map(Item::Video).collect(),
|
|
_ => Vec::new(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Screen for Subs {
|
|
fn spec(&mut self, cx: &Cx) -> Spec {
|
|
let shorts = cx.settings().shorts;
|
|
let mut lines = Vec::new();
|
|
if cx.signed_in() {
|
|
let client = cx.client();
|
|
self.feed.start::<Subs>(cx, Subs::paged, move || client.subscriptions());
|
|
lines.extend(self.feed.lines("Legújabb videók", shorts));
|
|
if self.feed.feed().is_some_and(|f| f.is_empty()) {
|
|
lines.push(L::notice("none", "info", "Nincs új videó", "A fiókod feliratkozásainak videói jelennek meg itt."));
|
|
}
|
|
} else {
|
|
self.load_local(cx);
|
|
let subs = cx.library().subs.clone();
|
|
if subs.is_empty() {
|
|
lines.push(L::page_title("title", "Feliratkozások", "Ezen a TV-n még nem iratkoztál fel egy csatornára sem."));
|
|
lines.push(L::notice(
|
|
"how",
|
|
"info",
|
|
"Így iratkozhatsz fel",
|
|
"Nyiss meg egy csatornát (egy videó alatt vagy a keresőben), és nyomd meg a Feliratkozás gombot. Ha bejelentkezel, a fiókod feliratkozásai látszanak itt.",
|
|
));
|
|
lines.push(L::chips("signin", "", vec![crate::page::Ch::new("signin", "Bejelentkezés QR-kóddal").icon("user").tone("primary")]));
|
|
} else {
|
|
let channels: Vec<C> = subs
|
|
.iter()
|
|
.map(|s| {
|
|
let mut c = C::new(format!("c:{}", s.id), s.title.clone(), s.thumb.clone());
|
|
c.caption = s.title.clone();
|
|
c.round = true;
|
|
c
|
|
})
|
|
.collect();
|
|
lines.push(L::cards("channels", "Csatornáid", "landscape", channels).captions());
|
|
match &self.local {
|
|
Some(Load::Ready(v)) => {
|
|
let cards = v.iter().filter(|v| shorts || !v.short).map(video_card).collect();
|
|
lines.extend(grid_lines("subs-grid", "Legújabb videók", "landscape", cards, GRID_YT));
|
|
}
|
|
Some(other) => lines.extend(other.status("local-status")),
|
|
None => {}
|
|
}
|
|
}
|
|
}
|
|
Spec { lines, frame: Frame { nav: Some(1), ..Frame::default() } }
|
|
}
|
|
|
|
fn activate(&mut self, cx: &Cx, line: &str, key: &str) {
|
|
if line == "signin" {
|
|
cx.c.sign_in();
|
|
return;
|
|
}
|
|
if cx.signed_in() {
|
|
screens::open_card(cx, key, self.feed.find(key), self.feed.queue(line, key));
|
|
} else {
|
|
let items = self.local_items();
|
|
let id = key.split(':').nth(1).unwrap_or_default();
|
|
let item = items.iter().find(|i| i.id() == id).cloned();
|
|
let title = cx.library().subs.iter().find(|s| s.id == id).map(|s| s.title.clone());
|
|
let item = item.or_else(|| title.map(|t| Item::Channel(crate::yt::parse::Channel { id: id.into(), title: t, ..Default::default() })));
|
|
screens::open_card(cx, key, item, screens::queue_after(&items, key));
|
|
}
|
|
}
|
|
|
|
fn focus(&mut self, cx: &Cx, _line: &str, key: &str) {
|
|
let item = if cx.signed_in() { self.feed.find(key) } else { self.local_items().into_iter().find(|i| key.ends_with(i.id())) };
|
|
screens::focus_backdrop(cx, item.as_ref(), key);
|
|
}
|
|
|
|
fn more(&mut self, cx: &Cx, list: &str) {
|
|
self.feed.more::<Subs>(cx, list, Subs::paged);
|
|
}
|
|
|
|
fn shown(&mut self, cx: &Cx) {
|
|
// Followed or dropped a channel meanwhile.
|
|
if !cx.signed_in() {
|
|
let have = matches!(&self.local, Some(Load::Ready(_)));
|
|
if have {
|
|
self.local = None;
|
|
}
|
|
}
|
|
}
|
|
|
|
fn as_any(&mut self) -> &mut dyn Any {
|
|
self
|
|
}
|
|
}
|