Time strings

During scanning I convert the length into a time string ( "h:mm:ss" ).
This is drawn in the gui when a collection list is populated.
This commit is contained in:
Bryan Schumaker 2010-10-11 18:22:05 -04:00
parent 6c6477b677
commit 6934974d75
3 changed files with 10 additions and 6 deletions

View File

@ -2,6 +2,9 @@
import libsaria
import datetime
timedelta = datetime.timedelta
tag = None
audio = None
ins_table = None
@ -9,8 +12,9 @@ ins_index = None
ins_tree = None
class TrackRecord:
def __init__(self, year, length):
def __init__(self, year, length, lenstr):
self.length = length
self.lenstr = lenstr
self.count = 0
self.year = year
#self.like = None
@ -58,7 +62,7 @@ class Collection:
def walk_tags(self):
for tag in self.tag_tree.walk_forwards():
rec = self.records[tag[3]]
yield tag + [rec.year] + [rec.length]
yield tag + [rec.year] + [rec.lenstr]
def find_id(self, file):
stripped = file.strip(libsaria.path.sep)
@ -94,7 +98,8 @@ class Collection:
if title == "":
title = u"Unknown Title"
record = TrackRecord(t.year, audio.length)
len = audio.length
record = TrackRecord(t.year, len, "%s" % timedelta(seconds=len))
id = self.next_record
self.next_record += 1

View File

@ -47,7 +47,6 @@ class Index(dict):
text = unicode(text)
terms = format(text)
results = dict()
#results = set()
search = re.search
get = self.get

View File

@ -4,7 +4,7 @@
from libsaria import collection
collection.new_source("~/Desktop")
#collection.new_source("~/Music/")
#collection.new_source("~/Desktop")
collection.new_source("~/Music/")
#collection.new_source("/media/Music")
print collection.library.size