Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. window.DefinePanel("Metadata to txt", { author: "ZedZagg" });
  2. include(`${fb.ComponentPath}docs\\Flags.js`);
  3. include(`${fb.ComponentPath}docs\\Helpers.js`);
  4.  
  5. let pathSet = false;
  6. let path = "";
  7.  
  8. function on_mouse_lbtn_down(x, y) {
  9. try {
  10. path = utils.InputBox(window.ID, "Enter output directory", "Spider Monkey Panel", "C:\\foobar\\", true);
  11. console.log(path);
  12. // OK was pressed.
  13. pathSet = true;
  14. } catch(e) {
  15. // Dialog was closed by pressing Esc, Cancel or the Close button.
  16. pathSet = false;
  17. }
  18. window.Repaint();
  19. }
  20.  
  21. function on_playback_new_track(metadb) {
  22. if(!metadb)
  23. return;
  24.  
  25. if(pathSet){
  26. //let tfo = fb.TitleFormat("%title%$crlf()%artist%$crlf()%album%");
  27. //console.log(tfo.EvalWithMetadb(metadb));
  28.  
  29. //utils.WriteTextFile(path, tfo.EvalWithMetadb(metadb), true);
  30. let tfo = fb.TitleFormat("%title%");
  31. utils.WriteTextFile(path + "\\title.txt", tfo.EvalWithMetadb(metadb), true);
  32.  
  33. tfo = fb.TitleFormat("%artist%");
  34. utils.WriteTextFile(path + "\\artist.txt", tfo.EvalWithMetadb(metadb), true);
  35.  
  36. tfo = fb.TitleFormat("%album%");
  37. utils.WriteTextFile(path + "\\album.txt", tfo.EvalWithMetadb(metadb), true);
  38. }
  39. }
  40.  
  41. function on_paint(gr) {
  42. if(!pathSet)
  43. gr.FillSolidRect(0, 0, ww, wh, RGB(255, 0, 0));
  44. else
  45. gr.FillSolidRect(0, 0, ww, wh, RGB(0, 255, 0));
  46. }
  47.  
  48. function on_size() {
  49. ww = window.Width;
  50. wh = window.Height;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement