commit b86b7881faeb6a90da2be9505e0e5f9627927591
parent 623e8e0ed2f2a52fca8add5330ce66b6bb3246a6
Author: Alex Balgavy <alex@balgavy.eu>
Date: Fri, 12 May 2023 16:08:27 +0200
linkhandler: save to internet archive
Diffstat:
1 file changed, 25 insertions(+), 0 deletions(-)
diff --git a/scripts/linkhandler b/scripts/linkhandler
@@ -170,6 +170,23 @@ sub menu {
}
}];
+ push @$tableref, ['Archive', sub {
+ my ($link) = @_;
+ detach sub {
+ web_archive($link);
+ notify "Archived", "$link";
+ }
+ }];
+
+ push @$tableref, ['Archive (and copy archived)', sub {
+ my ($link) = @_;
+ detach sub {
+ my $location = web_archive($link);
+ system(qq(printf '%s' '$location' | clc));
+ notify "Archived $link", "Archived location copied to clipboard: $location";
+ }
+ }];
+
# Choose an option
my @options = map { $_->[0] } @$tableref;
my $choice = choose(\@options);
@@ -179,6 +196,14 @@ sub menu {
return $tableref->[$choice_index][1];
}
+# Save in the Internet Archive
+sub web_archive {
+ my $link = shift;
+ my $location = `curl -sI 'https://web.archive.org/save/$link' | awk -F': ' '/^location/ { print \$2 }'`;
+ return $location;
+}
+
+
# How to play {{{1
sub play_audio_mpd {
my $link = shift;