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