autonomous-music-rating team mailing list archive
-
autonomous-music-rating team
-
Mailing list archive
-
Message #00000
Re: Autonomous music rating
Hi,
On Mirsal's request, I've created the group
https://launchpad.net/~autonomous-music-rating so that we have a
mailing list to discuss the topic. You may need to subscribe to it
manually depending on your Launchpad account configuration. I've also
created a project with the same name,
https://launchpad.net/autonomous-music-rating, so that we can host
Bazaar branches there.
I don't know how familiar you are with Zeitgeist or if you have used
it yet. It'd be best to build off the latest code, so if you have
installed the Ubuntu packages, please get a checkout from Bazaar
instead ("bzr get lp:zeitgeist zeitgeist-trunk"). You can either
install it system-wide (./autogen.sh; make; sudo make install, after
uninstalling the Ubuntu package) or just remember to start it manually
whenever you want to work with it (./zeitgeist-daemon.py) [0], and
symlinking its "zeitgeist" directory (the public Python API) into
whichever other directory you want to use it from.
You can find the only music data-source we have at the moment, the one
for Rhythmbox, in https://launchpad.net/zeitgeist-dataproviders. Check
out the code with "bzr get lp:zeitgeist-dataproviders". You can
install the data-source with "cd rhythmbox; sh ./install.sh".
To start working on this, I think the easiest would be to use Python,
as it's what's best supported by Zeitgeist [1], and because of it's
suitability for rapid prototyping. Bjarke, I'm not sure if you're
familiar with Python though? I'm attaching an example of a Python
script that gets information about all played songs [2].
A C library for Zeitgeist is under development but I don't know how
long exactly it'll take until it'll be publicly available. In case you
don't want to go with Python, it's still possible to use Zeitgeist
directly over D-Bus in the meantime, but it's API has some complicated
data structures which aren't that nice to work with from C.
I'd be good if we could all meet on IRC (#zeitgeist on
irc.freenode.net for example) to talk about how we want to start
approaching this.
By the way, in case you get inspired and want to start getting your
hands dirty, here is a quick introduction to Bazaar::
- bzr init - creates a Bazaar branch in the current directory
- bzr add - adds files to the branch
- bzr commit - commits all changes (of files which were added to
the branch at some previous point) to a new revision
- bzr push lp:~autonomous-music-rating/autonomous-music-rating/NAME
- creates a name branch owned by the autonomous-music-rating team
and part of the autonomous-music-rating project, with name "NAME".
- bzr get X - gets a copy of branch X (also "bzr branch X")
- bzr pull X - gets any new commits pushed to branch X (omit X
to get changes from the default branch, which is the one you pulled
from or, if it's a branch you created, the first place to which you
pushed; you can change the default branch with "bzr pull X
--remember")
- bzr merge X - merges any conflicting changes from branch X
Cheers,
[0] A third option would be copying
extra/org.gnome.zeitgeist.service.in into
/usr/share/dbus-1/services/org.gnome.zeitgeist.service and changing
the path in the Exec= line to wherever you have your code checkout.
Zeitgeist will then be started automatically whenever it is needed.
[1] Zeitgeist documentation, including documentation for the
"zeitgeist.client" and "zeitgeist.datamodel" Python modules:
http://zeitgeist-project.com/docs/0.3.2/
[2] Note that it uses zeitgeist.client.ZeitgeistDBusInterface instead
of the more polished zeitgeist.client.ZeitgeistClient because the
later only allows asynchronous usage (it was designed with GUI
applications in mind).
--
Siegfried-Angel Gevatter Pujals (RainCT)
Free Software Developer 363DEAE3
#! /usr/bin/env python
from zeitgeist.datamodel import Event, Subject, TimeRange, StorageState, \
ResultType, Interpretation, Manifestation
from zeitgeist.client import ZeitgeistDBusInterface # raw API for sync methods
zg = ZeitgeistDBusInterface()
event_templates = [
Event.new_for_values(
interpretation=Interpretation.OPEN_EVENT,
subject_interpretation=Interpretation.MUSIC.uri,
subject_manifestation=Manifestation.FILE),
Event.new_for_values(
interpretation=Interpretation.CLOSE_EVENT,
subject_interpretation=Interpretation.MUSIC.uri,
subject_manifestation=Manifestation.FILE)
]
events = zg.FindEvents(
TimeRange.until_now(),
event_templates,
StorageState.Any,
0, # no limit on how many events we get
ResultType.MostRecentEvents) # everything, newest first
events = [Event.new_for_struct(event) for event in events]
for event in events:
if event.get_interpretation() == Interpretation.OPEN_EVENT:
action = 'Started playing'
reason = '(manually)' \
if event.get_manifestation() == Manifestation.USER_ACTIVITY \
else '(automatically)' # SCHEDULED_ACTIVITY
else: # CLOSE_EVENT
action = 'Stopped playing'
reason = ''
subject = event.get_subjects()[0]
uri = '/'.join(subject.get_uri().split('/')[2:])
print action, uri, 'at', event.get_timestamp(), reason