querystream.awk 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. interactive = 0;
  17. }
  18. /<tr>/ {
  19. record = 1; row = ""; save = 0;
  20. }
  21. {
  22. if (record==1) row = row $0;
  23. }
  24. /playlist.pls/ {
  25. save = 1;
  26. }
  27. /<\/tr>/ {
  28. if (save==1)
  29. {
  30. hit = 1;
  31. nh = split(hints, hint);
  32. i = 1;
  33. while (i<=nh)
  34. {
  35. gsub ("_", " ", hint[i]);
  36. if (hint[i]=="not" && i < nh)
  37. {
  38. gsub("_", " ", hint[i+1]);
  39. if (match(tolower(row), tolower(hint[i+1])))
  40. {
  41. hit = 0;
  42. break;
  43. }
  44. else
  45. i += 2;
  46. }
  47. else
  48. {
  49. if (mix==0 && !match(tolower(row), tolower(hint[i])))
  50. {
  51. hit = 0;
  52. break;
  53. }
  54. else
  55. i++;
  56. }
  57. }
  58. if (hit==1)
  59. {
  60. if (interactive==1)
  61. {
  62. if (match(row, \
  63. /<a id=\"listlinks\" target=\"_scurl\" href=\"[^\"]*\">.*?<\/a>/) > 0)
  64. {
  65. desc = substr(row, RSTART, RLENGTH);
  66. sub(/<a id=\"listlinks\" target=\"_scurl\" href=\"[^\"]*\">/, "", desc);
  67. gsub("</a>", "", desc);
  68. gsub("<[^>]*>", "", desc);
  69. if (match(row, /shoutcast-playlist.pls\?rn=[0-9]+&file=filename.pls/) > 0)
  70. {
  71. a = substr(row, RSTART, RLENGTH);
  72. printf("# %s\n", desc);
  73. printf "http://www.shoutcast.com/sbin/%s\n", a;
  74. }
  75. }
  76. }
  77. else
  78. {
  79. if (match(row, /shoutcast-playlist.pls\?rn=[0-9]+&file=filename.pls/) > 0)
  80. {
  81. a = substr(row, RSTART, RLENGTH);
  82. printf "http://www.shoutcast.com/sbin/%s\n", a;
  83. }
  84. }
  85. }
  86. }
  87. save = 0;
  88. record = 0;
  89. }