* Martin Michlmayr <[EMAIL PROTECTED]> [2005-11-10 11:58]:
> The solution I thought of is the following: in jack, define rippers
> & co with only the basics and then add a new variable through which
> you can define options.  jack could then define its options but
> users could easily override them.

Here's a proof-of-concept implemention of this.  This basically allows
you to stick something like

helper_option['oggenc']:--foo
helper_option['foobar']:--bar

in your .jack3rc file.

Any comments?



Comments regarding the patch:
 - the man page needs to be updated
 - not sure if the Dict stuff should be handled in a more generic way

diff -urN ../jack-3.1.1~/jack_checkopts.py ../jack-3.1.1/jack_checkopts.py
--- ../jack-3.1.1~/jack_checkopts.py    2005-11-10 11:36:23.000000000 +0000
+++ ../jack-3.1.1/jack_checkopts.py     2005-11-11 17:08:32.000000000 +0000
@@ -150,7 +150,7 @@
         signal.signal(signal.SIGTTOU, signal.SIG_IGN)
 
     # load plugins, compile stuff
-    jack_helpers.init()
+    jack_helpers.init(cf)
 
     if not jack_helpers.helpers.has_key(cf['_encoder']) or 
jack_helpers.helpers[cf['_encoder']]['type'] != "encoder":
         dummy = []
diff -urN ../jack-3.1.1~/jack_config.py ../jack-3.1.1/jack_config.py
--- ../jack-3.1.1~/jack_config.py       2005-11-10 11:36:23.000000000 +0000
+++ ../jack-3.1.1/jack_config.py        2005-11-11 17:09:29.000000000 +0000
@@ -768,6 +768,11 @@
         'usage': "use the freedb PLAYORDER field to limit the tracks to rip 
(non-functional, sorry)",
         'long': 'AUTO',
         },
+    # tbm
+    'helper_option': {
+        'type': types.StringType,
+        'val': {},
+        },
     })
 
 for i in cf.keys():
diff -urN ../jack-3.1.1~/jack_helpers.py ../jack-3.1.1/jack_helpers.py
--- ../jack-3.1.1~/jack_helpers.py      2005-11-11 17:26:52.000000000 +0000
+++ ../jack-3.1.1/jack_helpers.py       2005-11-11 17:26:43.000000000 +0000
@@ -35,8 +35,9 @@
         'type': "encoder",
         'target': "ogg",
         'can_tag': 1,
-        'cmd': "oggenc -o %o -t %t -a %a -N %n -l %l -G %g -d %y -b %r %i",
-        'vbr-cmd': "oggenc -o %o -t %t -a %a -N %n -l %l -G %g -d %y -q %q %i",
+        'cmd': "oggenc -o %o $OPTIONS -b %r %i",
+        'vbr-cmd': "oggenc -o %o $OPTIONS -q %q %i",
+        'options': "-t %t -a %a -N %n -l %l -G %g -d %y",
         'tags': {
             'ogg': {
                 'track': "-t %s",
@@ -71,8 +72,8 @@
     'mp3enc': {
         'type': "encoder",
         'target': "mp3",
-        'cmd': "mp3enc -v -qual 9 -br %r -if %i -of %o",
-        'otf-cmd': "mp3enc -v -qual 9 -br %r -sti -be -of %o",
+        'cmd': "mp3enc $OPTIONS -v -qual 9 -br %r -if %i -of %o",
+        'otf-cmd': "mp3enc $OPTIONS -v -qual 9 -br %r -sti -be -of %o",
         'status_blocksize': 99,
         'bitrate_factor': 1000,
         'status_start': "%",
@@ -91,7 +92,7 @@
     'l3enc': {
         'type': "encoder",
         'target': "mp3",
-        'cmd': "l3enc -hq -br %r %i %o",
+        'cmd': "l3enc $OPTIONS -hq -br %r %i %o",
         'status_blocksize': 99,
         'bitrate_factor': 1000,
         'status_start': "%",
@@ -113,10 +114,11 @@
         'type': "encoder",
         'target': "mp3",
         'inverse-quality': 1,
-        'cmd': "lame --preset cbr %r --strictly-enforce-ISO %i %o",
-        'vbr-cmd': "lame --preset standard --vbr-new --nohist 
--strictly-enforce-ISO %i %o",
-        'otf-cmd': "lame --preset cbr %r --strictly-enforce-ISO - %o",
-        'vbr-otf-cmd': "lame --preset standard --vbr-new --nohist 
--strictly-enforce-ISO - %o",
+        'cmd': "lame --preset cbr %r $OPTIONS %i %o",
+        'vbr-cmd': "lame --preset standard --vbr-new --nohist $OPTIONS %i %o",
+        'otf-cmd': "lame --preset cbr %r $OPTIONS - %o",
+        'vbr-otf-cmd': "lame --preset standard --vbr-new --nohist $OPTIONS - 
%o",
+        'options': "--strictly-enforce-ISO",
         'status_blocksize': 160,
         'bitrate_factor': 1,
         'status_start': "%",
@@ -142,10 +144,10 @@
         'type': "encoder",
         'target': "mp3",
         'inverse-quality': 1,
-        'cmd': "gogo %i %o -b %r",
-        'vbr-cmd': "gogo %i %o -v %q",
-        'otf-cmd': "gogo stdin %o -b %r",
-        'vbr-otf-cmd': "gogo stdin %o -v %q",
+        'cmd': "gogo %i %o $OPTIONS -b %r",
+        'vbr-cmd': "gogo %i %o $OPTIONS -v %q",
+        'otf-cmd': "gogo stdin %o $OPTIONS -b %r",
+        'vbr-otf-cmd': "gogo stdin %o $OPTIONS -v %q",
         'status_blocksize': 160,
         'bitrate_factor': 1,
         'status_start': "%",
@@ -167,7 +169,7 @@
     'bladeenc': {
         'type': "encoder",
         'target': "mp3",
-        'cmd': "bladeenc %i %o -br %r",
+        'cmd': "bladeenc %i %o $OPTIONS -br %r",
         'status_blocksize': 180,
         'bitrate_factor': 1000,
         'status_start': "%",
@@ -186,10 +188,10 @@
     'xing': {
         'type': "encoder",
         'target': "mp3",
-        'cmd': "xingmp3enc -B %r %i %o",
-        'vbr-cmd': "xingmp3enc -V 100 %i %o",
-        'otf-cmd': "xingmp3enc -b %r -- %o",
-        'vbr-otf-cmd': "xingmp3enc -V 100 -- %o",
+        'cmd': "xingmp3enc $OPTIONS -B %r %i %o",
+        'vbr-cmd': "xingmp3enc $OPTIONS -V 100 %i %o",
+        'otf-cmd': "xingmp3enc $OPTIONS -b %r -- %o",
+        'vbr-otf-cmd': "xingmp3enc $OPTIONS -V 100 -- %o",
         'status_blocksize': 160,
         'bitrate_factor': 1,
         'status_start': "%",
@@ -210,8 +212,8 @@
     'flac': {
         'type': "encoder",
         'target': "flac",
-        'vbr-cmd': "flac -o %o %i",
-        'vbr-otf-cmd': "flac --channels 2 --bps 16 --sample-rate 44100 
--force-raw-format --endian=big --sign=signed -o %o -",
+        'vbr-cmd': "flac -o %o $OPTIONS %i",
+        'vbr-otf-cmd': "flac --channels 2 --bps 16 --sample-rate 44100 
--force-raw-format --endian=big --sign=signed $OPTIONS -o %o -",
         'status_blocksize': 160,
         'status_start': "%", 
         'percent_fkt': r"""
@@ -234,8 +236,8 @@
         'type': "encoder",
         'target': "mpc",
         'can_tag': 0,
-        'vbr-cmd': "mppenc --standard %i %o",
-        #'vbr-otf-cmd': "mppenc --standard - %o", # doesn't work, needs WAVE
+        'vbr-cmd': "mppenc $OPTIONS --standard %i %o",
+        #'vbr-otf-cmd': "mppenc $OPTIONS --standard - %o", # doesn't work, 
needs WAVE
         'status_blocksize': 160,
         'status_start': "-.-",
         'percent_fkt': r"""
@@ -253,8 +255,9 @@
     'cdparanoia': {
         'filters': [[r'\n', r'\r'], [r'(\r)+', r'\r'], [r'(Done\.\r)+', 
r'Done.\r']],
         'type': "ripper",
-        'cmd': "cdparanoia --abort-on-skip -d %d %n %o",
-        'otf-cmd': "cdparanoia --abort-on-skip -e -d %d %n -R -",
+        'cmd': "cdparanoia $OPTIONS -d %d %n %o",
+        'otf-cmd': "cdparanoia $OPTIONS -e -d %d %n -R -",
+        'options': "--abort-on-skip",
         'status_blocksize': 500,
         'status_start': "%",
         'status_fkt': r"""
@@ -315,7 +318,7 @@
 
     'cdda2wav': {
         'type': "ripper",
-        'cmd': "cdda2wav --no-infofile -H -v 1 -D %d -O wav -t %n %o",
+        'cmd': "cdda2wav --no-infofile -H -v 1 -D %d $OPTIONS -O wav -t %n %o",
         'status_blocksize': 200,
         'status_start': "percent_done:",
         'status_fkt': r"""
@@ -421,7 +424,7 @@
 
     'dagrab': {
         'type': "ripper",
-        'cmd': "dagrab -d %d -f %o %n",
+        'cmd': "dagrab $OPTIONS -d %d -f %o %n",
         'status_blocksize': 100,
         'status_start': "total:",
         'status_fkt': r"""
@@ -462,7 +465,7 @@
 
     'tosha': {
         'type': "ripper",
-        'cmd': "tosha -d %d -f wav -t %n -o %o",
+        'cmd': "tosha $OPTIONS -d %d -f wav -t %n -o %o",
         'status_blocksize': 100,
         'status_start': "total:",
         'status_fkt': r"""
@@ -519,18 +522,26 @@
 }
 
 helpers['lame-user'] = helpers['lame'].copy()
-helpers['lame-user'].update({'cmd': "lame --preset cbr %r 
--strictly-enforce-ISO %i %o",
-        'vbr-cmd': "lame -V %q --vbr-new --nohist --strictly-enforce-ISO %i 
%o",
-        'otf-cmd': "lame --preset cbr %r --strictly-enforce-ISO - %o",
-        'vbr-otf-cmd': "lame -V %q --vbr-new --nohist --strictly-enforce-ISO - 
%o", })
+helpers['lame-user'].update({'cmd': "lame --preset cbr %r $OPTIONS %i %o",
+        'vbr-cmd': "lame -V %q --vbr-new --nohist $OPTIONS %i %o",
+        'otf-cmd': "lame --preset cbr %r $OPTIONS - %o",
+        'vbr-otf-cmd': "lame -V %q --vbr-new --nohist $OPTIONS - %o", })
 
-def init():
+def init(cf):
     # import plugin
     jack_plugins.import_helpers()
 
     # compile exec strings
     for h in helpers.keys():
         for i in helpers[h].keys():
+            if i.endswith("cmd"):
+                if cf.has_key('helper_option') and 
cf['helper_option']['val'].has_key(h):
+                    options = cf['helper_option']['val'][h]
+                else:
+                    options = helpers[h].get("options", "")
+                helpers[h][i] = helpers[h][i].replace("$OPTIONS", options)
             if i[-4:] == "_fkt":
                 helpers[h][i] = compile(helpers[h][i], '<string>', 'exec')
 
diff -urN ../jack-3.1.1~/jack_rc.py ../jack-3.1.1/jack_rc.py
--- ../jack-3.1.1~/jack_rc.py   2005-11-11 17:07:15.000000000 +0000
+++ ../jack-3.1.1/jack_rc.py    2005-11-11 17:07:58.000000000 +0000
@@ -93,10 +93,21 @@
     rc_cf = {}
     for i in rc:
         if i[0] != None:
+            x = i[0].split("[", 1)
+            ext = None
+            if len(x) > 1:
+                i[0] = x[0]
+                ext = x[1].strip("] '\"")
             if cf.has_key(i[0]):
                 ret, val = jack_argv.parse_option(cf, i[0:2], 0, i[0], None, 
origin="rcfile")
                 if ret != None:
-                    rc_cf[i[0]] = {'val': val}
+                    if ext:
+                        if rc_cf.has_key(i[0]):
+                            rc_cf[i[0]]['val'][ext] = val
+                        else:
+                            rc_cf[i[0]] = {'val': {ext: val}}
+                    else:
+                        rc_cf[i[0]] = {'val': val}
                 else:
                     warning(file + ":%s: " % i[3] + val)
             else:

-- 
Martin Michlmayr
http://www.cyrius.com/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to