From e76b691e78e273226cba9284cb8cd22a423319ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:23:25 -0500 Subject: bucky2 --- bucky2/rest/dropsy-web.pl | 103 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100755 bucky2/rest/dropsy-web.pl (limited to 'bucky2/rest/dropsy-web.pl') diff --git a/bucky2/rest/dropsy-web.pl b/bucky2/rest/dropsy-web.pl new file mode 100755 index 0000000..af2304d --- /dev/null +++ b/bucky2/rest/dropsy-web.pl @@ -0,0 +1,103 @@ +#!/usr/bin/perl +use lib "../lib"; +use Rest::Topsy; +use Rest::Dailyrotten; +my $topsy = new Rest::Topsy; +my $dr = new Rest::Dailyrotten; +$topsy->url('http://twitter.com/dailyrotten'); +my $entries = $topsy->topsy_load; +my $stories = $dr->dailyrotten_load; + +my $topsy_map = {}; +map { $topsy_map->{$_->{'description'}} = $_->{'total'} } @$entries; + +my $dr_topsy_match = []; +foreach my $day (@$stories) + { + my $is_ffa = 1; + foreach my $story (reverse @{ $day->{'post'} }) + { + my $title = $story->{'title'}; + my $rec = + { + date => nice_date($day->{'file'}), + title => $title, + forum => $story->{'comments'}, + ffa => $is_ffa, + url => $story->{'url'}, + }; + $is_ffa = 0; + if (exists($topsy_map->{$title})) + { + $rec->{'topsy'} = $topsy_map->{$title}, + } + push @$dr_topsy_match, $rec; + } + if ($dr_topsy_match->[-1]->{'forum'} > 100) + { $dr_topsy_match->[-1]->{'ffa'} = 1; } + } + +print_report("title", [(sort { lc $a->{'title'} cmp lc $b->{'title'} } @$dr_topsy_match)]); +print_report("date", [(sort { $b->{'date'} cmp $a->{'date'} } @$dr_topsy_match )]); +print_report("topsy", [(sort { $b->{'topsy'} <=> $a->{'topsy'} } @$dr_topsy_match)]); +print_report("forum", [(sort { $b->{'forum'} <=> $a->{'forum'} } @$dr_topsy_match)]); +sub print_report + { + my ($title, $matches) = @_; + my $out .= header($title); + foreach my $p (@$matches) + { + $out .= ""; + $out .= "". $p->{'date'} .""; + + my $ffa_class = " bold" if $p->{'ffa'}; + $out .= "". $p->{'forum'} .""; + + my $topsy_class = " bold" if $p->{'topsy'} > 100; + $out .= "". $p->{'topsy'} .""; + + $out .= "{'url'}\">". $p->{'title'} .""; + $out .= ""; + } + $out .= footer(); + $topsy->write_data("../tmp/dr/".$title.".html", $out); + } +sub header + { my $current = shift; my $out .= <<__HEADER__; + + + + + +date = date posted on daily rotten = date twittered
+forum = comments on dailyrotten forum (FFAs are bold)
+topsy = number of other people tweeting this story as calculated by topsy
+title = title of article
+ + + +"; + return $out; + } +sub footer + { return "
+__HEADER__ + $out .= join "", map { $current eq $_ ? "$_" : "$_" } qw[date forum topsy title]; + $out .= "
"; } +sub nice_date + { + my ($date) = @_; + $date =~ s/^_//; + $date =~ s/\.html$//; + return $date; + } -- cgit v1.2.3-70-g09d2