2009-05-31 17:31:09 -04:00
|
|
|
from duration import Duration
|
|
|
|
|
|
|
|
class SongInfo:
|
|
|
|
def __init__(self):
|
2009-06-26 20:05:50 -04:00
|
|
|
self.id = 0
|
2009-05-31 17:31:09 -04:00
|
|
|
self.filename = ""
|
2009-06-26 20:05:50 -04:00
|
|
|
self.count = 0
|
2009-06-28 14:05:17 -04:00
|
|
|
# Length is a string, duration is an int
|
|
|
|
self.length = ""
|
|
|
|
self.duration = 0
|
2009-06-08 21:45:44 -04:00
|
|
|
self.title = ""
|
|
|
|
self.album = ""
|
|
|
|
self.artist = ""
|
2009-06-28 14:05:17 -04:00
|
|
|
|
|
|
|
|
2009-06-28 23:13:12 -04:00
|
|
|
def setTime(self,time):
|
|
|
|
self.duration = time
|
|
|
|
self.length = self.fixTime(time)
|
|
|
|
|
|
|
|
def fixTime(self,time):
|
|
|
|
#time = self.duration
|
2009-06-28 14:05:17 -04:00
|
|
|
# Find hour
|
2009-06-28 23:13:12 -04:00
|
|
|
length = ""
|
2009-06-28 14:05:17 -04:00
|
|
|
if time >= 3600:
|
|
|
|
hour = time/3600
|
|
|
|
time = time - (self.hour * 3600)
|
|
|
|
if hour > 0:
|
2009-06-28 23:13:12 -04:00
|
|
|
length=str(hour)+":"
|
2009-06-28 14:05:17 -04:00
|
|
|
# Find minute
|
|
|
|
if time >= 60:
|
|
|
|
min = time/60
|
|
|
|
time = time - (min * 60)
|
|
|
|
if min < 10:
|
2009-06-28 23:13:12 -04:00
|
|
|
length+="0"
|
|
|
|
length+=str(min)+":"
|
2009-06-28 14:05:17 -04:00
|
|
|
else:
|
2009-06-28 23:13:12 -04:00
|
|
|
length+="00:"
|
2009-06-28 14:05:17 -04:00
|
|
|
# Remainder is seconds
|
|
|
|
sec = time
|
|
|
|
if sec < 10:
|
2009-06-28 23:13:12 -04:00
|
|
|
length+="0"
|
|
|
|
length+=str(sec)
|
|
|
|
return length
|