Created
May 15, 2012 23:52
-
-
Save vividsnow/2706103 to your computer and use it in GitHub Desktop.
recent supercollider tweets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env perl | |
use v5.12; | |
use HTTP::Tiny(); | |
use JSON::XS(); | |
use Try::Tiny; | |
use HTML::Entities 'decode_entities'; | |
my @search_words = ('#supercollider', '#sc140', '#sc', qw( | |
Ndef Tdef Pbind SinOsc PMOsc LFSaw LFPulse Splay Pan2 LFNoise0 LFNoise1 LFNoise2 LFCub LFPar | |
LFTri Drand Ringz Dshuf Decay2 DelayN DelayL DelayC CombC GVerb FreeVerb VarSaw DynKlank DynKlang | |
)); | |
my $http = HTTP::Tiny->new(timeout => 2); | |
say map { | |
decode_entities($_->{text} =~ s/(?<![\(\{])[\s\/]*#\S.+$|^(RT)?\s\@\S+\s//igmr)."\n"; | |
} grep { $_->{text} =~ /\.play|play\s*\{/ } map { | |
my $r = $http->get('http://search.twitter.com/search.json?'.$http->www_form_urlencode({ | |
q => 'play AND ('.join(' OR ', @search_words).') -rt', | |
result_type => 'recent', | |
rpp => 100, | |
page => $_ | |
})); | |
$r->{success} ? @{( try { JSON::XS->new->utf8->decode($r->{content})->{results}} catch { [] } )} : (); | |
} (1..2); # twitter responds only last week tweets and there are not many sc tweets, so query only 2 pages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment