3 # Copyright (C) 2023 Andrew Engelbrecht <andrew@fsf.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # converts a csv with speech / speaker info into HTML formatted links that
20 # point to audio recordings
26 "https://creativecommons.org/licenses/by/4.0/": "CC BY 4.0",
27 "https://creativecommons.org/licenses/by-sa/4.0/": "CC BY-SA 4.0",
28 "https://www.gnu.org/licenses/fdl-1.3.en.html": "GFDL 1.3" }
32 with
open('lp2023-video-import.csv', newline
='') as csvfile
:
33 spamreader
= csv
.reader(csvfile
, delimiter
=',', quotechar
='"')
34 for row
in spamreader
:
39 license_name
= licenses
[row
[2]]
40 audio_file
= re
.sub("[.]webm$", ".ogg", row
[4])
42 entries
.append((audio_file
, ' <li><a href="GNUAV/lp2023_audio/lp2023-{}">{}: {}</a> (<a href="{}">{}</a>)</li>'.format(audio_file
, authors
, description
, license_link
, license_name
)))
44 # replacing 'neptune-' with 'z-' affects sort order, placing it last
45 entries
= sorted(entries
, key
=lambda entry
: re
.sub("neptune-", "z-", entry
[0]))