-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkbeacon.pl
executable file
·53 lines (37 loc) · 1.03 KB
/
mkbeacon.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
use strict;
use autodie;
use File::Temp 'tempfile';
my $timestamp = "2011-12-31";
my $time = $timestamp."0000";
$time =~ s/-//g;
foreach my $f (@ARGV) {
next unless -f $f and $f =~ qr{^([a-z0-9.]+).*?(/([^/]+-[^/]+))?\.txt\.xz$};
print "$f\n";
my ($service, $set) = ($1,$3);
my $from = "http:https://$service" . ($set ? " (set $set)" : "");
my ($fh, $tmp) = tempfile();
print $fh <<BEACON;
#FORMAT: BEACON
#CREATOR: URLTeam
#HOMEPAGE: http:https://urlte.am/
#RELATION: http:https://dbpedia.org/resource/HTTP_301
#DESCRIPTION: Shortened URLs from $from
#PREFIX: http:https://$service/
#SOURCE: http:https://$service/
#TIMESTAMP: $timestamp
BEACON
close $fh;
`xz -z $tmp`;
`cat $f >> $tmp.xz`;
`cat $tmp.xz > $f`;
`touch -t $time $f`;
}
=head1 NAME
mkbeacon.pl - add metadata to .xz files from urlte.am
=head1 DESCRIPTION
This script prepends Beacon text format meta fields to link dumps provided by
L<http:https://urlea.am> beacuse metadata is crucial.
=head1 SEE ALSO
L<https://github.com/gbv/beaconspec>
=cut