Changing Song Length to a Number with Pyfoobar
<p>While attempting to make a now playing script for foobar with <a href="https://code.google.com/p/pyfoobar/" rel="nofollow">pyfoobar</a>, I've been trying to convert the length of the current track, a string, into a regular integer.</p>

<pre><code>from pyfoobar import foobar
import time

fb2k = foobar()
while(fb2k.isPlaying()==True):
    fb2k.playRandom()
    length=fb2k.lengthOfTrack()
    minute=int(length[0])*60
    second=int(length[2:])
    length=(minute+second)-1
    print "Now Playing: "+fb2k.getCurrentArtist()+" - "+fb2k.getCurrentTrack()
    time.sleep(length)
</code></pre>

<p>In order to update with each new track, I'm using a loop delayed by the number of seconds in the current track. When compiling, I get the following error:</p>

<pre><code>Traceback (most recent call last):
  File "C:\Users\000\Downloads\pyfoobar\pyfoobar\playing.py", line 8, in &lt;module&gt;
    minute=int(length[0])*60
IndexError: string index out of range
</code></pre>

<p>There's probably something obvious I'm missing, but I can't find what's fixing the error, especially because the lines calculating the length will return the correct number of seconds.</p>
