]> git.parisson.com Git - telemeta.git/commitdiff
fix unicodes, fix colors, cleanup, add new player view (contour, white bg), add old...
authoryomguy <yomguy@parisson.com>
Sun, 8 Jul 2012 17:40:29 +0000 (19:40 +0200)
committeryomguy <yomguy@parisson.com>
Sun, 8 Jul 2012 17:40:29 +0000 (19:40 +0200)
telemeta/models/dublincore.py
telemeta/models/media.py
telemeta/models/system.py
telemeta/static/telemeta/css/more.png
telemeta/static/telemeta/css/telemeta.css
telemeta/templates/telemeta/mediaitem_detail.html
telemeta/templates/telemeta/mediaitem_player_contour.html [new file with mode: 0644]
telemeta/urls.py
tools/dev/push.sh
tools/scripts/process-waveform-cgi.py [new file with mode: 0755]

index 67ebde8ae626395e3271a9d989166d47ea00bbea..504121c0b8b4e4abede3dec1d2c428b587a89180 100644 (file)
@@ -65,7 +65,11 @@ class Resource(object):
            [(key, value), ...]"""
         result = []
         for element in self.elements:
-            result.append((element.name, unicode(element.value)))
+            if isinstance(element.value, str):
+                value = element.value.decode('utf8')
+            else:
+                value = element.value
+            result.append((element.name, unicode(value)))
         return result
 
     def add(self, *elements):
index ee0880bb8d6bc1bd949a90b87eeea2fc3ab14c74..f5671d369de0f42c449aa73d24f8c2117fe2066c 100644 (file)
@@ -215,7 +215,8 @@ class MediaCollection(MediaResource):
     conservation_site     = CharField(_('conservation site'))
 
     # Technical data
-    code                  = CharField(_('code'), unique=True, required=True, validators=[is_valid_collection_code])
+    code                  = CharField(_('code'), unique=True, required=True,
+                                      validators=[is_valid_collection_code])
     old_code              = CharField(_('old code'), unique=False, null=True, blank=True)
     approx_duration       = DurationField(_('approximative duration'))
     physical_items_num    = IntegerField(_('number of components (medium / piece)'))
@@ -381,7 +382,7 @@ class MediaItem(MediaResource):
     def public_id(self):
         if self.code:
             return self.code
-        return self.id
+        return str(self.id)
 
     class Meta(MetaCore):
         db_table = 'media_items'
index 51938469f908e8df9367ca533082dbef8dde7a99..c7b3719c4ae7b7538673e5a4cb6fc5a72441ce6c 100644 (file)
@@ -84,7 +84,7 @@ class UserProfile(models.Model):
     user            = ForeignKey(User, unique=True, required=True)
     institution     = CharField(_('Institution'))
     department      = CharField(_('Department'))
-    attachment      = CharField(_('attachment'))
+    attachment      = CharField(_('Attachment'))
     function        = CharField(_('Function'))
     address         = TextField(_('Address'))
     telephone       = CharField(_('Telephone'))
index db83cb87aab29c84b1795ee16dfc97be9b033399..3954eea759bd8bbceef1b25f282345aef1da89c5 100644 (file)
Binary files a/telemeta/static/telemeta/css/more.png and b/telemeta/static/telemeta/css/more.png differ
index d1a4dae986b919fc322a13dbe4190ab6e3fbb6a1..9c07dc31be7f9c6797579dbddaaccfc786989b39 100644 (file)
@@ -726,7 +726,7 @@ dl.dublincore dd.caption {
     color: #6a0307 !important;
     text-decoration: none;
     margin: 0;
-    background: #fff url(more.png) no-repeat left top;
+    background: #fff url(/static/telemeta/images/more.png) no-repeat left top;
     background-position: 0 -16px;
     padding-bottom: 2px;
     padding-left: 16px;
index 2a2a96e918661cf55610d155cfdfb2f7d622c1ef..be55192ca7424e49aeae5fe116c2e761252649eb 100644 (file)
         soundManager.preferFlash = true;
 
         //initializing the visualizers to be passed to the player
+        {% block graphers %}
         var visualizers = {};
         {% for v in visualizers %}
             visualizers["{{v.name}}"] = "{% url telemeta-item-visualize item.public_id,v.id,"WIDTH","HEIGHT" %}";
         {% endfor %}
+        {% endblock graphers %}
+
         {% if user.is_superuser %}
              loadPlayer('{% url telemeta-item-analyze-xml item.public_id %}',
               "{% url telemeta-item-export item.public_id,"mp3" %}", undefined, '{{item.id}}', visualizers,
diff --git a/telemeta/templates/telemeta/mediaitem_player_contour.html b/telemeta/templates/telemeta/mediaitem_player_contour.html
new file mode 100644 (file)
index 0000000..aeb3bd8
--- /dev/null
@@ -0,0 +1,54 @@
+{% extends "telemeta/mediaitem_detail.html" %}
+{% load telemeta_utils %}
+{% load i18n %}
+
+{% block stylesheets %}
+{{ block.super }}
+    <style type="text/css">
+        #rightcol {
+            width: {{width}}px;
+            padding: 0px;
+            border: 0px solid #999;
+            background-color: transparent;
+        }
+        .ts-skin-lab .ts-player .ts-wave {
+            height: {{height}}px;
+        }
+        .ts-player {
+            margin-top: 0px;
+            border: 0px solid #999;
+            }
+
+    </style>
+{% endblock %}
+
+{% block graphers %}
+        //initializing the visualizers to be passed to the player
+        var visualizers = {};
+        visualizers["{{visualizer_id}}"] = "{% url telemeta-item-visualize item.public_id,visualizer_id,"WIDTH","HEIGHT" %}";
+{% endblock graphers %}
+
+{% block title %}{% endblock %}
+{% block title_buttons %}{% endblock %}
+
+{% block layout %}
+{% block content %}
+<div>
+{% if item.file %}
+    {% if public_access or user.is_staff %}
+    <div id="rightcol" style="float: left; padding-bottom:0;">
+        <div id="player_minimized" class="ts-skin-lab">
+            <div class="wazing"></div>
+            <div id="player" class="ts-player">
+            </div>
+        </div>
+
+    </div>
+    {% endif %}
+{% endif %}
+</div>
+
+{% endblock content%}
+{% endblock layout %}
+
+{% block footer %}{% endblock %}
index 36b3be2cf599e89c3b171f679fb225f1eb246287..1a3f11a414ac279d6c650f7cdfaea62b1238d63a 100644 (file)
@@ -114,6 +114,8 @@ urlpatterns = patterns('',
         dict(template='telemeta/mediaitem_player.html'), name="telemeta-item-player"),
     url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/player/(?P<width>[0-9]+)x(?P<height>[0-9]+)/simple/$', item_view.item_detail,
         dict(template='telemeta/mediaitem_player_simple.html'), name="telemeta-item-player-simple"),
+    url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/player/(?P<width>[0-9]+)x(?P<height>[0-9]+)/countour/$', item_view.item_detail,
+        dict(template='telemeta/mediaitem_player_contour.html'), name="telemeta-item-player-contour"),
     url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/performances/$', item_view.item_performances_edit,
         dict(template='telemeta/mediaitem_performances_edit.html'), name="telemeta-item-performances_edit"),
     url(r'^archives/items/(?P<public_id>[A-Za-z0-9._-]+)/keywords/$', item_view.item_keywords_edit,
index c6bab55ad76fbbfdcba18a381a4644cd6d1d6f3f..6369c231e924bb8b984854d145d71421e29a0a8f 100755 (executable)
@@ -21,10 +21,10 @@ ssh vcs.parisson.com "cd /var/git/telemeta.git; git update-server-info"
 
 #echo "Update jimi.parisson.com:"
 echo "Update angus.parisson.com:"
-ssh angus.parisson.com "cd /home/telemeta/telemeta-master; git pull; \
-                        cd /home/telemeta/telemeta-develop; git pull; \
-                        cd /home/telemeta/demo/; ./manage.py migrate telemeta --delete-ghost-migrations;
-                        cd /home/telemeta/sandbox/; ./manage.py migrate telemeta --delete-ghost-migrations; 
-                        cd /home/telemeta/parisson/; ./manage.py migrate telemeta --delete-ghost-migrations; "
+ssh angus.parisson.com "cd /home/telemeta/telemeta-master; git pull origin master; \
+                        cd /home/telemeta/telemeta-develop; git pull origin dev; \
+                        cd /home/telemeta/demo/; ./manage.py migrate --delete-ghost-migrations;
+                        cd /home/telemeta/sandbox/; ./manage.py migrate --delete-ghost-migrations; 
+                        cd /home/telemeta/parisson/; ./manage.py migrate --delete-ghost-migrations; "
 
 echo "Done !"
diff --git a/tools/scripts/process-waveform-cgi.py b/tools/scripts/process-waveform-cgi.py
new file mode 100755 (executable)
index 0000000..317878b
--- /dev/null
@@ -0,0 +1,222 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2009-2010 Guillaume Pellerin <yomguy@parisson.com>
+
+# This file is part of TimeSide.
+
+# TimeSide 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.
+
+# TimeSide 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 TimeSide.  If not, see <http://www.gnu.org/licenses/>.
+
+# Author: Guillaume Pellerin <yomguy@parisson.com>
+
+# for python2.5
+
+version = '0.5'
+
+
+import os
+import sys
+import time
+import shutil
+import datetime
+import timeside
+
+# soon with python2.6
+#from multiprocessing import Process
+
+from django.core.management import setup_environ
+from django.core.files.base import ContentFile
+import cgi
+fs = cgi.FieldStorage()
+
+
+orig_media_dir = '/mnt/awdiomusic/musicbase'
+project_dir = '/mnt/awdio'
+log_file = project_dir + '/logs/process.log'
+sys.path.append('/home/awdio/apps/telemeta-awdio')
+
+
+class GrapherScheme:
+
+    def __init__(self):
+        self.color = 255
+        self.color_scheme = {
+            'waveform': [ # Four (R,G,B) tuples for three main color channels for the spectral centroid method
+                        (self.color,self.color,self.color)
+#                        (0, 0, 0), (0, 0, 0), (0, 0, 0), (0,0,0)
+                        ],
+            'spectrogram': [
+                        (0, 0, 0), (58/4,68/4,65/4), (80/2,100/2,153/2), (90,180,100), (224,224,44), (255,60,30), (255,255,255)
+                        ]}
+
+        # Grapher id
+        self.id = 'waveform_awdio'
+
+        # Width of the image
+        self.width = 1800
+
+        # Height of the image
+        self.height = 233
+
+        # Background color
+        self.bg_color = None
+
+        # Force computation. By default, the class doesn't overwrite existing image files.
+        self.force = False
+        
+        # Nb of threads
+        # FIXME: memory leak for > 1 !
+        self.threads = 1
+
+      
+class TelemetaPreprocessImport(object):
+
+    def __init__(self, root_dir, dest_dir, log_file):
+       from telemeta.cache import TelemetaCache as Cache
+       from telemeta.util.logger import Logger
+       self.media_item_dir = 'items'
+        self.root_dir = root_dir + 'items'
+        self.dest_dir = dest_dir
+        self.threads = 1
+        self.logger = Logger(log_file)
+        self.counter = 0
+        self.force = 0
+        self.cache = Cache(self.dest_dir)
+
+        self.scheme = GrapherScheme()
+        self.width = self.scheme.width
+        self.height = self.scheme.height
+        self.bg_color = self.scheme.bg_color
+        self.color_scheme = self.scheme.color_scheme
+        self.force = self.scheme.force
+        self.threads = self.scheme.threads
+        self.logger = Logger(log_file)
+        self.counter = 0
+        self.collection_name = 'awdio'
+        self.collection = self.set_collection(self.collection_name)
+        
+        self.analyzers = timeside.core.processors(timeside.api.IAnalyzer)
+        self.grapher = timeside.grapher.WaveformAwdio(width=self.width, 
+                                                         height=self.height, 
+                                                         bg_color=self.bg_color, 
+                                                         color_scheme=self.color_scheme)
+        
+
+    def set_collection(self, collection_name):
+        import telemeta.models
+        collections = telemeta.models.media.MediaCollection.objects.filter(code=collection_name)
+        if not collections:
+            c = telemeta.models.media.MediaCollection(code=collection_name)
+            c.title = collection_name
+            c.save()
+            msg = 'added'
+            self.logger.logger.info(collection_name, msg)
+            collection = c
+        else:
+            collection = collections[0]
+        return collection
+
+    def process(self):
+       import telemeta.models
+       keys = fs.keys()
+       if keys[0] == 'file':
+           filename = fs['file'].value
+           media_orig = orig_media_dir + os.sep + filename
+           media = self.root_dir + os.sep + filename
+           
+           if not os.path.exists(media):
+               shutil.copy(media_orig, media)
+               os.system('chmod 644 ' + media)
+            
+            name, ext = os.path.splitext(filename)
+            size = str(self.width) + '_' + str(self.height)
+            image_name = name + '.' + self.scheme.id + '.' + size + '.png'
+            image = self.dest_dir + os.sep + image_name
+            xml = name + '.xml'
+            
+            if not self.cache.exists(image_name) or not self.cache.exists(xml):
+                mess = 'Processing ' + media
+                self.logger.logger.info(mess)
+           
+               print "Content-type: text/plain\n"
+               print mess
+               decoder  = timeside.decoder.FileDecoder(media)
+               pipe = decoder | self.grapher
+               analyzers = []
+               analyzers_sub = []
+               for analyzer in self.analyzers:
+                   subpipe = analyzer()
+                   analyzers_sub.append(subpipe)
+                   pipe = pipe | subpipe
+               pipe.run()
+               
+               mess = 'Rendering ' + image
+               self.logger.logger.info(mess)
+               self.grapher.render(output=image)
+               
+               mess = 'Frames / Pixel = ' + str(self.grapher.graph.samples_per_pixel)
+               self.logger.logger.info(mess)
+               
+               for analyzer in analyzers_sub:
+                   value = analyzer.result()
+                   if analyzer.id() == 'duration':
+                       value = datetime.timedelta(0,value)
+                   analyzers.append({'name':analyzer.name(),
+                           'id':analyzer.id(),
+                           'unit':analyzer.unit(),
+                           'value':str(value)})
+               
+               self.cache.write_analyzer_xml(analyzers, xml)
+               
+               item = telemeta.models.media.MediaItem.objects.filter(code=name)
+                           
+               if not item:
+                   item = telemeta.models.media.MediaItem(collection=self.collection, code=name)
+                   item.title = name
+                   item.file = self.media_item_dir + os.sep + filename
+                   item.save()
+                   msg = 'added item : ' + filename
+                   self.logger.logger.info(self.collection_name, msg)
+
+               pipe = 0
+               decoder = 0
+               
+               print "OK"
+               
+               #except:
+                   #pipe = 0
+                   #decoder = 0
+                   #mess = 'Could NOT process : ' + media
+                   #self.logger.logger.error(mess)
+                   #print mess
+                   
+           else:
+               mess = "Nothing to do with file : " + media
+               self.logger.logger.info(mess)
+               print "Content-type: text/plain\n"
+               print mess
+       
+       else:
+           print "Content-type: text/plain\n"
+           print "No file given !"
+       
+
+if __name__ == '__main__':
+    sys.path.append(project_dir)
+    import settings
+    setup_environ(settings)
+    media_dir = settings.MEDIA_ROOT
+    data_dir = settings.TELEMETA_DATA_CACHE_DIR
+    t = TelemetaPreprocessImport(media_dir, data_dir, log_file)
+    t.process()