We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e8d9fbb commit 9e77b63Copy full SHA for 9e77b63
crates/onetagger-autotag/src/lib.rs
@@ -23,7 +23,7 @@ use crossbeam_channel::{unbounded, Sender, Receiver};
23
use onetagger_tag::{AudioFileFormat, Tag, Field, TagDate, CoverType, TagImpl, EXTENSIONS};
24
use onetagger_shared::Settings;
25
use onetagger_player::AudioSources;
26
-use onetagger_tagger::{Track, AudioFileInfo, TaggerConfig, StylesOptions, AutotaggerSource, AutotaggerSourceBuilder, CAMELOT_NOTES};
+use onetagger_tagger::{Track, AudioFileInfo, TaggerConfig, StylesOptions, AutotaggerSource, AutotaggerSourceBuilder};
27
28
use crate::shazam::Shazam;
29
mod shazam;
@@ -121,9 +121,7 @@ impl TrackImpl for Track {
121
let mut value = self.key.as_ref().unwrap().to_string();
122
// Convert to camelot
123
if config.camelot {
124
- if let Some((_, c)) = CAMELOT_NOTES.iter().find(|(o, _)| o == &value) {
125
- value = c.to_string();
126
- }
+ value = onetagger_tagger::to_camelot(&value).to_owned();
127
}
128
tag.set_field(Field::Key, vec![value], config.overwrite_tag(SupportedTag::Key));
129
crates/onetagger-renamer/src/docs.rs
@@ -42,7 +42,7 @@ lazy_static! {
42
SymbolDoc::prop("last", "Get the last item in an array"),
43
];
44
45
- pub static ref FUNCTIONS: [SymbolDoc; 15] = [
+ pub static ref FUNCTIONS: [SymbolDoc; 17] = [
46
SymbolDoc::f("lower", "Convert all to lowercase", vec![]),
47
SymbolDoc::f("lowercase", "Convert all to lowercase", vec![]),
48
SymbolDoc::f("upper", "Convert all to uppercase", vec![]),
@@ -58,7 +58,8 @@ lazy_static! {
58
SymbolDoc::f("join", "Join array into string with custom separator", vec![DocParameter::s("separator", true)]),
59
SymbolDoc::f("parent", "Get parent folder of path", vec![]),
60
SymbolDoc::f("filename", "Get file/folder name of path", vec![]),
61
-
+ SymbolDoc::f("camelot", "Convert key to camelot, or keep original", vec![DocParameter::s("value", true)]),
62
+ SymbolDoc::f("uncamelot", "Convert key from camelot, or keep original", vec![DocParameter::s("value", true)]),
63
64
65
crates/onetagger-renamer/src/parser.rs
@@ -786,6 +786,28 @@ impl Token for TokenFunction {
786
Some(Data::String(a.last()?.to_string()))
787
},
788
789
+ },
790
+ // Conver to camelot
791
+ "camelot" => {
792
+ match data {
793
+ Data::String(s) => {
794
+ Some(Data::String(onetagger_tagger::to_camelot(s).to_owned()))
795
796
+ Data::Array(a) => {
797
+ Some(Data::Array(a.iter().map(|v| onetagger_tagger::to_camelot(v).to_owned()).collect()))
798
+ }
799
800
801
+ // Convert from camelot
802
+ "uncamelot" => {
803
804
805
+ Some(Data::String(onetagger_tagger::from_camelot(s).to_owned()))
806
807
808
+ Some(Data::Array(a.iter().map(|v| onetagger_tagger::from_camelot(v).to_owned()).collect()))
809
810
811
812
f => {
813
error!("Invalid function: {f}!");
crates/onetagger-tagger/src/lib.rs
@@ -474,6 +474,23 @@ pub const CAMELOT_NOTES: [(&str, &str); 35] = [
474
("E", "12B"),
475
476
477
+/// Convert to camelot or return original
478
+pub fn to_camelot(key: &str) -> &str {
479
+ if let Some((_, v)) = CAMELOT_NOTES.iter().find(|(k, _)| *k == key.trim()) {
480
+ return *v;
481
482
+ key
483
+}
484
+
485
+/// Convert from camelot to normal key
486
+pub fn from_camelot(key: &str) -> &str {
487
+ if let Some((v, _)) = CAMELOT_NOTES.iter().find(|(_, k)| *k == key.trim()) {
488
489
490
491
492
493
494
pub trait LyricsExt {
495
/// Generate LRC data
496
/// If meta is present, will be written
0 commit comments