[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

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

Add bpm metadata editing

Kasper (Dec 14, 2021, 5:04 PM +0100) 8b28db59 a3baa723

+54 -13
+1 -1
CHANGELOG.md
··· 5 5 - Add `Ctrl+U` (macOS: `Cmd+U`) and `View > Toggle Queue` to show/hide the queue 6 6 - Add support for changing track artworks using double-click and drag-and-drop 7 7 - Add `Ctrl+]` and `Ctrl+]` (macOS: `Cmd+]` and `Cmd+]`) for opening the next and previous track in the "Get Info" window 8 - - Add metadata editing of track number, total tracks, disc number and total discs 8 + - Add metadata editing of bpm, track number, total tracks, disc number and total discs 9 9 - Add more items to the Song menu 10 10 - Add `Escape` shortcut for deselecting tracks 11 11 - Add support selecting tracks via `Ctrl+A` (macOS: `Cmd+A`), `Shift+Up/Down`, `Alt+Up/Down`, `Shift+Alt+Up/Down`
+50 -5
native/src/tracks.rs
··· 371 371 trackCount: String, 372 372 discNum: String, 373 373 discCount: String, 374 + bpm: String, 374 375 comments: String, 375 376 } 376 377 ··· 601 602 } 602 603 } 603 604 Ok(()) 605 + } 606 + pub fn remove_bpm(&mut self) { 607 + match self { 608 + Tag::Id3(tag) => tag.remove("TBPM"), 609 + Tag::Mp4(tag) => tag.remove_bpm(), 610 + } 611 + } 612 + pub fn set_bpm(&mut self, value: u16) { 613 + match self { 614 + Tag::Id3(tag) => { 615 + tag.set_text("TBPM", value.to_string()); 616 + } 617 + Tag::Mp4(tag) => { 618 + tag.set_bpm(value); 619 + } 620 + } 604 621 } 605 622 pub fn remove_comments(&mut self) { 606 623 match self { ··· 916 933 // year 917 934 let new_year_i32 = match new_info.year.as_ref() { 918 935 "" => None, 919 - value => Some(value.parse().expect("Invalid year")), 936 + value => match value.parse() { 937 + Ok(n) => Some(n), 938 + Err(_) => throw!("Invalid year"), 939 + }, 920 940 }; 921 941 let new_year_i64 = new_year_i32.map(|n| i64::from(n)); 922 942 match new_year_i32 { ··· 927 947 // track_number, track_count 928 948 let new_track_number: Option<u32> = match new_info.trackNum.as_ref() { 929 949 "" => None, 930 - value => Some(value.parse().expect("Invalid track number")), 950 + value => match value.parse() { 951 + Ok(n) => Some(n), 952 + Err(_) => throw!("Invalid track number"), 953 + }, 931 954 }; 932 955 let new_track_count: Option<u32> = match new_info.trackCount.as_ref() { 933 956 "" => None, 934 - value => Some(value.parse().expect("Invalid track count")), 957 + value => match value.parse() { 958 + Ok(n) => Some(n), 959 + Err(_) => throw!("Invalid track count"), 960 + }, 935 961 }; 936 962 match tag.set_track_info(new_track_number, new_track_count) { 937 963 Ok(()) => {} ··· 943 969 // disc_number, disc_count 944 970 let new_disc_number: Option<u32> = match new_info.discNum.as_ref() { 945 971 "" => None, 946 - value => Some(value.parse().expect("Invalid disc number")), 972 + value => match value.parse() { 973 + Ok(n) => Some(n), 974 + Err(_) => throw!("Invalid disc number"), 975 + }, 947 976 }; 948 977 let new_disc_count: Option<u32> = match new_info.discCount.as_ref() { 949 978 "" => None, 950 - value => Some(value.parse().expect("Invalid disc count")), 979 + value => match value.parse() { 980 + Ok(n) => Some(n), 981 + Err(_) => throw!("Invalid disc count"), 982 + }, 951 983 }; 952 984 match tag.set_disc_info(new_disc_number, new_disc_count) { 953 985 Ok(()) => {} ··· 956 988 Err(e) => Err(e)?, 957 989 }; 958 990 991 + let new_bpm: Option<u16> = match new_info.bpm.as_ref() { 992 + "" => None, 993 + value => match value.parse() { 994 + Ok(n) => Some(n), 995 + Err(_) => throw!("Invalid bpm"), 996 + }, 997 + }; 998 + match new_bpm { 999 + None => tag.remove_bpm(), 1000 + Some(value) => tag.set_bpm(value), 1001 + }; 1002 + 959 1003 // comment 960 1004 match new_info.comments.as_ref() { 961 1005 "" => tag.remove_comments(), ··· 991 1035 track.trackCount = new_track_count; 992 1036 track.discNum = new_disc_number; 993 1037 track.discCount = new_disc_count; 1038 + track.bpm = new_bpm.map(|n| n.into()); 994 1039 track.comments = new_comments; 995 1040 996 1041 return ctx.env.get_undefined();
+2 -4
src/components/TrackInfo.svelte
··· 68 68 trackCount, 69 69 discNum, 70 70 discCount, 71 - // bpm, 71 + bpm, 72 72 // compilation, 73 73 // rating, 74 74 // liked, ··· 253 253 </div> 254 254 <div class="row"> 255 255 <div class="label">BPM</div> 256 - <input disabled class="medium" type="text" bind:value={bpm} /> 256 + <input class="medium" type="text" bind:value={bpm} /> 257 257 </div> 258 258 <div class="row"> 259 259 <div class="label">Play count</div> ··· 331 331 color: inherit 332 332 border: 1px solid rgba(#ffffff, 0.25) 333 333 box-sizing: border-box 334 - &[disabled] 335 - opacity: 0.4 336 334 &.num 337 335 width: 30px 338 336 flex-grow: 0
+1 -3
src/stores/trackInfo.ts
··· 16 16 trackCount: string 17 17 discNum: string 18 18 discCount: string 19 - // discNum: string 20 - // discCount: string 21 - // bpm: string 19 + bpm: string 22 20 // compilation: string 23 21 // rating: string 24 22 // liked: string