CLI utility to ingest embedded json metadata from yt-dlp downloads to a SQLite database file
yt-dlp
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: Add rudementary progress bar to indexing process

0xBA5E64 94bf09b5 f21a4b38

+144 -8
+127
Cargo.lock
··· 119 119 ] 120 120 121 121 [[package]] 122 + name = "bumpalo" 123 + version = "3.20.2" 124 + source = "registry+https://github.com/rust-lang/crates.io-index" 125 + checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" 126 + 127 + [[package]] 122 128 name = "byteorder" 123 129 version = "1.5.0" 124 130 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 199 205 checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" 200 206 dependencies = [ 201 207 "crossbeam-utils", 208 + ] 209 + 210 + [[package]] 211 + name = "console" 212 + version = "0.16.3" 213 + source = "registry+https://github.com/rust-lang/crates.io-index" 214 + checksum = "d64e8af5551369d19cf50138de61f1c42074ab970f74e99be916646777f8fc87" 215 + dependencies = [ 216 + "encode_unicode", 217 + "libc", 218 + "unicode-width", 219 + "windows-sys 0.61.2", 202 220 ] 203 221 204 222 [[package]] ··· 313 331 dependencies = [ 314 332 "serde", 315 333 ] 334 + 335 + [[package]] 336 + name = "encode_unicode" 337 + version = "1.0.0" 338 + source = "registry+https://github.com/rust-lang/crates.io-index" 339 + checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" 316 340 317 341 [[package]] 318 342 name = "equivalent" ··· 655 679 ] 656 680 657 681 [[package]] 682 + name = "indicatif" 683 + version = "0.18.4" 684 + source = "registry+https://github.com/rust-lang/crates.io-index" 685 + checksum = "25470f23803092da7d239834776d653104d551bc4d7eacaf31e6837854b8e9eb" 686 + dependencies = [ 687 + "console", 688 + "portable-atomic", 689 + "unicode-width", 690 + "unit-prefix", 691 + "web-time", 692 + ] 693 + 694 + [[package]] 658 695 name = "is_terminal_polyfill" 659 696 version = "1.70.2" 660 697 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 665 702 version = "1.0.18" 666 703 source = "registry+https://github.com/rust-lang/crates.io-index" 667 704 checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" 705 + 706 + [[package]] 707 + name = "js-sys" 708 + version = "0.3.95" 709 + source = "registry+https://github.com/rust-lang/crates.io-index" 710 + checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca" 711 + dependencies = [ 712 + "once_cell", 713 + "wasm-bindgen", 714 + ] 668 715 669 716 [[package]] 670 717 name = "lazy_static" ··· 952 999 checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" 953 1000 954 1001 [[package]] 1002 + name = "portable-atomic" 1003 + version = "1.13.1" 1004 + source = "registry+https://github.com/rust-lang/crates.io-index" 1005 + checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" 1006 + 1007 + [[package]] 955 1008 name = "potential_utf" 956 1009 version = "0.1.5" 957 1010 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1054 1107 "subtle", 1055 1108 "zeroize", 1056 1109 ] 1110 + 1111 + [[package]] 1112 + name = "rustversion" 1113 + version = "1.0.22" 1114 + source = "registry+https://github.com/rust-lang/crates.io-index" 1115 + checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" 1057 1116 1058 1117 [[package]] 1059 1118 name = "ryu" ··· 1618 1677 checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" 1619 1678 1620 1679 [[package]] 1680 + name = "unicode-width" 1681 + version = "0.2.2" 1682 + source = "registry+https://github.com/rust-lang/crates.io-index" 1683 + checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" 1684 + 1685 + [[package]] 1686 + name = "unit-prefix" 1687 + version = "0.5.2" 1688 + source = "registry+https://github.com/rust-lang/crates.io-index" 1689 + checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" 1690 + 1691 + [[package]] 1621 1692 name = "url" 1622 1693 version = "2.5.8" 1623 1694 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1676 1747 checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" 1677 1748 1678 1749 [[package]] 1750 + name = "wasm-bindgen" 1751 + version = "0.2.118" 1752 + source = "registry+https://github.com/rust-lang/crates.io-index" 1753 + checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89" 1754 + dependencies = [ 1755 + "cfg-if", 1756 + "once_cell", 1757 + "rustversion", 1758 + "wasm-bindgen-macro", 1759 + "wasm-bindgen-shared", 1760 + ] 1761 + 1762 + [[package]] 1763 + name = "wasm-bindgen-macro" 1764 + version = "0.2.118" 1765 + source = "registry+https://github.com/rust-lang/crates.io-index" 1766 + checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed" 1767 + dependencies = [ 1768 + "quote", 1769 + "wasm-bindgen-macro-support", 1770 + ] 1771 + 1772 + [[package]] 1773 + name = "wasm-bindgen-macro-support" 1774 + version = "0.2.118" 1775 + source = "registry+https://github.com/rust-lang/crates.io-index" 1776 + checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904" 1777 + dependencies = [ 1778 + "bumpalo", 1779 + "proc-macro2", 1780 + "quote", 1781 + "syn", 1782 + "wasm-bindgen-shared", 1783 + ] 1784 + 1785 + [[package]] 1786 + name = "wasm-bindgen-shared" 1787 + version = "0.2.118" 1788 + source = "registry+https://github.com/rust-lang/crates.io-index" 1789 + checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129" 1790 + dependencies = [ 1791 + "unicode-ident", 1792 + ] 1793 + 1794 + [[package]] 1795 + name = "web-time" 1796 + version = "1.1.0" 1797 + source = "registry+https://github.com/rust-lang/crates.io-index" 1798 + checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" 1799 + dependencies = [ 1800 + "js-sys", 1801 + "wasm-bindgen", 1802 + ] 1803 + 1804 + [[package]] 1679 1805 name = "whoami" 1680 1806 version = "1.6.1" 1681 1807 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1787 1913 dependencies = [ 1788 1914 "anyhow", 1789 1915 "clap", 1916 + "indicatif", 1790 1917 "matroska", 1791 1918 "serde_json", 1792 1919 "sqlx",
+1
Cargo.toml
··· 6 6 [dependencies] 7 7 anyhow = "1.0.102" 8 8 clap = { version = "4.6.0", features = ["derive"] } 9 + indicatif = "0.18.4" 9 10 matroska = "0.30.0" 10 11 serde_json = "1.0.149" 11 12 sqlx = { version = "0.8.6", features = ["sqlite", "migrate", "runtime-tokio"] }
+16 -8
src/lib.rs
··· 1 + use indicatif::{ProgressBar, ProgressStyle}; 1 2 use sqlx::{Pool, Sqlite}; 2 3 use std::path::PathBuf; 3 4 use thiserror::Error; ··· 54 55 .collect() 55 56 }); 56 57 57 - if files.len() == 0 { 58 + if files.is_empty() { 58 59 return Err(IndexError::NoVideos); 59 - } else { 60 - println!("Found {} videos.", files.len()); 61 60 } 61 + println!("Found {} videos.", files.len()); 62 + let bar = ProgressBar::new(files.len().try_into().unwrap()); 63 + bar.set_style( 64 + ProgressStyle::with_template( 65 + "[{elapsed_precise} / {duration_precise}] {wide_bar} [{human_pos}/{human_len}]", 66 + ) 67 + .unwrap(), 68 + ); 62 69 63 70 for path in files { 64 71 let video_path: String = path.to_string_lossy().to_string(); 65 72 66 - println!("Processing video: {}", video_path); 67 - 68 73 let json: serde_json::Value = match extract_json_metadata(&path) { 69 74 Ok(value) => value, 70 75 Err(error) => { 71 - println!( 76 + bar.println(format!( 72 77 "Error, couldn't index \"{}\" - {}", 73 78 path.to_string_lossy(), 74 - error 75 - ); 79 + error, 80 + )); 76 81 continue; 77 82 } 78 83 }; ··· 85 90 .execute(db_pool) 86 91 .await 87 92 .map_err(|_| IndexError::DatabaseError)?; 93 + 94 + bar.inc(1); 88 95 } 89 96 97 + bar.finish(); 90 98 Ok(()) 91 99 }