Commit 20b5eb7488

20b5eb7488911b623aec14f097e0f2851720b681

parent: f576837b45

Unsigned

kqvanity <kqvanity@gmail.com> · 2026-04-16 11:42 UTC

feat(blocklist): initial impl of channel blocklist

Layout: unified · split

src/config/main.rs +19
@@ -2,6 +2,7 @@ use crate::global::traits::{ConfigTrait, SearchProviderTrait};
22use serde::{Deserialize, Serialize};
33use std::collections::HashMap;
44use typemap::Key;
5use crate::config::serde::ColorVariantSerde::Black;
56
67/// `main.yml`, the main config file
78#[derive(Serialize, Deserialize, Clone)]
@@ -43,6 +44,23 @@ pub struct MainConfig {
4344 pub legacy_input_handling: bool,
4445 #[serde(default = "default_env")]
4546 pub env: HashMap<String, String>,
47 #[serde(default = "blacklist")]
48 pub block_list: BlockList,
49}
50
51#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)]
52pub struct BlockList {
53 #[serde(default = "channels")]
54 pub channels: Vec<String>
55}
56
57const fn channels() -> Vec<String> {
58 return vec![]
59}
60const fn blacklist() -> BlockList {
61 BlockList {
62 channels: vec![]
63 }
4664}
4765
4866impl Key for MainConfig {
@@ -71,6 +89,7 @@ impl Default for MainConfig {
7189 legacy_input_handling: legacy_input_handling_default(),
7290
7391 env: default_env(),
92 block_list: blacklist(),
7493 }
7594 }
7695}
src/items/itemlist.rs +14
@@ -387,6 +387,8 @@ impl FrameworkItem for ItemList {
387387 .unwrap()
388388 .image_index;
389389
390 let mainconfig = framework.data.global.get::<MainConfig>().unwrap();
391
390392 // fetch the items using the invidious api
391393 match page {
392394 Page::MainMenu(MainMenuPage::Trending) => {
@@ -415,6 +417,18 @@ impl FrameworkItem for ItemList {
415417 self.items = SearchProviderWrapper::search(search)?
416418 .into_iter()
417419 .map(|item| Item::from_search_item(item, image_index))
420 .filter(|item| {
421 let channel_id = match item.clone() {
422 Item::MiniVideo(video) => video.channel_id,
423 Item::MiniPlaylist(playlist) => playlist.channel_id,
424 Item::MiniChannel(channel) => channel.id,
425 Item::FullVideo(video) => video.id,
426 Item::FullPlaylist(playlist) => playlist.id,
427 Item::FullChannel(channel) => channel.id,
428 _ => "".to_string(),
429 };
430 !mainconfig.block_list.channels.contains(&channel_id)
431 })
418432 .collect();
419433 if !self.items.is_empty() {
420434 self.items.push(Item::Page(true));