{% from "_bypass.html" import render_bypass %}
{% set row_id = ep.guid|episode_dom_id('row') %}
{% set details_id = ep.guid|episode_dom_id('details') %}
{{ ep.episode_number if ep.episode_number is not none else '—' }}
{{ ep.title }}
{% if ep.meta.draft %}{% include "icon_square.svg" %} DRAFT{% endif %}
{{ ep.guid }}
{{ ep.pub_date.strftime('%Y-%m-%d %H:%M') }}
{% if ep.audio.duration_seconds %}
{% set total = ep.audio.duration_seconds|int %}
{% set h = total // 3600 %}{% set m = (total % 3600) // 60 %}{% set s = total % 60 %}
{% if h %}{{ '%d:%02d:%02d'|format(h, m, s) }}{% else %}{{ '%d:%02d'|format(m, s) }}{% endif %}
{% else %}
—
{% endif %}
{%- set meta_findings = report.get_episode_findings(ep.guid, 'meta') -%}
{%- set image_findings = report.get_episode_findings(ep.guid, 'image') -%}
{%- set audio_findings = report.get_episode_findings(ep.guid, 'audio') -%}
{%- set has_errors = meta_findings or image_findings or audio_findings -%}
{%- if not has_errors -%}
OK
{% include "icon_circle.svg" %}
{%- else -%}
{%- macro render_badge(findings, icon_svg, a11y_text) -%}
{%- if findings -%}
{%- set has_fail = findings|selectattr('level', 'equalto', level_fail)|list -%}
{%- set codes = findings|map(attribute='code')|unique|join(', ') -%}
{%- if has_fail -%}
{{ a11y_text }}: {{ codes }}
{{ icon_svg|safe }}
{%- else -%}
{{ a11y_text }}: {{ codes }}
{{ icon_svg|safe }}
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
{% set icon_audio %}{% include "icon_audio.svg" %}{% endset %}
{% set icon_image %}{% include "icon_image.svg" %}{% endset %}
{% set icon_meta %}{% include "icon_meta.svg" %}{% endset %}
{{ render_badge(audio_findings, icon_audio, 'Audio issues') }}
{{ render_badge(image_findings, icon_image, 'Image issues') }}
{{ render_badge(meta_findings, icon_meta, 'Metadata issues') }}
{%- endif -%}
{%- set has_audio_fail = audio_findings | selectattr("level", "equalto", level_fail) | list | length > 0 -%}
{%- set _show_audio_bypass = show_audio_bypass if show_audio_bypass is defined else false -%}
{%- set _show_image_bypass = show_image_bypass if show_image_bypass is defined else false -%}
{% set all_findings = meta_findings + image_findings + audio_findings %}
{% if all_findings %}