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:
parent
6c6477b677
commit
6934974d75
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
import libsaria
|
import libsaria
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
timedelta = datetime.timedelta
|
||||||
|
|
||||||
tag = None
|
tag = None
|
||||||
audio = None
|
audio = None
|
||||||
ins_table = None
|
ins_table = None
|
||||||
|
@ -9,8 +12,9 @@ ins_index = None
|
||||||
ins_tree = None
|
ins_tree = None
|
||||||
|
|
||||||
class TrackRecord:
|
class TrackRecord:
|
||||||
def __init__(self, year, length):
|
def __init__(self, year, length, lenstr):
|
||||||
self.length = length
|
self.length = length
|
||||||
|
self.lenstr = lenstr
|
||||||
self.count = 0
|
self.count = 0
|
||||||
self.year = year
|
self.year = year
|
||||||
#self.like = None
|
#self.like = None
|
||||||
|
@ -58,7 +62,7 @@ class Collection:
|
||||||
def walk_tags(self):
|
def walk_tags(self):
|
||||||
for tag in self.tag_tree.walk_forwards():
|
for tag in self.tag_tree.walk_forwards():
|
||||||
rec = self.records[tag[3]]
|
rec = self.records[tag[3]]
|
||||||
yield tag + [rec.year] + [rec.length]
|
yield tag + [rec.year] + [rec.lenstr]
|
||||||
|
|
||||||
def find_id(self, file):
|
def find_id(self, file):
|
||||||
stripped = file.strip(libsaria.path.sep)
|
stripped = file.strip(libsaria.path.sep)
|
||||||
|
@ -94,7 +98,8 @@ class Collection:
|
||||||
if title == "":
|
if title == "":
|
||||||
title = u"Unknown 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
|
id = self.next_record
|
||||||
self.next_record += 1
|
self.next_record += 1
|
||||||
|
|
|
@ -47,7 +47,6 @@ class Index(dict):
|
||||||
text = unicode(text)
|
text = unicode(text)
|
||||||
terms = format(text)
|
terms = format(text)
|
||||||
results = dict()
|
results = dict()
|
||||||
#results = set()
|
|
||||||
|
|
||||||
search = re.search
|
search = re.search
|
||||||
get = self.get
|
get = self.get
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
from libsaria import collection
|
from libsaria import collection
|
||||||
|
|
||||||
|
|
||||||
collection.new_source("~/Desktop")
|
#collection.new_source("~/Desktop")
|
||||||
#collection.new_source("~/Music/")
|
collection.new_source("~/Music/")
|
||||||
#collection.new_source("/media/Music")
|
#collection.new_source("/media/Music")
|
||||||
print collection.library.size
|
print collection.library.size
|
||||||
|
|
Loading…
Reference in New Issue