coverart.awk 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #
  2. # Copyright (C) 2005, 2006 Stephen Jungels
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # See COPYING for the full text of the license.
  15. BEGIN {
  16. state = 0;
  17. }
  18. {
  19. if (state==0 && $0 ~ /<coverart>/) state = 1;
  20. if (state==1 && $0 ~ /<medium>/)
  21. {
  22. state = 2;
  23. art = "";
  24. }
  25. if (state==2)
  26. {
  27. art = art $0;
  28. }
  29. if (state==2 && $0 ~ /<\/medium>/)
  30. {
  31. state = 3;
  32. sub (".*<medium>[ \t]*", "", art);
  33. sub ("[ \t]*</medium>.*", "", art);
  34. }
  35. }
  36. END {
  37. if (state==3)
  38. print art;
  39. else
  40. print "No art available";
  41. }