Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.DefinePanel("Metadata to txt", { author: "ZedZagg" });
- include(`${fb.ComponentPath}docs\\Flags.js`);
- include(`${fb.ComponentPath}docs\\Helpers.js`);
- let pathSet = false;
- let path = "";
- function on_mouse_lbtn_down(x, y) {
- try {
- path = utils.InputBox(window.ID, "Enter output directory", "Spider Monkey Panel", "C:\\foobar\\", true);
- console.log(path);
- // OK was pressed.
- pathSet = true;
- } catch(e) {
- // Dialog was closed by pressing Esc, Cancel or the Close button.
- pathSet = false;
- }
- window.Repaint();
- }
- function on_playback_new_track(metadb) {
- if(!metadb)
- return;
- if(pathSet){
- //let tfo = fb.TitleFormat("%title%$crlf()%artist%$crlf()%album%");
- //console.log(tfo.EvalWithMetadb(metadb));
- //utils.WriteTextFile(path, tfo.EvalWithMetadb(metadb), true);
- let tfo = fb.TitleFormat("%title%");
- utils.WriteTextFile(path + "\\title.txt", tfo.EvalWithMetadb(metadb), true);
- tfo = fb.TitleFormat("%artist%");
- utils.WriteTextFile(path + "\\artist.txt", tfo.EvalWithMetadb(metadb), true);
- tfo = fb.TitleFormat("%album%");
- utils.WriteTextFile(path + "\\album.txt", tfo.EvalWithMetadb(metadb), true);
- }
- }
- function on_paint(gr) {
- if(!pathSet)
- gr.FillSolidRect(0, 0, ww, wh, RGB(255, 0, 0));
- else
- gr.FillSolidRect(0, 0, ww, wh, RGB(0, 255, 0));
- }
- function on_size() {
- ww = window.Width;
- wh = window.Height;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement