#!/usr/bin/perl
# Origin: http://myrtfm.blogspot.co.il/2015/08/debconf-rss-reader.html
use LWP 5.64; # Loads all important LWP classes, and makes
use HTTP::Cookies; # Allow work with cookies
use WWW::Mechanize;
use XML::RSS;
use Encode qw(decode encode);
my $browser = LWP::UserAgent->new;
$browser->cookie_jar( HTTP::Cookies->new(
'file' => '/tmp/headers',
# where to read/write cookies
'autosave' => 1,
# save it to disk when done
));
$browser->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
my $url = "https://wiki.debconf.org/wiki/Videoteam/Subtitles/videos_debconf15";
my $response = $browser->get( $url );
#for each cookie we got, add it to the current jar
$browser->cookie_jar->extract_cookies( $response );
$response = $browser->get( $url );
my $rss = XML::RSS->new( version => '0.9' );
$rss->channel(
title => "video grabber for $url",
link => "$url",
description => "vg");
$rss->parsefile("$0.rss") if -f "$0.rss";
my $link = $response->content;
while ($link =~ /(.*)<\/a>/g)
{
$rss->add_item( title => $2, link => $1, mode => 'insert');
$link =~ s/(.*)<\/a>//;
}
$rss->save("$0.rss");
__END__
=head1 NAME
vg RSS - a script to get an RSS from debconf videos.
=head1 SYNOPSIS
Create an RSS 0.9 file based on the messages page.
=head1 DESCRIPTION
This script provide a basic example on how one could get the RSS from the rusty pages without the RSS interface,
=head1 BUGS
=head1 AUTHOR
Original code:Boris Shtrasman
=head1 COPYRIGHT
Copyright (c) 2015 Boris Shtrasman