Skip to content

Commit

Permalink
Fix: Crash when using jinja2 striptags feature on None value
Browse files Browse the repository at this point in the history
  • Loading branch information
showi committed Dec 24, 2016
1 parent 9bf5741 commit 494408c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 366 deletions.
16 changes: 11 additions & 5 deletions resources/lib/qobuz/extension/kooli/kooli/application.py
Expand Up @@ -17,7 +17,7 @@
from flask import Flask
from flask import request
from flask import Response, redirect
JINJA2_ENVIRONMENT_OPTIONS = {'undefined': Undefined}
#JINJA2_ENVIRONMENT_OPTIONS = {'undefined': Undefined}
from flask import make_response, render_template, request

from qobuz.api import api
Expand All @@ -30,6 +30,7 @@
from qobuz.node import getNode, Flag
from qobuz.gui.directory import Directory
from qobuz import config
from qobuz.util.converter import converter
from kooli import kooli_path

qobuzApp = QobuzApplication(
Expand Down Expand Up @@ -194,10 +195,12 @@ def route_nfo_album(album_id=None, track_id=None):
return http_error(404)
if request.method == 'HEAD':
return '', 200
if 'description' not in response:
response['description'] = ''
elif response['description'] is None:
response['description'] = ''
if 'description' in response:
response['description'] = converter.strip_html(
response['description'], default='')
if 'catchline' in response:
response['catchline'] = converter.strip_html(
response['catchline'], default='')
response['image_default_size'] = qobuzApp.registry.get(
'image_default_size')
if 'duration' in response:
Expand All @@ -215,6 +218,9 @@ def route_nfo_artist(album_id=None):
response = api.get('/artist/get', artist_id=album['artist']['id'])
if response is None:
return http_error(404)
if 'biography' in response:
response['biography']['content'] = converter.strip_html(
response['biography']['content'], default='')
response['image_default_size'] = qobuzApp.registry.get(
'image_default_size')
return render_template('artist.nfo.tpl', **response)
Expand Down
16 changes: 9 additions & 7 deletions resources/lib/qobuz/extension/kooli/kooli/tpl/album.nfo.tpl
@@ -1,7 +1,7 @@

<album>
<title>{{title}}</title>
{% if artist.name %}
{% if artist.name is defined %}
<artist>{{artist.name}}</artist>
{% endif %}
{% for genre in genres_list %}
Expand Down Expand Up @@ -29,18 +29,20 @@
<duration>{{track.duration}}</duration>
</track>
{% endfor %}
<review>{%- if true -%}
<review>
{%- if catchline is defined -%}
{{catchline|striptags}}
{% endif %}
{{catchline}}
{%- endif -%}
{%- if description is defined -%}
{{description|striptags}}
{% endif %}
{{description}}
{%- endif -%}
{% if true %}
Duration : {{(duration / 60)|round}} mn
Tracks : {{tracks_count}}
Media : {{media_count}}
HiRes : {{hires}}
Sales factors (monthly/yearly): {{product_sales_factors_monthly}} / {{product_sales_factors_yearly}}
Copyright: {{copyright}}
{% endif %}</review>
{% endif %}
</review>
</album>
262 changes: 0 additions & 262 deletions resources/lib/qobuz/extension/kooli/kooli/tpl/album.nfo.txt

This file was deleted.

0 comments on commit 494408c

Please sign in to comment.