[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r172 - in gnue-cddb: . lib schema
From: |
johannes |
Subject: |
r172 - in gnue-cddb: . lib schema |
Date: |
Thu, 16 Dec 2004 10:21:24 -0600 (CST) |
Author: johannes
Date: 2004-12-16 10:21:23 -0600 (Thu, 16 Dec 2004)
New Revision: 172
Added:
gnue-cddb/artist.gfd
Modified:
gnue-cddb/cddb.gpd
gnue-cddb/disc.gfd
gnue-cddb/dlgArtist.gfd
gnue-cddb/lib/helper.py
gnue-cddb/schema/cddb-C.gld
gnue-cddb/schema/cddb.gcd
Log:
Lot's of improvements ...
Added: gnue-cddb/artist.gfd
===================================================================
--- gnue-cddb/artist.gfd 2004-12-10 12:31:17 UTC (rev 171)
+++ gnue-cddb/artist.gfd 2004-12-16 16:21:23 UTC (rev 172)
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="iso8859-1"?>
+
+<!-- Artist Selection / Modification
+
+ Copyright 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 of
+ the License, 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 GNU Enterprise; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ $Id: $ -->
+
+<form title="Artists" style="form">
+ <options>
+ </options>
+
+ <!-- =================================================================== -->
+ <!-- Datasources -->
+ <!-- =================================================================== -->
+
+ <datasource connection="appserver" name="dtsArtist" table="cddb_artist"
+
explicitfields="cddb_lastname,cddb_middlename,cddb_firstname,cddb_matchcode"
+ order_by="cddb_name" cache="250" />
+
+ <datasource connection="appserver" name="dtsOptions" table="cddb_options"
+ prequery="True" />
+
+
+ <!-- =================================================================== -->
+ <!-- Blocks -->
+ <!-- =================================================================== -->
+
+ <logic>
+
+ <block name="blkInput">
+ <field name="search" />
+ </block>
+
+ <block name="blkArtist" datasource="dtsArtist">
+ <field name="first" field="cddb_firstname" maxLength="30" />
+ <field name="middle" field="cddb_middlename" maxLength="30" />
+ <field name="last" field="cddb_lastname" maxLength="30" />
+ <field name="full" field="cddb_name" maxLength="100" />
+ </block>
+
+ <block name="blkOptions" datasource="dtsOptions" />
+ </logic>
+
+
+ <!-- =================================================================== -->
+ <!-- Layout (Main Form) -->
+ <!-- =================================================================== -->
+
+ <layout xmlns:c="GNUe:Layout:Char" c:height="7" c:width="80" tabbed="none">
+
+ <page name="pgArtist" caption="Artist">
+
+ <label c:x="1" c:y="1" c:width="12" text="First name:" />
+ <label c:x="1" c:y="2" c:width="12" text="Middle Name:" />
+ <label c:x="1" c:y="3" c:width="12" text="Last Name:" />
+ <label c:x="1" c:y="4" c:width="12" text="Full Name:" />
+ <label c:x="1" c:y="5" c:width="12" text="Search :" />
+
+ <entry c:x="13" c:y="1" c:width="40" block="blkArtist" field="first" />
+
+ <entry c:x="13" c:y="2" c:width="40" block="blkArtist" field="middle" />
+ <entry c:x="13" c:y="3" c:width="40" block="blkArtist" field="last" />
+
+ <entry c:x="13" c:y="4" c:width="60" block="blkArtist" field="full"
+ style="label" />
+
+ <entry c:x="13" c:y="5" c:width="50" block="blkInput" field="search"
+ focusorder="1" />
+
+ <!-- ================================================================ -->
+ <!-- Button Row (Actions) -->
+ <!-- ================================================================ -->
+
+ <button c:x="65" c:y="5" c:width="10" label="Search" focusorder="2" >
+ <trigger name="btnSearch" type="ON-ACTION">
+ dtsOptions.createResultSet ()
+ blkOptions.firstRecord ()
+
+ name = blkInput.search.get ()
+ blkInput.clear ()
+
+ res = blkOptions.call ('cddb_findArtist', {'name': name})
+ dtsArtist.createResultSet ({'gnue_id': res})
+ blkArtist.firstRecord ()
+
+ setFocus (blkArtist.first)
+ </trigger>
+ </button>
+
+ </page>
+
+ </layout>
+</form>
+
Modified: gnue-cddb/cddb.gpd
===================================================================
--- gnue-cddb/cddb.gpd 2004-12-10 12:31:17 UTC (rev 171)
+++ gnue-cddb/cddb.gpd 2004-12-16 16:21:23 UTC (rev 172)
@@ -22,8 +22,7 @@
</description>
</step>
- <step type="form" location="appserver://appserver/form/cddb_artist"
- title="Artists" >
+ <step type="form" location="./artist.gfd" title="Artists" >
<description><![CDATA[
<html><head></head><body>
<h1>Artists</h1>
Modified: gnue-cddb/disc.gfd
===================================================================
--- gnue-cddb/disc.gfd 2004-12-10 12:31:17 UTC (rev 171)
+++ gnue-cddb/disc.gfd 2004-12-16 16:21:23 UTC (rev 172)
@@ -33,7 +33,8 @@
<!-- =================================================================== -->
<datasource connection="appserver" name="dtsDArtist" table="cddb_artist"
- order_by="cddb_name" prequery="True" cache="250" />
+ order_by="cddb_name" prequery="True" cache="250"
+
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" />
@@ -49,6 +50,9 @@
master="dtsDisc" masterlink="gnue_id" detaillink="cddb_disc"
order_by="cddb_track" />
+ <datasource connection="appserver" name="dtsSrcArtist" table="cddb_artist"
+
explicitfields="cddb_lastname,cddb_middlename,cddb_firstname,cddb_matchcode"
+ prequery="False" cache="250" />
<!-- =================================================================== -->
<!-- Blocks -->
@@ -72,10 +76,12 @@
<field name="comment" field="cddb_comment" maxLength="70" />
<field name="url" field="filedb_url" readonly="True" />
<field name="length" field="cddb_length" typecast="date" />
+
+ <field name="gid" field="gnue_id" readonly="True" />
</block>
- <block name="blkTrack" datasource="dtsTrack" rows="15" >
+ <block name="blkTrack" datasource="dtsTrack" rows="13" >
<field name="track" field="cddb_track" maxLength="2"
typecast="number" />
@@ -94,9 +100,16 @@
</block>
<block name="blkOptions" datasource="dtsOptions">
- <field name="basepath" field="cddb_basepath" readonly="True" />
+ <field name="basepath" field="cddb_basepath" readonly="True" />
+ <field name="quality" field="cddb_encquality" readonly="True" />
+ <field name="unknown" field="cddb_unknown" readonly="True" />
</block>
+ <block name="blkSrcArtist" datasource="dtsSrcArtist">
+ <field name="id" field="gnue_id" />
+ <field name="matchcode" field="cddb_matchcode" />
+ </block>
+
</logic>
@@ -104,7 +117,7 @@
<!-- Layout (Main Form) -->
<!-- =================================================================== -->
- <layout xmlns:c="GNUe:Layout:Char" c:height="23" c:width="100" tabbed="none">
+ <layout xmlns:c="GNUe:Layout:Char" c:height="21" c:width="100" tabbed="none">
<page name="pgDisc" caption="Disc">
@@ -130,16 +143,14 @@
<button c:x="42" c:y="2" c:width="3" label="..." navigable="False">
<trigger type="ON-ACTION">
- setParameter ('triggerArg', 'disc')
- activateTrigger ('selectArtist')
+ blkDisc.url.set (blkDisc.call ('filedb_defaultURL', None))
</trigger>
</button>
<entry c:x="11" c:y="3" c:width="30" block="blkDisc" field="category"
style="dropdown" />
- <entry c:x="60" c:y="1" c:width="10" block="blkDisc" field="discid"
- style="label" />
+ <entry c:x="60" c:y="1" c:width="10" block="blkDisc" field="discid" />
<entry c:x="60" c:y="2" c:width="10" block="blkDisc" field="year" />
<entry c:x="60" c:y="3" c:width="39" block="blkDisc" field="url" />
@@ -168,7 +179,13 @@
<trigger type="ON-ACTION" src="tag_files" />
</button>
- <button c:x="51" c:y="5" c:width="8" label="Import" />
+ <button c:x="51" c:y="5" c:width="8" label="Import" >
+ <trigger type="ON-ACTION" >
+ print "gonna ask now ..."
+ res = blkOptions.call ('cddb_findArtist', {'name': 'foobar'})
+ print "Res=", repr (res)
+ </trigger>
+ </button>
<button c:x="60" c:y="5" c:width="12" label="Toggle all" >
<trigger type="ON-ACTION" src="toggle_action" />
@@ -209,34 +226,6 @@
<!-- ################################################################### -->
<!-- ===================================================================
- Select and/or modify an artist
-
- @param triggerArg: 'disc' or 'track'; specifies which block to set an
- artist for if the dialog is closed with Ok.
- =================================================================== -->
- <trigger name="selectArtist" type="NAMED">
- arg = getParameter ('triggerArg')
- if ';' in arg:
- (type, default) = arg.split (';')
- else:
- (type, default) = (arg, None)
-
- block = type == 'disc' and blkDisc or blkTrack
- params = {'cancel': True, 'artist': default or block.artist.get ()}
-
- runForm ('dlgArtist.gfd', params)
-
- blkDisc.artist.resetForeignKey ()
- blkTrack.artist.resetForeignKey ()
-
- if not params.get ('cancel'):
- block.artist.set (params.get ('artist'))
-
- setParameter ('triggerArg', params)
- </trigger>
-
-
- <!-- ===================================================================
Query a disc
This trigger clears all blocks, reads the disc information from the
@@ -247,8 +236,12 @@
<trigger name="query_cd" type="NAMED">
from lib import helper
- blkDisc.rollback ()
+ # Since the rollback also destroys the currently loaded record in options,
+ # we have to reload the options afterwards
+ form.rollback ()
+ dtsOptions.createResultSet ()
+ setStatusText ("Fetching disc information ...")
discInfo = helper.getDiscInfo ()
<!-- First have a look if the disc is already listed in backend-db. The
@@ -258,20 +251,25 @@
dtsDisc.createResultSet ({'cddb_discid': idstr, 'cddb_seconds': length})
if blkDisc.discid.get () == idstr and dtsTrack.count () == discInfo [1]:
+ setStatusText ("")
return
<!-- Start off with a new disc. Disc-Id and length in seconds cannot change
through match-selection. -->
if dtsDisc.count () > 1:
blkDisc.rollback ()
+ dtsOptions.createResultSet ()
blkDisc.discid.set (idstr)
blkDisc.seconds.set (discInfo [-1])
+ setStatusText ("Connecting to remote cd database ...")
cddb = helper.openCDDB ()
try:
+ setStatusText ("Query for disc ...")
matches = helper.getMatches (cddb, discInfo)
+ setStatusText ("")
if len (matches):
params = {'cancel': True, 'matches': matches, 'result': None}
@@ -286,27 +284,30 @@
<!-- Split the match title into a disc-title and an artist name and start
the selection / modification of the artist -->
(title, artist) = helper.splitTitle (match ['title'])
- setParameter ('triggerArg', 'disc;%s' % artist)
- activateTrigger ('selectArtist')
- if getParameter ('triggerArg') ['cancel']:
- return
+ artistMap = getParameter ('artistMap')
+ art = helper.findArtist (artist, artistMap, blkOptions.unknown.get ())
blkDisc.title.set (title)
blkDisc.category.set (match ['category'])
+ blkDisc.artist.set (art)
blkDisc.url.set (blkDisc.call ('filedb_defaultURL', None))
<!-- Download the selected match from the remote cd database -->
+ setStatusText ("Downloading selected match ...")
download = helper.download (cddb, discInfo, match ['matchcode'])
blkDisc.year.set (download.get ('year'))
finally:
cddb.close ()
+ setStatusText ("")
<!-- Iterate over all downloaded tracks and create a track-record. Note:
there is no 'empty' track record, because of the former procedure call
on the master record. This led to a post and theirfor removed the
pending, but empty detail record. -->
for (track, title, length) in download ['tracks']:
+ setStatusText ("Adding track %s: %s" % ((track+1), title))
+
blkTrack.newRecord ()
blkTrack.track.set (track + 1)
@@ -315,11 +316,8 @@
artist and start artist selection / modification. -->
if title and '/' in title:
(title, artist) = helper.splitTitle (title)
- setParameter ('triggerArg', 'track;%s' % artist)
- activateTrigger ('selectArtist')
- <!-- If the selection has been canceled we use the disc's artist -->
- if getParameter ('triggerArg') ['cancel']:
- blkTrack.artist.set (blkDisc.artist.get ())
+ art = helper.findArtist (artist, artistMap, blkOptions.unknown.get())
+ blkTrack.artist.set (art)
else:
blkTrack.artist.set (blkDisc.artist.get ())
@@ -333,6 +331,7 @@
blkTrack.firstRecord ()
blkDisc.update ()
+ setStatusText ("")
</trigger>
@@ -373,13 +372,16 @@
FIXME: this message is not displayed by uidriver until this
trigger has finished completely ! -->
print "Extracting %d to %s" % (track, fullpath)
- setStatusText ("Extracting track %d to %s ..." % (track, fullpath))
+ setStatusText ("Extracting track %d ..." % track)
dae.runDAE (track, fullpath)
blkTrack.ripped = mx.DateTime.now ()
blkTrack.url.set (fullpath)
+ setStatusText ("")
blkTrack.nextRecord ()
+
+ showMessage ('Audio extraction complete')
</trigger>
@@ -394,6 +396,8 @@
blkTrack.gotoRecord (tr)
if not blkTrack.isEmpty ():
blkTrack.action.set (not blkTrack.action.get ())
+
+ blkTrack.firstRecord ()
</trigger>
@@ -407,18 +411,27 @@
<trigger name="ogg_encode" type="NAMED">
import lib.helper
+ if blkOptions.isEmpty ():
+ dtsOptions.createResultSet ()
+ blkOptions.firstRecord ()
+
for tr in range (dtsTrack.count ()):
blkTrack.gotoRecord (tr)
if not blkTrack.isEmpty () and blkTrack.action.get ():
print "Encoding track %s to ogg/vorbis ..." % (tr + 1)
- setStatusText ("Encoding track %s to ogg/vorbis ..." % (tr + 1))
+ setStatusText ("Encoding track %s ..." % (tr + 1))
- oggfile = lib.helper.ogg_encode (blkTrack.url.get ())
+ oggfile = lib.helper.ogg_encode (blkTrack.url.get (),
+ blkOptions.quality.get () or 0.5)
if oggfile:
blkTrack.url.set (oggfile)
+ setStatusText ("")
+
activateTrigger ('tag_files')
+
+ showMessage ('Encoding complete')
</trigger>
@@ -432,7 +445,6 @@
<trigger name="tag_files" type="NAMED">
from lib import helper
- blkTrack.firstRecord ()
for i in range (dtsTrack.count ()):
blkTrack.gotoRecord (i)
@@ -447,6 +459,28 @@
tracknum = blkTrack.track.get ()
helper.tag_oggfile (filename, album, category, title, artist, tracknum)
+ setStatusText ("")
</trigger>
+
+ <trigger type="On-Startup">
+ import string
+ from lib import helper
+
+ print "Building artist map ...",
+
+ artistMap = {}
+ dtsSrcArtist.createResultSet ()
+ for ix in range (dtsSrcArtist.count ()):
+ blkSrcArtist.gotoRecord (ix)
+
+ mc = blkSrcArtist.matchcode.get ()
+ codes = map (string.upper, helper.getArtistNames (mc))
+ codes.sort ()
+ artistMap [tuple (codes)] = blkSrcArtist.id.get ()
+
+ setParameter ('artistMap', artistMap)
+
+ print "Ok"
+ </trigger>
</form>
Modified: gnue-cddb/dlgArtist.gfd
===================================================================
--- gnue-cddb/dlgArtist.gfd 2004-12-10 12:31:17 UTC (rev 171)
+++ gnue-cddb/dlgArtist.gfd 2004-12-16 16:21:23 UTC (rev 172)
@@ -40,6 +40,8 @@
explicitfields="cddb_lastname,cddb_middlename,cddb_firstname,cddb_matchcode"
cache="250" />
+ <datasource connection="appserver" name="dtsOptions" table="cddb_options" />
+
<!-- =================================================================== -->
<!-- Blocks -->
<!-- =================================================================== -->
@@ -54,6 +56,7 @@
<field name="gnueid" field="gnue_id" readonly="True" />
</block>
+ <block name="blkOptions" datasource="dtsOptions" />
</logic>
@@ -77,17 +80,8 @@
dtsArtist.simpleQuery ({'gnue_id': res [0]['gnue_id']})
return
- from lib import helper
-
- rs = dtsSearch.createResultSet ()
- if rs.getRecordCount ():
- for name in helper.getArtistNames (preselect):
- rec = rs.findRecord ({'cddb_matchcode': name.upper ()})
- if rec is not None:
- dtsArtist.simpleQuery ({'gnue_id': rec.getField ('gnue_id')})
- return
-
- blkArtist.last.set (preselect)
+ res = blkOptions.call ('cddb_findArtist', {'name': preselect})
+ dtsArtist.createResultSet ({'gnue_id': res})
</trigger>
<!-- =================================================================== -->
Modified: gnue-cddb/lib/helper.py
===================================================================
--- gnue-cddb/lib/helper.py 2004-12-10 12:31:17 UTC (rev 171)
+++ gnue-cddb/lib/helper.py 2004-12-16 16:21:23 UTC (rev 172)
@@ -173,6 +173,18 @@
# -----------------------------------------------------------------------------
+#
+# -----------------------------------------------------------------------------
+
+def findArtist (artist, artistMap, fallback = None):
+
+ names = map (string.upper, getArtistNames (artist))
+ names.sort ()
+
+ return artistMap.get (tuple (names), fallback)
+
+
+# -----------------------------------------------------------------------------
# Download a match from remote db
# -----------------------------------------------------------------------------
Modified: gnue-cddb/schema/cddb-C.gld
===================================================================
--- gnue-cddb/schema/cddb-C.gld 2004-12-10 12:31:17 UTC (rev 171)
+++ gnue-cddb/schema/cddb-C.gld 2004-12-16 16:21:23 UTC (rev 172)
@@ -62,7 +62,9 @@
</class>
<class name="options" label="Options">
- <property name="basepath" pos="300" label="Base path" />
+ <property name="basepath" pos="100" label="Base path" />
+ <property name="encquality" pos="200" label="Encoding quality" />
+ <property name="unknown" pos="300" label="Unknown artist" />
</class>
</module>
Modified: gnue-cddb/schema/cddb.gcd
===================================================================
--- gnue-cddb/schema/cddb.gcd 2004-12-10 12:31:17 UTC (rev 171)
+++ gnue-cddb/schema/cddb.gcd 2004-12-16 16:21:23 UTC (rev 172)
@@ -123,7 +123,55 @@
<!-- ================================================================= -->
<class name="options">
- <property name="basepath" type="string(250)" />
+ <property name="basepath" type="string(250)" />
+ <property name="encquality" type="number(2,1)" />
+ <property name="unknown" type="cddb_artist" />
+
+ <!-- ====================================================================
+ Find an artist by it's name
+ This function tries to find an artist-record by it's matchcode, where
+ all possible permutations of the name are tried.
+
+ @param name: name of the artist. case and order does not matter
+ @return: gnue_id of the artist or None if no such artist exists
+ ================================================================ -->
+ <procedure name="findArtist" type="string(32)">
+ <parameter name="name" type="string(100)" />
+ import string
+ parts = name.upper().split ()
+
+ if len (parts) > 1:
+ # Find the number of permutations (faculty of number of parts)
+ count = 1
+ for index in range (2, len (parts) + 1):
+ count *= index
+
+ # build all permutations
+ names = []
+ for index in range (count):
+ seqc = list (parts [:])
+ seqn = [seqc.pop ()]
+ divider = 2 # divider is meant to be len (seqn) + 1, just a bit
faster
+
+ while seqc:
+ index, new_index = index // divider, index % divider
+ seqn.insert (new_index, seqc.pop ())
+ divider += 1
+
+ names.append (string.join (seqn, ' '))
+ else:
+ names = parts
+
+ # iterate over all possible names and return the first match (if any)
+ for name in names:
+ r = session.find ('cddb_artist', {'cddb_matchcode': name},
+ ['cddb_lastname'],
+ ['cddb_firstname', 'cddb_lastname', 'cddb_middlename'])
+ if r:
+ return r [0].gnue_id
+
+ return self.cddb_unknown.gnue_id
+ </procedure>
</class>
</module>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r172 - in gnue-cddb: . lib schema,
johannes <=