Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import os, string
- h = open( 'playlists.xml', 'w' )
- h.write('<?xml version="1.0"?>\n')
- h.write('<rhythmdb-playlists>\n')
- h.write(' <playlist name="Play Queue" type="queue"/>\n')
- h.write(' <playlist name="My Top Rated" type="automatic" sort-key="Rating" sort-direction="1">\n')
- h.write(' <conjunction>\n')
- h.write(' <equals prop="type">song</equals>\n')
- h.write(' <subquery>\n')
- h.write(' <conjunction>\n')
- h.write(' <greater prop="rating">4.000000</greater>\n')
- h.write(' </conjunction>\n')
- h.write(' </subquery>\n')
- h.write(' </conjunction>\n')
- h.write(' </playlist>\n')
- h.write(' <playlist name="Recently Added" type="automatic" sort-key="Artist" sort-direction="0">\n')
- h.write(' <conjunction>\n')
- h.write(' <equals prop="type">song</equals>\n')
- h.write(' <subquery>\n')
- h.write(' <conjunction>\n')
- h.write(' <current-time-within prop="first-seen">604800</current-time-within>\n')
- h.write(' </conjunction>\n')
- h.write(' </subquery>\n')
- h.write(' </conjunction>\n')
- h.write(' </playlist>\n')
- h.write(' <playlist name="Recently Played" type="automatic" sort-key="Artist" sort-direction="1">\n')
- h.write(' <conjunction>\n')
- h.write(' <equals prop="type">song</equals>\n')
- h.write(' <subquery>\n')
- h.write(' <conjunction>\n')
- h.write(' <current-time-within prop="last-played">604800</current-time-within>\n')
- h.write(' </conjunction>\n')
- h.write(' </subquery>\n')
- h.write(' </conjunction>\n')
- h.write(' </playlist>\n')
- if not os.path.exists('playlists'):
- os.makedirs('playlists')
- os.chdir('playlists')
- a = open( 'order_file', 'r' )
- for b in a.xreadlines():
- if b[-1:] == '\n':
- b = b[:-1]
- if b[-1:] == '\r':
- b = b[:-1]
- if b == 'EOF':
- break
- c = open( b+'.playlist', 'r' )
- b = string.replace( b, '&', '&' )
- h.write(' <playlist name="'+b+'" type="static">\n')
- for line in c.xreadlines():
- if line[-1:] == '\n':
- line = line[:-1]
- if line[-1:] == '\r':
- line = line[:-1]
- if line != 'EOF':
- if line.find('\t') != -1:
- line = line[:line.find('\t')]
- line = string.replace( line, '&', '&' )
- h.write(' <location>'+line+'</location>\n')
- else:
- break
- c.close()
- h.write(' </playlist>\n')
- a.close()
- h.write('</rhythmdb-playlists>\n')
- h.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement