summaryrefslogtreecommitdiff
path: root/tweet-archive.pl
diff options
context:
space:
mode:
Diffstat (limited to 'tweet-archive.pl')
-rw-r--r--tweet-archive.pl72
1 files changed, 52 insertions, 20 deletions
diff --git a/tweet-archive.pl b/tweet-archive.pl
index a1b5fff..1a7232b 100644
--- a/tweet-archive.pl
+++ b/tweet-archive.pl
@@ -3,9 +3,11 @@ use v5.36;
use strict;
use warnings;
use experimental 'try';
+use lib 'lib','local/lib/perl5';
use Path::Tiny;
use JSON::MaybeXS;
use Dakkar::TweetArchive;
+use Dakkar::NotesArchive;
use Dakkar::TweetArchive::Store;
my $json_parser = JSON::MaybeXS->new(
@@ -24,30 +26,60 @@ my $conf = $json_parser->decode(
},
);
-my $client = Dakkar::TweetArchive->new($conf);
-my $store = Dakkar::TweetArchive::Store->new($conf);
+my $store = Dakkar::TweetArchive::Store->new($conf->{db});
-my $ua = $client->client->ua;
-my @responses;
-$ua->add_handler( response_done => sub { push @responses, $_[0]; return } );
+if ($conf->{twitter}) {
+ my $client = Dakkar::TweetArchive->new($conf->{twitter});
-try {
- my $latest_id = $store->latest_tweet_id;
+ my @responses;
+ $client->client->ua->add_handler( response_done => sub { push @responses, $_[0]; return } );
- for my $tweet ($client->home_timeline($latest_id)->@*) {
- $store->store_tweet($tweet);
+ try {
+ my $latest_id = $store->latest_tweet_id;
+
+ for my $tweet ($client->home_timeline($latest_id)->@*) {
+ $store->store_tweet($tweet);
+ }
+
+ $store->store_twitter_friends($client->friends);
+ $store->store_twitter_followers($client->followers);
}
+ catch ($e) {
+ print "Twitter Fail: $e\n";
+ for my $res (@responses) {
+ next if $res->is_success;
+ print $res->request->as_string;
+ print $res->as_string;
+ print "\n",'-' x 50,"\n\n";
+ }
+ }
+ ;
+};
+
+if ($conf->{misskey}) {
+ my $client = Dakkar::NotesArchive->new($conf->{misskey});
- $store->store_friends($client->friends);
- $store->store_followers($client->followers);
- 1;
-}
-catch ($e) {
- print "Fail: $e\n";
- for my $res (@responses) {
- next if $res->is_success;
- print $res->request->as_string;
- print $res->as_string;
- print "\n",'-' x 50,"\n\n";
+ my @responses;
+ $client->client->ua->add_handler( response_done => sub { push @responses, $_[0]; return } );
+
+ try {
+ my $latest_id = $store->latest_note_id;
+
+ for my $note ($client->timeline($latest_id)->@*) {
+ $store->store_note($note);
+ }
+
+ $store->store_misskey_following($client->following);
+ $store->store_misskey_followers($client->followers);
}
+ catch ($e) {
+ print "Misskey Fail: $e\n";
+ for my $res (@responses) {
+ next if $res->is_success;
+ print $res->request->as_string;
+ print $res->as_string;
+ print "\n",'-' x 50,"\n\n";
+ }
+ };
};
+