feat: add font

fix: filter unplayable streams
This commit is contained in:
kieran 2024-11-20 15:08:40 +00:00
parent 56b73b879e
commit 35aa3c1c91
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
11 changed files with 80 additions and 42 deletions

86
Cargo.lock generated
View File

@ -464,9 +464,9 @@ dependencies = [
[[package]] [[package]]
name = "async-wsocket" name = "async-wsocket"
version = "0.9.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c0984bead67f20366bc8dd46018dfbe189b67eeefb0e5b86b9eade18d7c3c3b" checksum = "a107e3bdbe61e8e1e1341c57241b4b2d50501127b44bd2eff13b4635ab42d35a"
dependencies = [ dependencies = [
"async-utility", "async-utility",
"futures", "futures",
@ -1379,7 +1379,7 @@ dependencies = [
[[package]] [[package]]
name = "egui-video" name = "egui-video"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/v0l/egui-video.git?rev=5e2167855822f9523aaab0fe58ec8b3d510d1996#5e2167855822f9523aaab0fe58ec8b3d510d1996" source = "git+https://github.com/v0l/egui-video.git?rev=7d93a672fcadb7f98883a1a46f3c7f6e902c89a6#7d93a672fcadb7f98883a1a46f3c7f6e902c89a6"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"atomic", "atomic",
@ -1387,8 +1387,12 @@ dependencies = [
"egui", "egui",
"egui_inbox", "egui_inbox",
"ffmpeg-rs-raw", "ffmpeg-rs-raw",
"itertools 0.13.0",
"log", "log",
"m3u8-rs",
"nom", "nom",
"ureq",
"url",
] ]
[[package]] [[package]]
@ -1604,7 +1608,7 @@ dependencies = [
[[package]] [[package]]
name = "ffmpeg-rs-raw" name = "ffmpeg-rs-raw"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.v0l.io/Kieran/ffmpeg-rs-raw.git?rev=90b98598e1fee6ddc52787c5c88924b52146b026#90b98598e1fee6ddc52787c5c88924b52146b026" source = "git+https://git.v0l.io/Kieran/ffmpeg-rs-raw.git?rev=bb11e998e759b0332c22703844f448fb2ea3b4b5#bb11e998e759b0332c22703844f448fb2ea3b4b5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ffmpeg-sys-the-third", "ffmpeg-sys-the-third",
@ -1615,8 +1619,8 @@ dependencies = [
[[package]] [[package]]
name = "ffmpeg-sys-the-third" name = "ffmpeg-sys-the-third"
version = "2.0.0+ffmpeg-7.0" version = "2.1.0+ffmpeg-7.1"
source = "git+https://github.com/shssoichiro/ffmpeg-the-third.git?branch=master#fd44dd339be4971c0e32787b42514883ca934997" source = "git+https://git.v0l.io/ffmpeg/ffmpeg-the-third.git?branch=master#0fdfa9ab506f5c92aad5a175db081c8a2c1579a1"
dependencies = [ dependencies = [
"bindgen 0.69.5", "bindgen 0.69.5",
"cc", "cc",
@ -2514,6 +2518,16 @@ dependencies = [
"hashbrown 0.15.0", "hashbrown 0.15.0",
] ]
[[package]]
name = "m3u8-rs"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f03cd3335fb5f2447755d45cda9c70f76013626a9db44374973791b0926a86c3"
dependencies = [
"chrono",
"nom",
]
[[package]] [[package]]
name = "mach2" name = "mach2"
version = "0.4.2" version = "0.4.2"
@ -2722,11 +2736,12 @@ dependencies = [
[[package]] [[package]]
name = "nostr" name = "nostr"
version = "0.35.0" version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56db234b2e07901e372f34e9463f91590579cd8e6dbd34ed2ccc7e461e4ba639" checksum = "14ad56c1d9a59f4edc46b17bc64a217b38b99baefddc0080f85ad98a0855336d"
dependencies = [ dependencies = [
"aes", "aes",
"async-trait",
"base64", "base64",
"bech32", "bech32",
"bip39", "bip39",
@ -2753,9 +2768,9 @@ dependencies = [
[[package]] [[package]]
name = "nostr-database" name = "nostr-database"
version = "0.35.0" version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50de8cc5e77e7dafa7e2e0d0d67187ef19e191dcd1a68efffd3e05152d91b3c3" checksum = "1859abebf78d7d9e945b20c8faaf710c9db905adeb148035b803ae45792dbebe"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"lru", "lru",
@ -2767,9 +2782,9 @@ dependencies = [
[[package]] [[package]]
name = "nostr-relay-pool" name = "nostr-relay-pool"
version = "0.35.0" version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "800b9ca169902977366f8243ec645b1fa4a128ab621331796d4a26bd7bc22a88" checksum = "e39cfcb30cab86b30ca9acba89f5ccb25a4142a5dc5fcfbf3edf34b204ddd7c7"
dependencies = [ dependencies = [
"async-utility", "async-utility",
"async-wsocket", "async-wsocket",
@ -2786,9 +2801,9 @@ dependencies = [
[[package]] [[package]]
name = "nostr-sdk" name = "nostr-sdk"
version = "0.35.0" version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d93036bf4c1e35145ca2cd6ee4cb7bb9c74f41cbca9cc4caff1e87b5e192f253" checksum = "e4739ed15ff81a0e474d79b38c3eb481ff5f968c1865f38ba46852daf6f6495e"
dependencies = [ dependencies = [
"async-utility", "async-utility",
"atomic-destructor", "atomic-destructor",
@ -2796,7 +2811,6 @@ dependencies = [
"nostr", "nostr",
"nostr-database", "nostr-database",
"nostr-relay-pool", "nostr-relay-pool",
"nostr-signer",
"nostr-zapper", "nostr-zapper",
"nwc", "nwc",
"thiserror", "thiserror",
@ -2804,25 +2818,11 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "nostr-signer"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1e132975a677a1c97a7695ef1161291dc06517a588b6e17e3aa05d3fb4056a0"
dependencies = [
"async-utility",
"nostr",
"nostr-relay-pool",
"thiserror",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "nostr-zapper" name = "nostr-zapper"
version = "0.35.0" version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b60e7a3ecc9881ca418e772a6fc4410920653a9f0bf9457b6ddd732d2a3f64f1" checksum = "9d9709ecf8050bbe4ecf0e5efda2f25b690bb1761fc504e05654621ba9e568a8"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"nostr", "nostr",
@ -2832,7 +2832,7 @@ dependencies = [
[[package]] [[package]]
name = "nostrdb" name = "nostrdb"
version = "0.3.4" version = "0.3.4"
source = "git+https://github.com/damus-io/nostrdb-rs?branch=master#9bbafd8a2e904b77a51e7cfca71eb5bb5650e829" source = "git+https://github.com/damus-io/nostrdb-rs?rev=9bbafd8a2e904b77a51e7cfca71eb5bb5650e829#9bbafd8a2e904b77a51e7cfca71eb5bb5650e829"
dependencies = [ dependencies = [
"bindgen 0.69.5", "bindgen 0.69.5",
"cc", "cc",
@ -2902,10 +2902,11 @@ dependencies = [
[[package]] [[package]]
name = "nwc" name = "nwc"
version = "0.35.0" version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e962f52732a6d91c1e76d4de3f1daa186e77a849e98e5abe53ca7fe9796d04e" checksum = "1b5f98bcaf232b3ec48e018792ca7bc2b90e7520d001a07b8218a9e76a03fda2"
dependencies = [ dependencies = [
"async-trait",
"async-utility", "async-utility",
"nostr", "nostr",
"nostr-relay-pool", "nostr-relay-pool",
@ -3730,6 +3731,7 @@ version = "0.23.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993"
dependencies = [ dependencies = [
"log",
"once_cell", "once_cell",
"ring", "ring",
"rustls-pki-types", "rustls-pki-types",
@ -4612,6 +4614,22 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "ureq"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a"
dependencies = [
"base64",
"flate2",
"log",
"once_cell",
"rustls",
"rustls-pki-types",
"url",
"webpki-roots",
]
[[package]] [[package]]
name = "url" name = "url"
version = "2.5.2" version = "2.5.2"

View File

@ -8,9 +8,9 @@ crate-type = ["lib", "cdylib"]
[dependencies] [dependencies]
tokio = { version = "1.40.0", features = ["fs", "rt-multi-thread", "rt"] } tokio = { version = "1.40.0", features = ["fs", "rt-multi-thread", "rt"] }
egui = { version = "0.29.1" } egui = { version = "0.29.1", default-features = false, features = [] }
nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", branch = "master" } nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "9bbafd8a2e904b77a51e7cfca71eb5bb5650e829" }
nostr-sdk = { version = "0.35.0", features = ["all-nips"] } nostr-sdk = { version = "0.36.0", features = ["all-nips"] }
log = "0.4.22" log = "0.4.22"
pretty_env_logger = "0.5.0" pretty_env_logger = "0.5.0"
egui_inbox = "0.6.0" egui_inbox = "0.6.0"
@ -28,7 +28,7 @@ resvg = { version = "0.44.0", default-features = false }
serde = { version = "1.0.214", features = ["derive"] } serde = { version = "1.0.214", features = ["derive"] }
serde_with = { version = "3.11.0", features = ["hex"] } serde_with = { version = "3.11.0", features = ["hex"] }
egui-video = { git = "https://github.com/v0l/egui-video.git", rev = "5e2167855822f9523aaab0fe58ec8b3d510d1996" } egui-video = { git = "https://github.com/v0l/egui-video.git", rev = "7d93a672fcadb7f98883a1a46f3c7f6e902c89a6" }
#egui-video = { path = "../egui-video" } #egui-video = { path = "../egui-video" }
[target.'cfg(not(target_os = "android"))'.dependencies] [target.'cfg(not(target_os = "android"))'.dependencies]

View File

@ -1,4 +1,3 @@
- [Player] HLS demuxer
- [Login] Proper key storage - [Login] Proper key storage
- [NDB] Handle PRE's - [NDB] Handle PRE's
- [UX] Render non-ascii chars with better font - [UX] Render non-ascii chars with better font

View File

@ -12,7 +12,6 @@
# --enable-x264 \ # --enable-x264 \
# --enable-libwebp \ # --enable-libwebp \
# --enable-libpng \ # --enable-libpng \
# --enable-android-media-codec \
# --api-level=28 \ # --api-level=28 \
# --no-ffmpeg-kit-protocols \ # --no-ffmpeg-kit-protocols \
# --no-archive # --no-archive

BIN
assets/Outfit-Light.ttf Normal file

Binary file not shown.

BIN
assets/Outfit-Regular.ttf Normal file

Binary file not shown.

BIN
assets/Outfit.ttf Normal file

Binary file not shown.

View File

@ -1,6 +1,7 @@
use crate::route::Router; use crate::route::Router;
use eframe::epaint::FontFamily;
use eframe::{App, CreationContext, Frame}; use eframe::{App, CreationContext, Frame};
use egui::{Color32, Context, Margin}; use egui::{Color32, Context, FontData, FontDefinitions, Margin};
use nostr_sdk::database::MemoryDatabase; use nostr_sdk::database::MemoryDatabase;
use nostr_sdk::Client; use nostr_sdk::Client;
use nostrdb::{Config, Ndb}; use nostrdb::{Config, Ndb};
@ -60,6 +61,15 @@ where
let ndb = Ndb::new(ndb_path.to_str().unwrap(), &ndb_config).unwrap(); let ndb = Ndb::new(ndb_path.to_str().unwrap(), &ndb_config).unwrap();
let mut fd = FontDefinitions::default();
fd.font_data.insert(
"Outfit".to_string(),
FontData::from_static(include_bytes!("../assets/Outfit-Light.ttf")),
);
fd.families
.insert(FontFamily::Proportional, vec!["Outfit".to_string()]);
cc.egui_ctx.set_fonts(fd);
let cfg = config.clone(); let cfg = config.clone();
Self { Self {
client: client.clone(), client: client.clone(),

View File

@ -73,7 +73,7 @@ impl Login {
pub fn sign_event(&self, ev: UnsignedEvent) -> Result<Event, Error> { pub fn sign_event(&self, ev: UnsignedEvent) -> Result<Event, Error> {
let secret = self.secret_key()?; let secret = self.secret_key()?;
ev.sign(&secret).map_err(Error::new) ev.sign_with_keys(&secret).map_err(Error::new)
} }
pub fn write_live_chat_msg(&self, link: &NostrLink, msg: &str) -> Result<Event, Error> { pub fn write_live_chat_msg(&self, link: &NostrLink, msg: &str) -> Result<Event, Error> {

View File

@ -39,6 +39,7 @@ impl NostrWidget for HomePage {
.iter() .iter()
.map(|n| services.ndb.get_note_by_key(services.tx, NoteKey::new(n.0))) .map(|n| services.ndb.get_note_by_key(services.tx, NoteKey::new(n.0)))
.map_while(|f| f.ok()) .map_while(|f| f.ok())
.filter(|f| f.can_play())
.collect(); .collect();
ScrollArea::vertical() ScrollArea::vertical()

View File

@ -27,6 +27,8 @@ pub trait StreamInfo {
fn host(&self) -> &[u8; 32]; fn host(&self) -> &[u8; 32];
fn stream(&self) -> Option<&str>; fn stream(&self) -> Option<&str>;
/// Is the stream playable by this app
fn can_play(&self) -> bool;
fn starts(&self) -> u64; fn starts(&self) -> u64;
@ -74,6 +76,15 @@ impl<'a> StreamInfo for Note<'a> {
} }
} }
/// Is the stream playable by this app
fn can_play(&self) -> bool {
if let Some(stream) = self.stream() {
stream.contains(".m3u8")
} else {
false
}
}
fn starts(&self) -> u64 { fn starts(&self) -> u64 {
if let Some(s) = self.get_tag_value("starts") { if let Some(s) = self.get_tag_value("starts") {
s.variant().str().map_or(self.created_at(), |v| { s.variant().str().map_or(self.created_at(), |v| {