Commit | Line | Data |
---|---|---|
b9d29a8a AE |
1 | #! /usr/bin/python |
2 | ||
3 | # Copyright (C) 2023 Andrew Engelbrecht <andrew@fsf.org> | |
4 | # | |
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. | |
9 | # | |
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. | |
14 | # | |
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 | |
18 | ||
19 | # converts a csv with speech / speaker info into HTML formatted links that | |
20 | # point to audio recordings | |
21 | ||
22 | import csv | |
23 | import re | |
24 | ||
25 | licenses = { | |
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" } | |
29 | ||
c4b24549 | 30 | entries = [] |
b9d29a8a AE |
31 | |
32 | with open('lp2023-video-import.csv', newline='') as csvfile: | |
33 | spamreader = csv.reader(csvfile, delimiter=',', quotechar='"') | |
34 | for row in spamreader: | |
066eab3c AE |
35 | |
36 | authors = row[0] | |
37 | description = row[1] | |
38 | license_link = row[2] | |
39 | license_name = licenses[row[2]] | |
40 | audio_file = re.sub("[.]webm$", ".ogg", row[4]) | |
41 | ||
c4b24549 AE |
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))) |
43 | ||
44 | # replacing 'neptune-' with 'z-' affects sort order, placing it last | |
45 | entries = sorted(entries, key=lambda entry: re.sub("neptune-", "z-", entry[0])) | |
b9d29a8a | 46 | |
c4b24549 AE |
47 | print('<ul>') |
48 | for entry in entries: | |
49 | print(entry[1]) | |
b9d29a8a AE |
50 | print('</ul>') |
51 |