From d78b0060c12a2ed6a34514bb68ac043643023bad Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 7 Jan 2011 16:30:33 +0100 Subject: [PATCH] fix no image buffer after request, return to mp3 view by default --- telemeta/cache.py | 4 +- .../templates/telemeta/mediaitem_detail.html | 211 ------------------ telemeta/web/base.py | 20 +- 3 files changed, 12 insertions(+), 223 deletions(-) diff --git a/telemeta/cache.py b/telemeta/cache.py index b5f2fd9a..19ec76ec 100644 --- a/telemeta/cache.py +++ b/telemeta/cache.py @@ -38,7 +38,6 @@ import os import xml.dom.minidom -#import xml.dom.ext class TelemetaCache(object): @@ -74,7 +73,7 @@ class TelemetaCache(object): def read_stream_bin(self, file): path = self.dir + os.sep + file - chunk_size = 0x1000 + chunk_size = 0xFFF f = open(path, 'r') while True: _chunk = f.read(chunk_size) @@ -116,5 +115,4 @@ class TelemetaCache(object): root.appendChild(node) f = open(path, "w") f.write(xml.dom.minidom.Document.toprettyxml(doc)) -# xml.dom.ext.PrettyPrint() f.close() diff --git a/telemeta/templates/telemeta/mediaitem_detail.html b/telemeta/templates/telemeta/mediaitem_detail.html index c7b3ebdd..b09e6a88 100644 --- a/telemeta/templates/telemeta/mediaitem_detail.html +++ b/telemeta/templates/telemeta/mediaitem_detail.html @@ -1,212 +1 @@ {% extends "telemeta_default/mediaitem_detail.html" %} - -{% load telemeta_utils %} -{% load i18n %} - -{% block content %} - -

Item : {{ item }}

-
- -{% if item.file %} -
- Minimize -
-
-
-
- Maximize -
-
-
-
-
- - -
-
-
-
-
- -
-
- - - -
- -
- - - - - - - {% for analyser in analysers %} - - - - - - {% endfor %} -
PropertyValueUnit
- {{ analyser.name }} - - {{ analyser.value }} - - {{ analyser.unit }} -
-
- -
- - {% if audio_export_enabled %} -
-

{% trans "Download:" %} - {% for format in export_formats %} - {{ format.name }} - {% endfor %}

-
- {% endif %} - -
-{% endif %} - -
- {% block general_info %} -
- {% dl_field item "title" %} - {% dl_field item "alt_title" %} - {% dl_field item "collector" %} -
{% field_label item "collection" %}
-
{{ item.collection }}
- {% if item.recorded_from_date %} -
{% trans "Recording date" %}
-
{{ item.recorded_from_date }} {{ item.recorded_to_date|prepend:" - " }}
- {% endif %} -
- {% endblock general_info %} -
-
- {% block geoethnic_data %} -
-

{% trans "Geographic and cultural informations" %}

-
- {% if item.location %} -
{% trans "Location" %}
-
{{ item.location.fullnames|join:"
" }}
- {% endif %} - {% dl_field item "location_comment" %} - {% dl_field item "cultural_area" %} - {% dl_field item "ethnic_group" %} - {% dl_field item "context_comment" %} - {% dl_field item "keywords" join with ", " %} -
-
- {% endblock geoethnic_data %} -
-
- {% block musical_data %} -
-

{% trans "Musical informations" %}

-
- {% dl_field item "vernacular_style" %} - {% dl_field item "generic_style" %} - {% dl_field item "author" %} -
- {% if item.performances %} -
- - - - - - - - - - - {% for performance in item.performances.all %} - - - - - - - {% endfor %} - -
{% field_label "MediaItemPerformance" "instruments_num" %}{% field_label "MediaItemPerformance" "instrument" %}{% field_label "MediaItemPerformance" "alias" %}{% field_label "MediaItemPerformance" "musicians" %}
{{ performance.instruments_num }}{{ performance.instrument|default:"" }}{{ performance.alias|default:"" }}{{ performance.musicians }}
-
- {% endif %} -
- {% endblock musical_data %} -
-
- {% block general_data %} -
-

{% trans "General informations" %}

-
- {% dl_field item "comment" %} - {% dl_field item "collector_selection" %} -
-
- {% endblock general_data %} -
-
- {% block archive_data %} -
-

{% trans "Archiving data" %}

-
- {% dl_field item "code" %} - {% dl_field item "old_code" %} - {% dl_field item "track" %} - {% dl_field item "creator_reference" %} - {% dl_field item "external_references" %} - {% dl_field item "public_access_label" %} -
-
- {% endblock archive_data %} -
-
- {% block technical_data %} -
-

{% trans "Technical data" %}

-
-
-
{% trans "Media type" %}
{% trans "Audio" %}
- {% dl_field item "approx_duration" %} -
-
-
- {% endblock technical_data %} -
- -
- -{% endblock %} - diff --git a/telemeta/web/base.py b/telemeta/web/base.py index d9599856..9c1257e1 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -161,13 +161,14 @@ class WebView(object): 'id':analyzer.id(), 'unit':analyzer.unit(), 'value':str(value)}) + decoder.release() self.cache.write_analyzer_xml(analyzers, analyze_file) return render(request, template, {'item': item, 'export_formats': formats, 'visualizers': graphers, 'visualizer_id': grapher_id,'analysers': analyzers, #FIXME analysers - 'audio_export_enabled': getattr(settings, 'TELEMETA_DOWNLOAD_ENABLED', False) + 'audio_export_enabled': getattr(settings, 'TELEMETA_DOWNLOAD_ENABLED', True) }) def item_analyze(self): @@ -195,7 +196,7 @@ class WebView(object): pipe = decoder | graph pipe.run() graph.render(self.cache.dir + os.sep + file) - + response = HttpResponse(self.cache.read_stream_bin(file), mimetype = mime_type) return response @@ -233,15 +234,16 @@ class WebView(object): if not self.cache_export.exists(file): # source > encoder > stream media = self.cache_export.dir + os.sep + file - decoder.setup() proc = encoder(media) - proc.setup(decoder.channels(), decoder.samplerate()) - #metadata = dublincore.express_item(item).to_list() - #enc.set_metadata(metadata) - response = HttpResponse(stream_from_processor(decoder, proc), mimetype = mime_type) - else: - response = HttpResponse(self.cache_export.read_stream_bin(file), mimetype = mime_type) +# metadata = dublincore.express_item(item).to_list() +# enc.set_metadata(metadata) + pipe = decoder | proc + pipe.run() +# response = HttpResponse(stream_from_processor(decoder, proc), mimetype = mime_type) +# else: + response = HttpResponse(self.cache_export.read_stream_bin(file), mimetype = mime_type) + decoder.release() response['Content-Disposition'] = 'attachment' return response -- 2.39.5