The playlist is now written using a single call.
The script also sleeps for 1 sec prior to processing an empty playlist.
This commit is contained in:
parent
c639414ec3
commit
6bce98ea9e
1 changed files with 8 additions and 5 deletions
11
xmmslist.py
11
xmmslist.py
|
@ -66,6 +66,8 @@ if len(sys.argv) > 1:
|
||||||
if m:
|
if m:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if (os.path.getsize(playlist) == 0):
|
||||||
|
time.sleep(1)
|
||||||
f = open(playlist, 'r')
|
f = open(playlist, 'r')
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -98,20 +100,21 @@ if len(sys.argv) > 1:
|
||||||
|
|
||||||
song += '</tr>\n'
|
song += '</tr>\n'
|
||||||
|
|
||||||
f = open(playlist, 'w')
|
plist = song
|
||||||
f.write(song)
|
|
||||||
|
|
||||||
stop = len(lines) - 1
|
stop = len(lines) - 1
|
||||||
if stop > 0:
|
if stop > 0:
|
||||||
i = 1
|
i = 1
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if song != line:
|
if song != line:
|
||||||
f.write(line)
|
plist += line
|
||||||
i += 1
|
i += 1
|
||||||
if i >= maxsongs or i > stop:
|
if i >= maxsongs or i > stop:
|
||||||
break
|
break
|
||||||
|
|
||||||
# Last Update
|
# Last Update
|
||||||
f.write('<tr><td colspan="3" valign="bottom" align="left"><br><br><small>' + time.strftime('Updated on %B %d, %Y at %H:%M %Z') + '</small></td><td colspan="2" valign="bottom" align="right"><small><a href="http://www.thauvin.net/blog/stories.jsp?id=5#xmmslist" class="small" target="_blank">' + os.path.basename(sys.argv[0]) + '</a> ' + version + '</small></td></tr>\n')
|
plist += ('<tr><td colspan="3" valign="bottom" align="left"><br><br><small>' + time.strftime('Updated on %B %d, %Y at %H:%M %Z') + '</small></td><td colspan="2" valign="bottom" align="right"><small><a href="http://www.thauvin.net/blog/stories.jsp?id=5#xmmslist" class="small" target="_blank">' + os.path.basename(sys.argv[0]) + '</a> ' + version + '</small></td></tr>\n')
|
||||||
|
|
||||||
|
f = open(playlist, 'w')
|
||||||
|
f.write(plist)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue