Advertisement
Guest User

Untitled

a guest
Apr 27th, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import os, string
  4.  
  5. h = open( 'playlists.xml', 'w' )
  6.  
  7. h.write('<?xml version="1.0"?>\n')
  8. h.write('<rhythmdb-playlists>\n')
  9. h.write(' <playlist name="Play Queue" type="queue"/>\n')
  10. h.write(' <playlist name="My Top Rated" type="automatic" sort-key="Rating" sort-direction="1">\n')
  11. h.write(' <conjunction>\n')
  12. h.write(' <equals prop="type">song</equals>\n')
  13. h.write(' <subquery>\n')
  14. h.write(' <conjunction>\n')
  15. h.write(' <greater prop="rating">4.000000</greater>\n')
  16. h.write(' </conjunction>\n')
  17. h.write(' </subquery>\n')
  18. h.write(' </conjunction>\n')
  19. h.write(' </playlist>\n')
  20. h.write(' <playlist name="Recently Added" type="automatic" sort-key="Artist" sort-direction="0">\n')
  21. h.write(' <conjunction>\n')
  22. h.write(' <equals prop="type">song</equals>\n')
  23. h.write(' <subquery>\n')
  24. h.write(' <conjunction>\n')
  25. h.write(' <current-time-within prop="first-seen">604800</current-time-within>\n')
  26. h.write(' </conjunction>\n')
  27. h.write(' </subquery>\n')
  28. h.write(' </conjunction>\n')
  29. h.write(' </playlist>\n')
  30. h.write(' <playlist name="Recently Played" type="automatic" sort-key="Artist" sort-direction="1">\n')
  31. h.write(' <conjunction>\n')
  32. h.write(' <equals prop="type">song</equals>\n')
  33. h.write(' <subquery>\n')
  34. h.write(' <conjunction>\n')
  35. h.write(' <current-time-within prop="last-played">604800</current-time-within>\n')
  36. h.write(' </conjunction>\n')
  37. h.write(' </subquery>\n')
  38. h.write(' </conjunction>\n')
  39. h.write(' </playlist>\n')
  40.  
  41. if not os.path.exists('playlists'):
  42. os.makedirs('playlists')
  43. os.chdir('playlists')
  44. a = open( 'order_file', 'r' )
  45. for b in a.xreadlines():
  46. if b[-1:] == '\n':
  47. b = b[:-1]
  48. if b[-1:] == '\r':
  49. b = b[:-1]
  50. if b == 'EOF':
  51. break
  52. c = open( b+'.playlist', 'r' )
  53. b = string.replace( b, '&', '&amp;' )
  54. h.write(' <playlist name="'+b+'" type="static">\n')
  55. for line in c.xreadlines():
  56. if line[-1:] == '\n':
  57. line = line[:-1]
  58. if line[-1:] == '\r':
  59. line = line[:-1]
  60. if line != 'EOF':
  61. if line.find('\t') != -1:
  62. line = line[:line.find('\t')]
  63. line = string.replace( line, '&', '&amp;' )
  64. h.write(' <location>'+line+'</location>\n')
  65. else:
  66. break
  67. c.close()
  68. h.write(' </playlist>\n')
  69. a.close()
  70. h.write('</rhythmdb-playlists>\n')
  71. h.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement