[soundconverter] Apply newer post-2.0.3 batch mode fixes from upstream scm.

Michael Schwendt mschwendt at fedoraproject.org
Thu May 10 19:19:20 UTC 2012


commit 580b1ca2c48270048f6f06b515221c40cac2df96
Author: Michael Schwendt <mschwendt at fedoraproject.org>
Date:   Thu May 10 21:19:14 2012 +0200

    Apply newer post-2.0.3 batch mode fixes from upstream scm.
    
      This should also fix WAV batch encoding.

 soundconverter-2.0.3-pre-2.0.4.patch |  340 ++++++++++++++++++++++++++++++++++
 soundconverter.spec                  |   16 ++-
 2 files changed, 355 insertions(+), 1 deletions(-)
---
diff --git a/soundconverter-2.0.3-pre-2.0.4.patch b/soundconverter-2.0.3-pre-2.0.4.patch
new file mode 100644
index 0000000..30f21aa
--- /dev/null
+++ b/soundconverter-2.0.3-pre-2.0.4.patch
@@ -0,0 +1,340 @@
+diff -Nurb --strip-trailing-cr soundconverter-2.0.3/bin/soundconverter.py soundconverter-2.0.4-pre/bin/soundconverter.py
+--- soundconverter-2.0.3/bin/soundconverter.py	2012-02-21 16:58:46.000000000 +0100
++++ soundconverter-2.0.4-pre/bin/soundconverter.py	2012-05-10 19:40:25.000000000 +0200
+@@ -68,8 +68,10 @@
+         gobject.threads_init()
+         import gnomevfs
+     except ImportError:
+-        print '%s needs pygtk and gnome-python >= 2.12!' % NAME
++        print '%s needs pygtk and gnome-python >= 2.24!' % NAME
+         sys.exit(1)
++    except:
++        pass
+ 
+     try:
+         import pygst
+@@ -83,7 +85,18 @@
+             '.'.join([str(s) for s in gst.gst_version]))
+ 
+ 
+-
++def check_mime_type(mime):
++    types = {'vorbis': 'audio/x-vorbis', 'flac': 'audio/x-flac', 'wav' : 'audio/x-wav',
++        'mp3': 'audio/mpeg', 'aac': 'audio/x-m4a'}
++    mime = types.get(mime, mime)
++    if mime not in types.values():
++        print 'Cannot use "%s" mime type.' % mime
++        print 'Supported shortcuts and mime types:',
++        for k,v in sorted(types.iteritems()):
++            print '%s %s' % (k,v),
++        print
++        raise SystemExit
++    return mime
+ 
+ 
+ def mode_callback(option, opt, value, parser, **kwargs):
+@@ -102,8 +115,7 @@
+         help=_('Show tags for input files instead of converting '
+             'them. This indicates \n command line batch mode '
+             'and disables the graphical user interface.'))
+-    parser.add_option('-m', '--mime-type', action="store_true",
+-        dest="batch_mime",
++    parser.add_option('-m', '--mime-type', dest="cli-output-type",
+         help=_('Set the output MIME type for batch mode. The default '
+             'is %s. Note that you probably want to set the output '
+             'suffix as well.') % settings['cli-output-type'])
+@@ -111,7 +123,7 @@
+         help=_("Be quiet. Don't write normal output, only errors."))
+     parser.add_option('-d', '--debug', action="store_true", dest="debug",
+         help=_('Displays additional debug information'))
+-    parser.add_option('-s', '--suffix', dest="new_suffix",
++    parser.add_option('-s', '--suffix', dest="cli-output-suffix",
+         help=_('Set the output filename suffix for batch mode.'
+             'The default is %s . Note that the suffix does not '
+             'affect\n the output MIME type.') % settings['cli-output-suffix'])
+@@ -123,7 +135,6 @@
+ 
+ 
+ _add_soundconverter_path()
+-_check_libs()
+ 
+ import soundconverter
+ soundconverter.NAME = NAME
+@@ -145,14 +156,31 @@
+         continue
+     settings[k] = getattr(options, k)
+ 
++settings['cli-output-type'] = check_mime_type(settings['cli-output-type'])
++
++_check_libs()
++
+ print '  using %d thread(s)' % settings['jobs']
+ 
+-from soundconverter.ui import gui_main
++from soundconverter.batch import cli_convert_main
++from soundconverter.batch import cli_tags_main
+ from soundconverter.fileoperations import filename_to_uri
+-
+ files = map(filename_to_uri, files)
+-gui_main(NAME, VERSION, GLADEFILE, files)
+ 
++try:
++    from soundconverter.ui import gui_main
++except:
++    if settings['mode'] == 'gui':
++        settings['mode'] = 'batch'
++    
++if settings['mode'] == 'gui':
++    gui_main(NAME, VERSION, GLADEFILE, files)
++elif settings['mode'] == 'tags':
++    if not files: print 'nothing to do...'
++    cli_tags_main(files)
++else:
++    if not files: print 'nothing to do...'
++    cli_convert_main(files)
+ 
+ 
+ 
+diff -Nurb --strip-trailing-cr soundconverter-2.0.3/soundconverter/batch.py soundconverter-2.0.4-pre/soundconverter/batch.py
+--- soundconverter-2.0.3/soundconverter/batch.py	1970-01-01 01:00:00.000000000 +0100
++++ soundconverter-2.0.4-pre/soundconverter/batch.py	2012-04-27 11:40:03.000000000 +0200
+@@ -0,0 +1,130 @@
++#!/usr/bin/python
++# -*- coding: utf-8 -*-
++#
++# SoundConverter - GNOME application for converting between audio formats.
++# Copyright 2004 Lars Wirzenius
++# Copyright 2005-2012 Gautier Portet
++#
++# This program 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; version 3 of the License.
++#
++# This program 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 this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
++# USA
++
++
++from soundfile import SoundFile
++import error
++from soundconverter.settings import settings
++from gstreamer import TagReader
++import gobject
++import time
++from namegenerator import TargetNameGenerator
++from queue import TaskQueue
++from gstreamer import Converter
++import sys
++
++def cli_tags_main(input_files):
++    error.set_error_handler(error.ErrorPrinter())
++    loop = gobject.MainLoop()
++    gobject.threads_init()
++    context = loop.get_context()
++    for input_file in input_files:
++        input_file = SoundFile(input_file)
++        if not settings['quiet']:
++            print input_file.filename
++        t = TagReader(input_file)
++        t.start()
++        while t.running:
++            time.sleep(0.01)
++            context.iteration(True)
++            
++        if not settings['quiet']:
++            for key in sorted(input_file.tags):
++                print '     %s: %s' % (key, input_file.tags[key])
++
++
++class CliProgress:
++
++    def __init__(self):
++        self.current_text = ''
++
++    def show(self, new_text):
++        if new_text != self.current_text:
++            self.clear()
++            sys.stdout.write(new_text)
++            sys.stdout.flush()
++            self.current_text = new_text
++
++    def clear(self):
++        sys.stdout.write('\b \b' * len(self.current_text))
++        sys.stdout.flush()
++
++
++def cli_convert_main(input_files):
++    loop = gobject.MainLoop()
++    gobject.threads_init()
++    context = loop.get_context()
++    error.set_error_handler(error.ErrorPrinter())
++
++    output_type = settings['cli-output-type']
++    output_suffix = settings['cli-output-suffix']
++
++    generator = TargetNameGenerator()
++    generator.suffix = output_suffix
++
++    progress = CliProgress()
++
++    queue = TaskQueue()
++    for input_file in input_files:
++        input_file = SoundFile(input_file)
++        output_name = generator.get_target_name(input_file)
++        c = Converter(input_file, output_name, output_type)
++        c.overwrite = True
++        c.init()
++        c.start()
++        while c.running:
++            if c.get_duration():
++                percent = min(100, 100.0* (c.get_position() / c.get_duration()))
++                percent = '%.1f %%' % percent
++            else:
++                percent = '/-\|' [int(time.time()) % 4]
++            progress.show('%s: %s' % (c.sound_file.filename[-65:], percent ))
++            time.sleep(0.01)
++            context.iteration(True)
++        print
++
++    previous_filename = None
++    
++    '''
++    queue.start()
++    
++    #running, progress = queue.get_progress(perfile)
++    while queue.running:
++        t = None #queue.get_current_task()
++        if t and not settings['quiet']:
++            if previous_filename != t.sound_file.get_filename_for_display():
++                if previous_filename:
++                    print _('%s: OK') % previous_filename
++                previous_filename = t.sound_file.get_filename_for_display()
++
++            percent = 0
++            if t.get_duration():
++                percent = '%.1f %%' % ( 100.0* (t.get_position() / t.get_duration() ))
++            else:
++                percent = '/-\|' [int(time.time()) % 4]
++            progress.show('%s: %s' % (t.sound_file.get_filename_for_display()[-65:], percent ))
++        time.sleep(0.10)
++        context.iteration(True)
++    '''
++    if not settings['quiet']:
++        progress.clear()
++
++
+diff -Nurb --strip-trailing-cr soundconverter-2.0.3/soundconverter/gstreamer.py soundconverter-2.0.4-pre/soundconverter/gstreamer.py
+--- soundconverter-2.0.3/soundconverter/gstreamer.py	2012-04-19 14:11:06.000000000 +0200
++++ soundconverter-2.0.4-pre/soundconverter/gstreamer.py	2012-05-10 19:40:25.000000000 +0200
+@@ -27,7 +27,6 @@
+ import gobject
+ import gst
+ import gnomevfs
+-import gtk # TODO
+ import gconf
+ 
+ from fileoperations import vfs_encode_filename, file_encode_filename
+@@ -40,7 +39,12 @@
+ from settings import mime_whitelist, filename_blacklist
+ from error import SoundConverterException
+ from error import show_error
+-from notify import notification
++try:
++    from notify import notification
++except:
++    def notification(msg):
++        pass
++        
+ from fnmatch import fnmatch
+ 
+ import gconf
+@@ -182,12 +186,7 @@
+             return
+         self.done()
+         if result == gst.pbutils.INSTALL_PLUGINS_USER_ABORT:
+-            dialog = gtk.MessageDialog(parent=None, flags=gtk.DIALOG_MODAL,
+-                type=gtk.MESSAGE_INFO,
+-                buttons=gtk.BUTTONS_OK,
+-                message_format='Plugin installation aborted.')
+-            dialog.run()
+-            dialog.hide()
++            show_error(_('Plugin installation aborted.'))
+             return
+ 
+         show_error('Error', 'failed to install plugins: %s' % gobject.markup_escape_text(str(result)))
+@@ -473,11 +472,13 @@
+ 
+         self.output_filename = output_filename
+         self.output_type = output_type
+-        self.vorbis_quality = None
+-        self.aac_quality = None
+-        self.mp3_bitrate = None
+-        self.mp3_mode = None
+-        self.mp3_quality = None
++        self.vorbis_quality = 0.6
++        self.aac_quality = 192
++        self.mp3_bitrate = 192
++        self.mp3_mode = 'vbr'
++        self.mp3_quality = 3
++        self.flac_compression = 8
++        self.wav_sample_width = 16
+ 
+         self.output_resample = output_resample
+         self.resample_rate = resample_rate
+@@ -515,13 +516,8 @@
+         if not encoder:
+             # TODO: is this used ?
+             # TODO: add proper error management when an encoder cannot be created
+-            dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
+-                        gtk.MESSAGE_ERROR,
+-                        gtk.BUTTONS_OK,
+-                        _("Cannot create a decoder for \'%s\' format.") % \
++            show_error(_("Cannot create a decoder for \'%s\' format.") % 
+                         self.output_type)
+-            dialog.run()
+-            dialog.hide()
+             return
+ 
+         self.add_command(encoder)
+@@ -531,14 +527,7 @@
+         if dirname and not gnomevfs.exists(dirname):
+             log('Creating folder: \'%s\'' % dirname)
+             if not vfs_makedirs(str(dirname)):
+-                # TODO add better error management
+-                dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
+-                            gtk.MESSAGE_ERROR,
+-                            gtk.BUTTONS_OK,
+-                            _("Cannot create \'%s\' folder.") % \
+-                            dirname)
+-                dialog.run()
+-                dialog.hide()
++                show_error(_("Cannot create \'%s\' folder.") % dirname)
+                 return
+ 
+         self.add_command('%s location="%s"' % (
+diff -Nurb --strip-trailing-cr soundconverter-2.0.3/soundconverter/ui.py soundconverter-2.0.4-pre/soundconverter/ui.py
+--- soundconverter-2.0.3/soundconverter/ui.py	2012-04-16 14:07:42.000000000 +0200
++++ soundconverter-2.0.4-pre/soundconverter/ui.py	2012-05-10 19:40:25.000000000 +0200
+@@ -404,7 +404,7 @@
+         'delete-original': 0,
+         'output-resample': 0,
+         'resample-rate': 48000,
+-        'flac-speed': 0,
++        'flac-speed': 0, # TODO used ?
+         'force-mono': 0,
+         'last-used-folder': None,
+         'audio-profile': None,
+@@ -1485,6 +1485,7 @@
+     win = SoundConverterWindow(builder)
+     import error
+     error.set_error_handler(ErrorDialog(builder))
++    
+     #error_dialog = MsgAreaErrorDialog(builder)
+     #error_dialog.msg_area = win.msg_area
+     #error.set_error_handler(error_dialog)
diff --git a/soundconverter.spec b/soundconverter.spec
index b3136c9..df1141a 100644
--- a/soundconverter.spec
+++ b/soundconverter.spec
@@ -2,7 +2,7 @@
 
 Name:           soundconverter
 Version:        2.0.3
-Release:        2%{?dist}
+Release:        4%{?dist}
 Summary:        Simple sound converter application for GNOME
 
 Group:          Applications/Multimedia
@@ -11,6 +11,8 @@ URL:            http://soundconverter.org
 Source0:        http://launchpad.net/soundconverter/trunk/%{tar_ver}/+download/soundconverter-%{tar_ver}.tar.xz
 BuildArch:      noarch
 
+Patch0:         soundconverter-2.0.3-pre-2.0.4.patch
+
 BuildRequires:  desktop-file-utils
 BuildRequires:  intltool gettext
 BuildRequires:  pygtk2
@@ -48,6 +50,7 @@ writes anything the GStreamer library can.
 
 %prep
 %setup -q -n %{name}-%{tar_ver}
+%patch0 -p1 -b .pre-2.0.4
 
 
 %build
@@ -58,6 +61,7 @@ make %{?_smp_mflags}
 
 %install
 make install DESTDIR=${RPM_BUILD_ROOT}
+install -p soundconverter/batch.py ${RPM_BUILD_ROOT}/usr/lib/%{name}/python/soundconverter
 
 %find_lang %{name}
 
@@ -97,6 +101,16 @@ update-desktop-database &> /dev/null ||:
 
 
 %changelog
+* Thu May 10 2012 Michael Schwendt <mschwendt at fedoraproject.org> - 2.0.3-4
+- Apply newer post-2.0.3 batch mode fixes from upstream scm.
+  This should also fix WAV batch encoding.
+
+* Sat May  5 2012 Michael Schwendt <mschwendt at fedoraproject.org> - 2.0.3-3
+- Fix FLAC batch encoding (lp 995862).
+- Fix -m and -s (lp 988262).
+- Apply post-2.0.3 batch mode fixes from upstream scm. This involves
+  copying the new batch.py file manually (temporarily).
+
 * Tue Apr 24 2012 Michael Schwendt <mschwendt at fedoraproject.org> - 2.0.3-2
 - Update to 2.0.3 (stability/progress fixes and updated translations).
 


More information about the scm-commits mailing list