aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README19
-rw-r--r--rss-fix.pl58
2 files changed, 62 insertions, 15 deletions
diff --git a/README b/README
index f18175b..6712a7a 100644
--- a/README
+++ b/README
@@ -1,11 +1,16 @@
1A short script to fix Slipshine's broken RSS feed. 1A short script to fix Slipshine's broken RSS feed.
2 2
3All links are replaced with their real link instead of just 3All links are replaced with their real link instead of linking to
4'http://members.orgymania.net/'. I've also added a guid for each item. This 4'http://members.orgymania.net/' and putting the real link in the description.
5fixes update issues with some RSS clients. 5RSS clients should be able to see updated and new items now. Additionally,
6each update is split into its own item instead of having more than one update
7in the description of an item.
6 8
7rss-fix.pl requires XML::RSS, while rss-fix_no-xml-rss.pl does not. Both 9The script requires LWP::Simple and Digest::MD5 and is meant to be run on a
8require LWP::Simple and Digest::MD5. 10web server that can execute Perl CGI scripts. Put this file on a webserver and
11subscribe to the new url (eg. http://example.com/cgi/rss-fix.pl) instead of the
12original RSS url.
9 13
10Note: this is meant to run on a webserver and act as a proxy to slipshine's 14No data is stored. The original RSS url is downloaded each time the script is
11feed. Requires a webserver capable of runing perl via CGI scripts. 15run and it prints out a new RSS feed. No login credentials are needed as
16Slipshine's feed is not hosted in the members-only area.
diff --git a/rss-fix.pl b/rss-fix.pl
index 5deaa05..6a0bdfd 100644
--- a/rss-fix.pl
+++ b/rss-fix.pl
@@ -1,29 +1,64 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2 2
3##
4## The MIT License (MIT)
5##
6## Copyright (c) 2015 Nick Scheibenpflug
7##
8## Permission is hereby granted, free of charge, to any person obtaining a copy
9## of this software and associated documentation files (the "Software"), to deal
10## in the Software without restriction, including without limitation the rights
11## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12## copies of the Software, and to permit persons to whom the Software is
13## furnished to do so, subject to the following conditions:
14##
15## The above copyright notice and this permission notice shall be included in
16## all copies or substantial portions of the Software.
17##
18## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24## THE SOFTWARE.
25##
26
3use strict; 27use strict;
4use warnings; 28use warnings;
5 29
6use Digest::MD5 qw(md5_hex); 30use Digest::MD5 qw(md5_hex);
7use LWP::Simple; 31use LWP::Simple;
8 32
33# Get the broken RSS feed.
9my $borked_rss = get('http://orgymania.net/updates.xml'); 34my $borked_rss = get('http://orgymania.net/updates.xml');
35
36# Grab the RSS header.
10$borked_rss =~ /<channel>(.*?)<item>/s; 37$borked_rss =~ /<channel>(.*?)<item>/s;
11my $header = $1; 38my $header = $1;
12my %header_sections = $header =~ /<([^>]+)>(.*?)<\/\1>/smg; 39my %header_sections = $header =~ /<([^>]+)>(.*?)<\/\1>/smg;
13 40
14$header_sections{'docs'} = '';
15$header_sections{'generator'} = 'Not Slipshine. That shit\'s borked.'; 41$header_sections{'generator'} = 'Not Slipshine. That shit\'s borked.';
16 42
43# Grab all the <item> elements.
17my @items = $borked_rss =~ /<item>(.*?)<\/item>/smg; 44my @items = $borked_rss =~ /<item>(.*?)<\/item>/smg;
18my @ul_links; 45my @ul_links;
19 46
47# Iterate over each item in the <channel> and extract all the links.
20foreach my $item (@items) { 48foreach my $item (@items) {
49 # Get a hash of all the tags in the current <item> element.
21 my %sections = $item =~ /<([^>]+)>(.*?)<\/\1>/smg; 50 my %sections = $item =~ /<([^>]+)>(.*?)<\/\1>/smg;
22 51
52 # Get a list of all the updates in the description.
23 $sections{'description'} =~ m/<ul>(.*?)<\/ul>/smg; 53 $sections{'description'} =~ m/<ul>(.*?)<\/ul>/smg;
24 my @list_items = split /<li>/, $1; 54 my @list_items = split /<li>/, $1;
55
56 # Each update gets its own <item> and we will find more than one link per
57 # <item> on occasion.
25 foreach my $l (@list_items) { 58 foreach my $l (@list_items) {
26 if ($l) { 59 if ($l) {
60 # Grab the real URL, update title, and user title
61 # (eg. 'updated by ...').
27 $l =~ m#<a href="(.*?)">(.*?)</a>(.*)#; 62 $l =~ m#<a href="(.*?)">(.*?)</a>(.*)#;
28 my $ul_link = $1; 63 my $ul_link = $1;
29 my $ul_title = $2; 64 my $ul_title = $2;
@@ -31,19 +66,23 @@ foreach my $item (@items) {
31 66
32 $ul_title_b =~ s/<(.*?)>//g; 67 $ul_title_b =~ s/<(.*?)>//g;
33 68
69 # Package the new data.
34 my %link_data; 70 my %link_data;
35 $link_data{'link'} = $ul_link; 71 $link_data{'link'} = $ul_link;
36 $link_data{'title'} = $ul_title; 72 $link_data{'title'} = $ul_title;
37 $link_data{'titleb'} = $ul_title_b; 73 $link_data{'titleb'} = $ul_title_b;
38 $link_data{'pubDate'} = $sections{'pubDate'}; 74 $link_data{'pubDate'} = $sections{'pubDate'};
39 75
76 # Store the data.
40 push @ul_links, \%link_data; 77 push @ul_links, \%link_data;
41 } 78 }
42 } 79 }
43} 80}
44 81
82# Print directly to the browser.
45print "Content-type: text/xml\n\n"; 83print "Content-type: text/xml\n\n";
46 84
85# RSS header stuff.
47print qq(<?xml version="1.0" encoding="iso-8859-1" ?>\n<rss version="2.0">\n); 86print qq(<?xml version="1.0" encoding="iso-8859-1" ?>\n<rss version="2.0">\n);
48print "<channel>\n\t<title>$header_sections{title}</title>\n", 87print "<channel>\n\t<title>$header_sections{title}</title>\n",
49 "\t<description>$header_sections{description}</description>\n", 88 "\t<description>$header_sections{description}</description>\n",
@@ -51,13 +90,16 @@ print "<channel>\n\t<title>$header_sections{title}</title>\n",
51 "\t<generator>$header_sections{generator}</generator>\n", 90 "\t<generator>$header_sections{generator}</generator>\n",
52 "\t<link>$header_sections{link}</link>\n"; 91 "\t<link>$header_sections{link}</link>\n";
53 92
93# Print each <item>.
54foreach my $nlink (@ul_links) { 94foreach my $nlink (@ul_links) {
55 print "\t<item>\n"; 95 print "\t<item>\n",
56 print "\t\t<title>$nlink->{title}</title>\n"; 96 "\t\t<title>$nlink->{title}</title>\n",
57 print "\t\t<guid>$nlink->{link}</guid>\n"; 97 "\t\t<guid>$nlink->{link}</guid>\n",
58 print "\t\t<link>$nlink->{link}</link>\n"; 98 "\t\t<link>$nlink->{link}</link>\n",
59 print "\t\t<pubDate>$nlink->{pubDate}</pubDate>\n"; 99 "\t\t<pubDate>$nlink->{pubDate}</pubDate>\n",
60 print "\t\t<description><![CDATA[<a href=\"$nlink->{link}\">$nlink->{title}</a>$nlink->{titleb}]]></description>\n"; 100 "\t\t<description><![CDATA[<a href=\"$nlink->{link}\">$nlink->{title}</a>$nlink->{titleb}]]></description>\n",
61 print "\t</item>\n"; 101 "\t</item>\n";
62} 102}
103
104# RSS footer.
63print "</channel>\n</rss>\n"; 105print "</channel>\n</rss>\n";