Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8dbe284d06 | ||
|
|
0a838524f3 | ||
|
|
21be087ee7 | ||
|
|
8fd91a7afe | ||
|
|
5548ea253e | ||
|
|
07b553e6b7 | ||
|
|
02ca39953c | ||
|
|
b0f84143b0 | ||
|
|
24e71c039f |
@@ -1,4 +1,9 @@
|
||||
# pod_feeder
|
||||
# NOTICE: THIS PROJECT IS NO LONGER MAINTAINED
|
||||
Please migrate to
|
||||
[pod_feeder_v2](https://gitlab.com/brianodonnell/pod_feeder_v2) and let this
|
||||
version die with dignity 🙂
|
||||
|
||||
# [pod_feeder](https://github.com/rev138/pod_feeder)
|
||||
Publishes RSS/Atom feeds to Diaspora*
|
||||
|
||||
This is a lightweight, customizable "bot" script to harvest RSS/Atom feeds and re-publish them to the Diaspora social network. It is posted here without warranty, for public use.
|
||||
@@ -13,10 +18,12 @@ This is a lightweight, customizable "bot" script to harvest RSS/Atom feeds and r
|
||||
- JSON
|
||||
- XML::Simple
|
||||
- DBD::SQLite
|
||||
- Unicode::Normalize
|
||||
- Getopt::Long
|
||||
- HTML::FormatMarkdown
|
||||
|
||||
For instance, on a debian system you can install them like so:
|
||||
|
||||
`sudo apt-get install libwww-perl libany-uri-escape-perl libhtml-parser-perl libjson-perl libxml-simple-perl libdbd-sqlite3-perl libhtml-format-perl`
|
||||
|
||||
This script is intended to be run as a cron job, which might look something like this:
|
||||
|
||||
`@hourly ~/pod_feeder.pl --feed-id myfeed --feed-url http://example.com/feeds/rss --pod-url https://diaspora.hzsogood.net --username user --password supersecretpassword --category-tags --title-tags > /dev/null 2>&1`
|
||||
@@ -25,6 +32,7 @@ This script is intended to be run as a cron job, which might look something like
|
||||
|
||||
-a --aspect-id <id> Aspects to share with. May specify multiple times (default: 'public')
|
||||
-b --embed-image Embed an image in the post if a link exists (default: off)
|
||||
--body Post the body of the feed (description or content:encoded item)
|
||||
-c --category-tags Attempt to automatically hashtagify RSS item 'categories' (default: off)
|
||||
-d --database <sqlite file> The SQLite file to store feed data (default: 'feed.db')
|
||||
-e --title-tags Automatically hashtagify RSS item title
|
||||
|
||||
+12
-5
@@ -268,7 +268,7 @@ sub get_feed_items {
|
||||
$link_part =~ s/(\?.*)$//;
|
||||
|
||||
# split up string
|
||||
my @parts = split( /([^(\p{Letter}|\p{Number})]|\p{Punctuation})/, $link_part );
|
||||
my @parts = split( /([^[[:alnum:]]]|[[:blank:]]|[[:punct:]])/, $link_part );
|
||||
|
||||
push( @hashtags, @parts );
|
||||
}
|
||||
@@ -281,7 +281,7 @@ sub get_feed_items {
|
||||
$title =~ s/('|`)//g;
|
||||
|
||||
# split up string on non-alphanumerics
|
||||
my @parts = split( /([^(\p{Letter}|\p{Number})]|\p{Punctuation})/, $title );
|
||||
my @parts = split( /([^[[:alnum:]]]|[[:blank:]]|[[:punct:]])/, $title );
|
||||
my @tags = ();
|
||||
|
||||
foreach my $part ( @parts ){
|
||||
@@ -362,6 +362,7 @@ sub get_feed_items {
|
||||
my $body = '';
|
||||
$body = HTML::FormatMarkdown->format_from_string($item->{'description'}, rm => 100000) if ($item->{'description'});
|
||||
$body = HTML::FormatMarkdown->format_from_string($item->{'content:encoded'}, rm => 100000) if ($item->{'content:encoded'});
|
||||
$body = HTML::FormatMarkdown->format_from_string($item->{'content'}, rm => 100000) if ($item->{'content'});
|
||||
|
||||
my $obj = {
|
||||
guid => $guid,
|
||||
@@ -389,7 +390,6 @@ sub get_feed_items {
|
||||
sub decode_feed{
|
||||
my ( $feed ) = @_;
|
||||
my @list = ();
|
||||
|
||||
# RSS
|
||||
if( defined $feed->{'channel'} and defined $feed->{'channel'}->{'item'} ){
|
||||
if( ref $feed->{'channel'}->{'item'} eq 'ARRAY' ){
|
||||
@@ -450,6 +450,12 @@ sub decode_feed{
|
||||
}
|
||||
}
|
||||
|
||||
if( defined $entries->{$guid}->{'content'} ){
|
||||
if( ref($entries->{$guid}->{'content'}) eq 'HASH' and defined $entries->{$guid}->{'content'}->{'content'} ){
|
||||
$item->{'content'} = $entries->{$guid}->{'content'}->{'content'};
|
||||
}
|
||||
}
|
||||
|
||||
push( @list, $item ) if defined $item->{'link'} and defined $item->{'title'};
|
||||
}
|
||||
}
|
||||
@@ -496,6 +502,7 @@ sub hashtagify {
|
||||
next if lc( $item ) =~ m/^(a(lso|nd|ny|re)|been|but|can(not|t)?|e(ach|tc|very)|for|from|g(e|o)t|ha(d|ve)|has(nt)?|hers?|hi(m|s)|how|its|no(r|t)|ours?|she|some|th(an|at|em?|eirs?|(e|o)se|ey|eyre|is)|too|very|was|wh(at|en|o)|with|you(r|rs)?)$/;
|
||||
# hashtagify it
|
||||
$item = '#' . $item unless $item =~ m/^#/;
|
||||
|
||||
# use a hash here instead of an ordered list for auto-dedupe
|
||||
$hashtags{ lc( $item ) } = undef;
|
||||
}
|
||||
@@ -621,7 +628,7 @@ sub post_message {
|
||||
my $message = { status_message => { text => format_content( $content, %params ), provider_display_name => $params{'via'} }, aspect_ids => $aspect_ids };
|
||||
my $json = JSON->new->allow_nonref;
|
||||
|
||||
$json = $json->utf8(0) unless utf8::is_utf8( $message );
|
||||
# $json = $json->utf8(1) unless utf8::is_utf8( $message );
|
||||
|
||||
my $json_message = $json->encode( $message );
|
||||
|
||||
@@ -666,7 +673,7 @@ sub usage {
|
||||
print " -b --embed-image Embed an image in the post if a link exists (default: off)\n";
|
||||
print " -c --category-tags Attempt to automatically hashtagify RSS item 'categories' (default: off)\n";
|
||||
print " -d --database <sqlite file> The SQLite file to store feed data (default: 'feed.db')\n";
|
||||
print " -e --title-tags Automatically hashtagify RSS item title\n";
|
||||
print " -e --title-tags Automatically hashtagify RSS item title\n";
|
||||
print " -f --feed-url <http://...> The feed URL\n";
|
||||
print " -g --user-agent <string> Use this to spoof the user-agent if the feed blocks bots (ex: 'Mozilla/5.0')\n";
|
||||
print " -i --feed-id <string> An arbitrary identifier to associate database entries with this feed\n";
|
||||
|
||||
Reference in New Issue
Block a user