From 717e85ce0991b49b23296cf5d533789847442d47 Mon Sep 17 00:00:00 2001 From: Quentin Gibeaux Date: Fri, 1 Oct 2021 11:19:08 +0200 Subject: [PATCH] fork feed2lav for root cert expiration handling --- podcasts/scripts/feed2lav-qgull.pl | 147 +++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100755 podcasts/scripts/feed2lav-qgull.pl diff --git a/podcasts/scripts/feed2lav-qgull.pl b/podcasts/scripts/feed2lav-qgull.pl new file mode 100755 index 0000000..d928fc8 --- /dev/null +++ b/podcasts/scripts/feed2lav-qgull.pl @@ -0,0 +1,147 @@ +#! /usr/bin/perl -CAS +# Gérald Sédrati-Dinet +# Frédéric Couchet +# License : WTFPL +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# Version 2, December 2004 +# +# Copyright (C) 2004 Sam Hocevar +# +# Everyone is permitted to copy and distribute verbatim or modified +# copies of this license document, and changing it is allowed as long +# as the name is changed. +# +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +# +# 0. You just DO WHAT THE FUCK YOU WANT TO. + +use 5.014; +use utf8; +use open qw(:std :encoding(UTF-8)); +use LWP::Simple; +use XML::RSS; +use DateTime; +use DateTime::Format::DateParse; +use Net::SSL; + +{ + # Overwrite output of enclosures to have attributes in fixed order + no warnings qw(redefine); + sub XML::RSS::Private::Output::Base::_out_single_item_enclosure { + my ($self, $item, $enc) = @_; + + return + $self->_out( + "_encode($enc->{$_}) . '"' } sort keys(%$enc) + ) . + " />\n" + ); + } +} + +# Configuration variables +my $url = "https://www.april.org/taxonomy_all_items/term/1918/all"; +my $urlfeed = "https://www.april.org/taxonomy_all_items/term/1918/all/feed"; +my $filename = "/usr/share/drupal6/lav.xml"; +my $linkurl = "https://april.org/libre-a-vous"; +my $feedurl = "https://april.org/lav.xml"; + +# build RSS object +my $rss = XML::RSS->new; + +# Fetch Drupal feed +my $ua = LWP::UserAgent->new; +$ua->ssl_opts( verify_hostname => 0); +my $req = HTTP::Request->new(GET => $urlfeed); +my $res = $ua->request($req); + +die "Couldn't get $urlfeed\n!" unless $res->is_success(); + +# Parse RSS +open(my $fh, '>:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; +$rss->parse($res->content); + +# Add description +$rss->{channel}->{description} = "

Chaque mardi de 15 h 30 à 17 h 00, l'April, l'association de promotion et de défense du logiciel libre, propose une émission de radio d'explications et d'échanges concernant les dossiers politiques et juridiques que l'association traite et les actions qu'elle mène : Libre à vous !. Une partie de l'émission est également consacrée aux actualités et actions de type sensibilisation. L'émission est diffusée sur radio Cause Commune sur la bande FM en Île-de-France (93.1) et sur le site web de la radio.

Donner à chacun et chacune, de manière simple et accessible les clefs pour comprendre les enjeux mais aussi proposer des moyens d'action, tel est l'objectif de l'émission.

"; + +# Add image +$rss->image(title=>'Libre à vous !', url=>'https://april.org/files/libre-a-vous/banniere-libre-a-vous-flux-rss-1400x1400.png', link=>$linkurl); + +$rss->{channel}->{link} = $linkurl; + +# Parse items +my @new_items; +foreach my $item (@{$rss->{'items'}}) { + # Add mp3 enclosure + my $ogg_enclosure = $item->{enclosure}; + if ($ogg_enclosure and ($ogg_enclosure->{type} eq 'audio/ogg' or $ogg_enclosure->{type} eq 'application/ogg')) { + my $mp3_enclosure; + $mp3_enclosure->{type} = 'audio/mpeg'; + $mp3_enclosure->{length} = $ogg_enclosure->{length}; + ($mp3_enclosure->{url} = $ogg_enclosure->{url}) =~ s/\.ogg$/.mp3/; + $item->{enclosure} = [$ogg_enclosure, $mp3_enclosure]; + } + + # Add items for each topic + if ($item->{description} =~ /Podcasts des différents sujets abordés(?:<\/strong><\/p>|<\/h2>)?\s*