#!/usr/bin/env perl
use strict;
use warnings;
use 5.012;
use Feed;
use Feed::Utils;
use Log::Log4perl;

Log::Log4perl::init(\<<'LOG');
log4perl.rootLogger = WARN, Screen
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.stderr = 1
log4perl.appender.Screen.layout = PatternLayout
log4perl.appender.Screen.layout.ConversionPattern = [%d{ISO8601}] %p{1} %X{opml} %X{uri} (%c) %m{chomp}%n
LOG

set_feed_class(Feed->with_traits(
    'MailDir',
    'FixDateTime',
    'DeDupe',
    'AuthorName',
    'UnBase64',
));

set_feed_args(
    dupe_dsn => 'dbi:SQLite:dbname=dedup.db',
    maildir_base => 'maildir',
);

feeds_from_opml(
    {
        mail_folders => 'Gentoo',
    },
    'https://planet.gentoo.org/opml.xml',
) if 0;

feeds(
    {
        mail_folders => 'Fun',
    },
    'https://dresdencodak.com/feed/rss/',
    'http://feeds2.feedburner.com/sydneypadua/yBZX',
    {
        uri => 'http://oglaf.com/feeds/rss/',
        title=>'Oglaf',
    },
    'http://www.bureau42.com/bureau42.rss',
    'http://syndication.thedailywtf.com/TheDailyWtf',
    {
        uri => 'https://feeds.feedburner.com/thisisindexed/',
        # uri => http://thisisindexed.com/feed/',
        title => 'Indexed',
        dedupe_use_body => 0,
    },
    {
        uri => 'https://bakabt.me/rss.php?uid=714931&key=94346a8e67f313b3cf64bef311eaf551',
        title => 'BakaBT releases',
        dedupe_use_body => 0,
        dedupe_use_date => 0,
    },
);

feeds(
    {
        mail_folders => 'OSS',
    },
    'https://alistapart.com/main/feed/',
    'https://www.oreilly.com/radar/feed/index.xml',
    'https://www.oreilly.com/radar/topics/four-short-links/feed/index.xml',
    'http://feeds.feedburner.com/Oreillygmt',
    'http://emacs-fu.blogspot.com/feeds/posts/default',
);

feeds(
    {
        mail_folders => 'Perl',
    },
    {
        uri => 'file:///var/www/thenautilus/htdocs/metacpan.atom',
        title => 'Recent CPAN uploads - MetaCPAN',
    },
    'http://pugs.blogs.com/pugs/index.rdf',
    'http://blog.plover.com/index.atom',
    'https://shitpost.plover.com/index.atom',
    'http://blogs.perl.org/atom.xml',
    'http://YAPHB.blogspot.com/atom.xml',
    'http://pugs.blogs.com/audrey/atom.xml',
    'http://blog.fsck.com/atom.xml',
    'http://blog.urth.org/index.xml',
    'http://log.perl.org/feeds/posts/default',
    {
        uri => 'https://xdg.me/blog/index.xml',
        dedupe_use_body => 0,
    },
    'http://perl6advent.wordpress.com/feed/',
    'http://perladvent.org/2014/atom.xml',
    'http://leonerds-code.blogspot.com/feeds/posts/default',
    'http://pl6anet.org/atom.xml',
    'https://rakudoweekly.blog/feed/',
);

feeds(
    {
        mail_folders => 'Science',
    },
    'http://www.badscience.net/feed/',
    'http://khymos.org/feed/',
    'http://glottorellando.wordpress.com/feed/',
    'http://languagelog.ldc.upenn.edu/nll/?feed=atom',
    {
    	uri => 'http://www.goodmath.org/blog/?feed=rss2',
        dedupe_use_body => 0,
    },
    'http://cattaneo-lescienze.blogautore.espresso.repubblica.it/feed/atom/',
    'http://feeds.feedburner.com/makezineonline',
    'http://ovadia-lescienze.blogautore.espresso.repubblica.it/feed/atom/',
    'http://rudimatematici-lescienze.blogautore.espresso.repubblica.it/feed/atom/',
    'http://www.schneier.com/blog/index.rdf',
    'http://bressanini-lescienze.blogautore.espresso.repubblica.it/feed/atom/',
    'http://feeds.feedburner.com/cavolettobruxelles',
    'http://scienceofmagic.wordpress.com/feed/',
    'http://blog.plan28.org/feeds/posts/default',
    'http://chasmosaurs.com/feed/',
);

feeds(
    {
        mail_folders => 'Stuff',
    },
    'https://freedom-to-tinker.com/feed/atom/',
    'http://hackaday.com/feed/',
    'http://watchismo.blogspot.com/feeds/posts/default',
);

feeds(
    {
        mail_folders => 'Weblogs',
    },
    'http://feeds.feedburner.com/boingboing/iBag',
    'http://www.rousette.org.uk/blog/index.xml',
    {
        uri => 'http://www.haibane.info/feed/',
        dedupe_use_body => 0,
    },
    'http://nobodyharks.blogspot.com/feeds/posts/default',
    'http://spaghettovolante.wordpress.com/feed/',
    'http://exquisitebeast.tumblr.com/rss',
    'https://viaggiandocongiotto.com/feed/',
    'https://megmegsmusings.wordpress.com/feed/',
);

feeds(
    {
        mail_folders => 'Writers',
    },
    {
        uri => 'http://www.antipope.org/charlie/blog-static/atom.xml',
        dedupe_use_date => 0,
    },
    {
        uri => 'http://elizabethbear.livejournal.com/data/rss',
        dedupe_use_body => 0,
    },
    'http://lisagoldresearch.wordpress.com/feed/',
    {
    	uri => 'http://journal.neilgaiman.com/feeds/posts/default',
	dedupe_use_body => 0,
    },
    'http://www.tor.com/feed',
    'http://whatever.scalzi.com/feed/',
    {
        uri => 'http://thecomposites.tumblr.com/rss',
        dedupe_use_body => 0,
    },
    {
    	uri => 'http://www.goodreads.com/author/show/16094.Lois_McMaster_Bujold/blog?format=rss',
	dedupe_use_body => 0,
    },
);

feeds(
    {
        mail_folders => '3dPrinter',
    },
    {
        uri => 'http://hydraraptor.blogspot.com/feeds/posts/default',
        dedupe_use_body => 0,
    },
);

