]> git.parisson.com Git - telemeta.git/commitdiff
add all graphers to first analyses, set new settings parameter for default size values
authoryomguy <yomguy@parisson.com>
Thu, 19 Apr 2012 14:26:20 +0000 (16:26 +0200)
committeryomguy <yomguy@parisson.com>
Thu, 19 Apr 2012 14:26:20 +0000 (16:26 +0200)
example/sandbox_sqlite/settings.py
telemeta/views/base.py

index 2ff3f4d1fcd4c5af3e1b1649d0c8260df246122b..b338bd6025fc7b13ef281bfda9530be475626453 100644 (file)
@@ -149,8 +149,11 @@ TELEMETA_DOWNLOAD_ENABLED = True
 TELEMETA_STREAMING_FORMATS = ('mp3', 'webm')
 TELEMETA_DOWNLOAD_FORMATS = ('wav', 'mp3', 'webm')
 TELEMETA_PUBLIC_ACCESS_PERIOD = 51
+TELEMETA_DEFAULT_WAVEFORM_SIZES = ['360x130', '640x130']
+
 AUTH_PROFILE_MODULE = 'telemeta.userprofile'
 SESSION_EXPIRE_AT_BROWSER_CLOSE = False
 
 EMAIL_HOST = 'localhost'
 DEFAULT_FROM_EMAIL = 'webmaster@parisson.com'
+
index f43be2a696b6b2afa94a7a6906a94e36f1b5c18b..59cb9456a8f7841b8fcf527c2b4365d3045c4cb9 100644 (file)
@@ -630,7 +630,10 @@ class ItemView(object):
         if request.REQUEST.has_key('grapher_id'):
             grapher_id = request.REQUEST['grapher_id']
         else:
-            grapher_id = 'waveform'
+            try:
+                grapher_id = settings.TELEMETA_DEFAULT_GRAPHER_ID
+            except:
+                grapher_id = 'waveform'
 
         previous, next = self.item_previous_next(item)
         mime_type = self.item_analyze(item)
@@ -681,7 +684,10 @@ class ItemView(object):
         if request.REQUEST.has_key('grapher_id'):
             grapher_id = request.REQUEST['grapher_id']
         else:
-            grapher_id = 'waveform'
+            try:
+                grapher_id = settings.TELEMETA_DEFAULT_GRAPHER_ID
+            except:
+                grapher_id = 'waveform'
 
         previous, next = self.item_previous_next(item)
         mime_type = self.item_analyze(item)
@@ -830,15 +836,40 @@ class ItemView(object):
         else:
             analyzers = []
             analyzers_sub = []
+            graphers_sub = []
+
             if item.file:
                 decoder  = timeside.decoder.FileDecoder(item.file.path)
                 pipe = decoder
+
                 for analyzer in self.analyzers:
                     subpipe = analyzer()
                     analyzers_sub.append(subpipe)
                     pipe = pipe | subpipe
+
+                try:
+                    sizes = settings.TELEMETA_DEFAULT_GRAPHER_SIZES
+                except:
+                    sizes = ['360x130', ]
+
+                for grapher in self.graphers:
+                    for size in sizes:
+                        width = size.split('x')[0]
+                        height = size.split('x')[1]
+                        image_file = '.'.join([item.public_id, grapher.id(), size.replace('x', '_'), 'png'])
+                        path = self.cache_data.dir + os.sep + image_file
+                        graph = grapher(width = int(width), height = int(height))
+                        graphers_sub.append({'graph' : graph, 'path': path})
+                        pipe = pipe | graph
+
                 pipe.run()
 
+                for grapher in graphers_sub:
+                    grapher['graph'].watermark('timeside', opacity=.6, margin=(5,5))
+                    f = open(grapher['path'], 'w')
+                    grapher['graph'].render(grapher['path'])
+                    f.close()
+
                 mime_type = decoder.format()
                 analysis = MediaItemAnalysis(item=item, name='MIME type',
                                              analyzer_id='mime_type', unit='', value=mime_type)