[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r174 - in gnue-cddb: . schema
From: |
johannes |
Subject: |
r174 - in gnue-cddb: . schema |
Date: |
Mon, 27 Dec 2004 06:57:23 -0600 (CST) |
Author: johannes
Date: 2004-12-27 06:57:22 -0600 (Mon, 27 Dec 2004)
New Revision: 174
Added:
gnue-cddb/updtags.py
Modified:
gnue-cddb/disc.gfd
gnue-cddb/schema/cddb.gcd
gnue-cddb/schema/filedb.gcd
Log:
Bug fixes and improvements
Modified: gnue-cddb/disc.gfd
===================================================================
--- gnue-cddb/disc.gfd 2004-12-20 20:03:27 UTC (rev 173)
+++ gnue-cddb/disc.gfd 2004-12-27 12:57:22 UTC (rev 174)
@@ -33,11 +33,11 @@
<!-- =================================================================== -->
<datasource connection="appserver" name="dtsDArtist" table="cddb_artist"
- order_by="cddb_name" prequery="True" cache="250"
+ order_by="cddb_name" prequery="True" cache="500"
explicitfields="cddb_lastname,cddb_middlename,cddb_firstname,cddb_matchcode"
/>
<datasource connection="appserver" name="dtsTArtist" table="cddb_artist"
- order_by="cddb_name" prequery="True" cache="250"
+ order_by="cddb_name" prequery="True" cache="500"
explicitfields="cddb_lastname,cddb_middlename,cddb_firstname,cddb_matchcode"
/>
@@ -47,10 +47,12 @@
<datasource connection="appserver" name="dtsOptions" table="cddb_options"
prequery="True" />
- <datasource connection="appserver" name="dtsDisc" table="cddb_disc" />
+ <datasource connection="appserver" name="dtsDisc" table="cddb_disc"
+ order_by="cddb_title" />
+
<datasource connection="appserver" name="dtsTrack" table="cddb_track"
master="dtsDisc" masterlink="gnue_id" detaillink="cddb_disc"
- order_by="cddb_track" />
+ order_by="cddb_track" cache="20" />
<datasource connection="appserver" name="dtsDiscArtist"
table="cddb_discartist" master="dtsDisc" masterlink="gnue_id"
@@ -62,7 +64,7 @@
<datasource connection="appserver" name="dtsSrcArtist" table="cddb_artist"
explicitfields="cddb_lastname,cddb_middlename,cddb_firstname,cddb_matchcode"
- prequery="False" cache="250" />
+ prequery="False" cache="500" />
<!-- =================================================================== -->
<!-- Blocks -->
@@ -97,7 +99,7 @@
<field name="track" field="cddb_track" maxLength="2"
typecast="number" />
- <field name="title" field="cddb_title" maxLength="90" />
+ <field name="title" field="cddb_title" maxLength="190" />
<field name="comment" field="cddb_comment" maxLength="70" />
<field name="length" field="cddb_length" typecast="date" />
@@ -155,7 +157,8 @@
<button c:x="65" c:y="3" c:width="3" label="..." navigable="False">
<trigger type="ON-ACTION">
- blkDisc.url.set (blkDisc.call ('filedb_defaultURL', None))
+ param = {'artistid': blkDiscArtist.artist.get ()}
+ blkDisc.url.set (blkDisc.call ('filedb_defaultURL', param))
</trigger>
</button>
@@ -291,7 +294,7 @@
blkDisc.title.set (title)
blkDisc.category.set (match ['category'])
blkDiscArtist.artist.set (art)
- blkDisc.url.set (blkDisc.call ('filedb_defaultURL', None))
+ blkDisc.url.set (blkDisc.call ('filedb_defaultURL', {'artistid': art}))
<!-- Download the selected match from the remote cd database -->
setStatusText ("Downloading selected match ...")
@@ -432,6 +435,8 @@
activateTrigger ('tag_files')
+ form.commit ()
+
showMessage ('Encoding complete')
</trigger>
Modified: gnue-cddb/schema/cddb.gcd
===================================================================
--- gnue-cddb/schema/cddb.gcd 2004-12-20 20:03:27 UTC (rev 173)
+++ gnue-cddb/schema/cddb.gcd 2004-12-27 12:57:22 UTC (rev 174)
@@ -37,17 +37,24 @@
<property name="name" type="string(100)">
from string import join
parts = []
- for i in [self.lastname, self.middlename, self.firstname]:
+ for i in [self.firstname, self.middlename]:
if i is not None and len (i.strip ()):
parts.append (i.strip ())
+ initial = join (parts, ' ')
+ parts = []
+
+ for i in [self.lastname, initial]:
+ if i is not None and len (i.strip ()):
+ parts.append (i.strip ())
+
return join (parts, ', ')
</property>
<property name="matchcode" type="string(100)">
from string import join
parts = []
- for i in [self.lastname, self.middlename, self.firstname]:
+ for i in [self.lastname, self.firstname, self.middlename]:
if i is not None and len (i.strip ()):
parts.append (i.strip ().upper ())
Modified: gnue-cddb/schema/filedb.gcd
===================================================================
--- gnue-cddb/schema/filedb.gcd 2004-12-20 20:03:27 UTC (rev 173)
+++ gnue-cddb/schema/filedb.gcd 2004-12-27 12:57:22 UTC (rev 174)
@@ -42,6 +42,7 @@
<property name="url" type="string(250)" />
<procedure name="defaultURL" type="string" >
+ <parameter name="artistid" type="string" />
from os import path, environ
opt = session.find ('cddb_options', [], [], ['cddb_basepath'])
default = opt and opt [0].cddb_basepath or environ ['HOME']
@@ -55,10 +56,13 @@
category = 'Unknown'
matchcode = 'unknown'
- artist = self.cddb_artist and self.cddb_artist.cddb_name or 'Various'
- title = self.cddb_title or 'Unknown'
+ artist = session.find ('cddb_artist', {'gnue_id': artistid}, [],
+ ['cddb_firstname', 'cddb_middlename', 'cddb_lastname', 'cddb_name'])
+ name = artist and artist [0].cddb_name or 'Various'
+ name = name.replace (',', '')
+ title = self.cddb_title or 'Unknown'
- reps = {'%a': artist, '%t': title, '%c': category, '%m': matchcode}
+ reps = {'%a': name, '%t': title, '%c': category, '%m': matchcode}
for (item, value) in reps.items ():
if item in pattern:
Added: gnue-cddb/updtags.py
===================================================================
--- gnue-cddb/updtags.py 2004-12-20 20:03:27 UTC (rev 173)
+++ gnue-cddb/updtags.py 2004-12-27 12:57:22 UTC (rev 174)
@@ -0,0 +1,130 @@
+# GNU Enterprise Application Server - Testing unit
+#
+# Copyright 2003-2004 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+#
+
+import os.path
+import ogg
+import ogg.vorbis
+import sys
+
+from gnue.appserver.language import App
+from lib import helper
+
+# -----------------------------------------------------------------------------
+# Return True if a value is listed in the comment dictionary
+# -----------------------------------------------------------------------------
+
+def compare_tag (cdict, tag, value):
+
+ clist = cdict.get (tag)
+ return clist is not None and value in clist
+
+
+# -----------------------------------------------------------------------------
+# Update a vorbis comment in an ogg/vorbis file
+# -----------------------------------------------------------------------------
+
+def update_tag (track, artists, tag, value):
+
+ filename = track.filedb_url
+ genre = track.disc.category.name
+ print "Updating track ", track.title, "...",
+ helper.tag_oggfile (filename, track.disc.title, genre, track.title, artists,
+ track.track)
+ print "Ok"
+
+
+
+
+if __name__ == "__main__":
+ app = App.App ()
+
+ print "requesting new session ..."
+ session = app.newSession ('test', 'test')
+
+ print "Fetching all tracks..."
+ session.setcontext ('cddb')
+
+ count = 0
+ update = 0
+
+ print "Build mapping for artists ..."
+ artists = {}
+ for i in session.find ('artist', [], [], ['cddb_firstname',
+ 'cddb_middlename', 'cddb_lastname', 'cddb_name']):
+ artists [i.gnue_id] = i.cddb_name
+
+ print "Build mapping for track-artists ..."
+ adict = {}
+ for i in session.find ('trackartist', [], ['cddb_track'],
+ ['cddb_track', 'cddb_artist']):
+ if not adict.has_key (i.cddb_track.gnue_id):
+ adict [i.cddb_track.gnue_id] = []
+
+ adict [i.cddb_track.gnue_id].append (artists [i.artist.gnue_id])
+
+ print "Ok"
+
+
+ tracks = session.find ('track', [], ['cddb_disc', 'cddb_track'],
+ ['cddb_title', 'cddb_track', 'filedb_url',
+ 'cddb_disc.cddb_title',
+ 'cddb_disc.cddb_category.cddb_name'])
+
+ for track in tracks:
+ print "Track:", o(track.title)
+ count += 1
+
+ # NOTE: if we don't want a artist-mapping in memory, use the following
+ # find. This will query the artists per track
+
+ #artists = []
+ #for a in session.find ('trackartist', {'cddb_track': track.gnue_id}, [],
+ #['cddb_artist', 'cddb_artist.cddb_firstname',
+ #'cddb_artist.cddb_middlename', 'cddb_artist.cddb_lastname',
+ #'cddb_artist.cddb_name']):
+ #artists.append (a.cddb_artist.cddb_name)
+
+ url = track.filedb_url
+ if url is not None and os.path.exists (url):
+ try:
+ artists = adict [track.gnue_id]
+ oggfile = ogg.vorbis.VorbisFile (track.filedb_url)
+ cdict = oggfile.comment ().as_dict ()
+ data = [('ALBUM', track.disc.title)]
+ data.extend ([('ARTIST', a) for a in artists])
+ data.append (('TITLE', track.title))
+ data.append (('TRACKNUM', "%d" % track.track))
+ data.append (('GENRE', track.disc.category.name))
+
+ for (tag, value) in data:
+ if not compare_tag (cdict, tag, value):
+ update += 1
+ update_tag (track, artists, tag, value)
+
+ break
+
+ except:
+ pass
+
+ print "Read %d tracks, updated %d tags." % (count, update)
Property changes on: gnue-cddb/updtags.py
___________________________________________________________________
Name: svn:keywords
+ Id
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r174 - in gnue-cddb: . schema,
johannes <=