Index: MediaStore.py
===================================================================
--- MediaStore.py (revision 5374)
+++ MediaStore.py (working copy)
@@ -2,6 +2,7 @@
import rhythmdb
import louie
+import urllib
from coherence.upnp.core import DIDLLite
@@ -22,12 +23,13 @@
self.parent_id = parent_id
self.name = name
self.mimetype = 'directory'
- self.item = DIDLLite.StorageFolder(id, parent_id,self.name)
+ self.item = DIDLLite.Container(id, parent_id,self.name)
self.update_id = 0
if children_callback != None:
self.children = children_callback
else:
self.children = []
+ self.item.childCount = self.get_child_count()
def add_child(self, child):
self.children.append(child)
@@ -75,18 +77,33 @@
# load common values
entry = self.store.db.entry_lookup_by_id (self.id)
- bitrate = self.store.db.entry_get (entry, rhythmdb.PROP_BITRATE)
- duration = self.store.db.entry_get (entry, rhythmdb.PROP_DURATION)
+ # Bitrate is in bytes/second, not kilobits/second
+ bitrate = self.store.db.entry_get (entry, rhythmdb.PROP_BITRATE) * 1024 / 8
+ # Duration is in HH:MM:SS format
+ seconds = self.store.db.entry_get (entry, rhythmdb.PROP_DURATION)
+ hours = seconds / 3600
+ seconds = seconds - hours * 3600
+ minutes = seconds / 60
+ seconds = seconds - minutes * 60
+ duration = ("%02d:%02d:%02d") % (hours, minutes, seconds)
+
location = self.store.db.entry_get (entry, rhythmdb.PROP_LOCATION)
+ if location.startswith("file://"):
+ location = unicode(urllib.url2pathname(location)[len("file://"):])
+ else:
+ location = None
mimetype = self.store.db.entry_get (entry, rhythmdb.PROP_MIMETYPE)
+ # This isn't a real mime-type
+ if mimetype == "application/x-id3":
+ mimetype = "audio/mpeg"
size = self.store.db.entry_get (entry, rhythmdb.PROP_FILE_SIZE)
# create item
item = DIDLLite.MusicTrack(self.id + CONTAINER_COUNT)
item.album = self.store.db.entry_get (entry, rhythmdb.PROP_ALBUM)
- ##item.albumArtURI = ## can we somehow store art in the upnp share??
+ #item.albumArtURI = ## can we somehow store art in the upnp share??
item.artist = self.store.db.entry_get (entry, rhythmdb.PROP_ARTIST)
- ##item.date =
+ #item.date =
item.genre = self.store.db.entry_get (entry, rhythmdb.PROP_GENRE)
item.originalTrackNumber = str(self.store.db.entry_get (entry, rhythmdb.PROP_TRACK_NUMBER))
item.title = self.store.db.entry_get (entry, rhythmdb.PROP_TITLE) # much nicer if it was entry.title
@@ -125,11 +142,10 @@
entry = self.store.db.entry_lookup_by_id (self.id)
uri = self.store.db.entry_get (entry, rhythmdb.PROP_LOCATION)
if uri.startswith("file://"):
- return uri[len("file://"):]
+ return unicode(urllib.url2pathname(uri)[len("file://"):])
else:
return None
-
class MediaStore:
implements = ['MediaServer']
Index: __init__.py
===================================================================
--- __init__.py (revision 5374)
+++ __init__.py (working copy)
@@ -8,11 +8,6 @@
rb.Plugin.__init__(self)
def activate(self, shell):
- self.coherence = self.get_coherence()
- if self.coherence is None:
- print "Coherence is not installed or too old, aborting"
- return
-
from twisted.internet import gtk2reactor
try:
gtk2reactor.install()
@@ -20,6 +15,11 @@
# sometimes it's already installed
print e
+ self.coherence = self.get_coherence()
+ if self.coherence is None:
+ print "Coherence is not installed or too old, aborting"
+ return
+
print "coherence UPnP plugin activated"
self.shell = shell
self.sources = {}
@@ -42,6 +42,8 @@
if self.coherence is None:
return
+ self.coherence.shutdown()
+
louie.disconnect(self.detected_media_server,
'Coherence.UPnP.ControlPoint.MediaServer.detected',
louie.Any)