Merge pull request '[I33] Format episode duration' (#34) from I33_episode-duration into main

Reviewed-on: rho_n/hpr_generator#34
This commit is contained in:
Roan Horning 2022-08-30 02:03:13 +00:00
commit bf60d35ed1
3 changed files with 16 additions and 2 deletions

View File

@ -55,7 +55,7 @@
<!--% latest_episodes.notes %-->
<footer>
<h2>listen now</h2>
<p>Duration: <!--% latest_episodes.duration %--></p>
<p>Duration: <!--% display_episode_duration(latest_episodes.duration) %--></p>
<audio controls preload="none">
<source src="local/hpr<!--% latest_episodes.id %-->.ogg" type="audio/ogg" >
<source src="local/hpr<!--% latest_episodes.id %-->.mp3" type="audio/mpeg" >

View File

@ -5,7 +5,7 @@
<!--% END %-->
<!--% MACRO show_meta(show) BLOCK %-->
<span><label>Released:</label> <!--% show.date %-->.</span> <span><label>Duration:</label> <!--% show.duration %-->.</span> <span><label>Flag:</label> <!--% display_explicit(show.explicit) %-->.</span> <span><!--% show_series(show.series, show.seriesid) %--></span> <br>
<span><label>Released:</label> <!--% show.date %-->.</span> <span><label>Duration:</label> <!--% display_episode_duration(show.duration) %-->.</span> <span><label>Flag:</label> <!--% display_explicit(show.explicit) %-->.</span> <span><!--% show_series(show.series, show.seriesid) %--></span> <br>
<span><label>Tags:</label> <em><!--% show.tags %--></em>.</span>
<!--% END %-->

View File

@ -8,6 +8,20 @@
<!--% ELSE %--><!--% display_when_false %--><!--% END %-->
<!--% END %-->
<!--% MACRO display_episode_duration(duration_sec) BLOCK %-->
<!--% seconds = duration_sec % 60 %-->
<!--% USE format %-->
<!--% minutes_only = format("%d") %-->
<!--% minutes = minutes_only(duration_sec / 60) %-->
<!--% hours_only = format("%d") %-->
<!--% hours = hours_only(minutes / 60) %-->
<!--% IF hours >= 1 %-->
<!--% minutes = minutes - hours * 60 %-->
<!--% END %-->
<!--% display_hours = format("%02d:%02d:%02d") %-->
<!--% display_hours(hours,minutes,seconds) %-->
<!--% END %-->
<!--% MACRO display_explicit(is_explicit) BLOCK %-->
<!--% display_choice(is_explicit, 'Explicit', 'Clean') %-->
<!--% END %-->