Revert "Use audio icon when spectrogram fails. Add note to doc:media-types."
authorBen Sturmfels <ben@sturm.com.au>
Tue, 28 Apr 2020 05:28:59 +0000 (15:28 +1000)
committerBen Sturmfels <ben@sturm.com.au>
Tue, 28 Apr 2020 08:23:24 +0000 (18:23 +1000)
This reverts commit 2b487fc16de2fc7c961f8df725c5ece0e5f56e3a.

mediagoblin/media_types/audio/processing.py

index 19254aa85ef3d36b66b52078030216f0d74e6e66..427309de5f212cdf9d34789c68b0ea6db4e01363 100644 (file)
@@ -148,34 +148,22 @@ class CommonAudioProcessor(MediaProcessor):
         _log.info('Creating OGG source for spectrogram')
         self.transcoder.transcode(self.process_filename, wav_tmp,
                                   mux_name='oggmux')
-
         spectrogram_tmp = os.path.join(self.workbench.dir,
                                        self.name_builder.fill(
                                            '{basename}-spectrogram.jpg'))
-
-        try:
-            self.thumbnailer.spectrogram(
-                wav_tmp,
-                spectrogram_tmp,
-                width=max_width,
-                fft_size=fft_size)
-
-            _log.debug('Saving spectrogram...')
-            store_public(self.entry, 'spectrogram', thumbnail,
+        self.thumbnailer.spectrogram(
+            wav_tmp,
+            spectrogram_tmp,
+            width=max_width,
+            fft_size=fft_size)
+
+        _log.debug('Saving spectrogram...')
+        store_public(self.entry, 'spectrogram', spectrogram_tmp,
                      self.name_builder.fill('{basename}.spectrogram.jpg'))
 
-            file_metadata = {'max_width': max_width,
+        file_metadata = {'max_width': max_width,
                          'fft_size': fft_size}
-            self.entry.set_file_metadata('spectrogram', **file_metadata)
-
-        except IndexError:
-            _log.warn(
-              'Your version of Numpy is too new to create the waveform thumbnail (#5457). '
-              "Try\n\t./bin/pip install numpy==1.9.1\n\t./bin/pip install scikits.audiolab==0.10.2")
-
-        except Exception as exc:
-            _log.warn('Failed to create spectrogram: '
-                    + '{0}'.exc)
+        self.entry.set_file_metadata('spectrogram', **file_metadata)
 
     def generate_thumb(self, size=None):
         if not size:
@@ -190,18 +178,13 @@ class CommonAudioProcessor(MediaProcessor):
             '{basename}-thumbnail.jpg'))
 
         # We need the spectrogram to create a thumbnail
-        try:
-            spectrogram = self.entry.media_files.get('spectrogram')
-            if not spectrogram:
-                _log.info('No spectrogram found, we will create one.')
-                self.create_spectrogram()
-                spectrogram = self.entry.media_files['spectrogram']
-
-            spectrogram_filepath = mgg.public_store.get_local_path(spectrogram)
-
-        except:
-            _log.warn('Failed to create spectrogram, using default audio image instead.')
-            spectrogram_filepath = 'mediagoblin/static/images/media_thumbs/audio.png'
+        spectrogram = self.entry.media_files.get('spectrogram')
+        if not spectrogram:
+            _log.info('No spectrogram found, we will create one.')
+            self.create_spectrogram()
+            spectrogram = self.entry.media_files['spectrogram']
+
+        spectrogram_filepath = mgg.public_store.get_local_path(spectrogram)
 
         self.thumbnailer.thumbnail_spectrogram(
             spectrogram_filepath,