-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetter_info.pl
executable file
·72 lines (60 loc) · 1.4 KB
/
getter_info.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl
#
use strict;
use warnings;
my $src = "svn";
my $out = "src/getters";
my %getters = ();
foreach my $dir ( qw(Premium Get Video Audio Image Link Direct) ) {
foreach my $f ( "$src/$dir/.template", glob "$src/$dir/*" ) {
next unless -r $f;
next if $f =~ /~$/;
$getters{ $f } = 1;
getter_info( $f );
}
}
foreach my $dir ( qw(Premium Get Video Audio Image Link Direct) ) {
foreach my $f ( "$out/$dir/.template", glob "$out/$dir/*" ) {
next unless -d $f;
$f =~ s/^$out/$src/;
die "getter $f does not exist"
unless $getters{ $f };
}
}
sub getter_info
{
my $file = shift;
my %tags;
my $pre = "";
open F_IN, "<", $file;
while ( <F_IN> ) {
$pre .= $_;
if ( /^([a-z]+):\s*(.*)$/ ) {
$tags{ $1 } = $2 unless exists $tags{ $1 };
}
}
close F_IN;
my @stat = stat $file;
my $outfile = $file;
$outfile =~ s#^$src#$out#;
print "Writing $outfile...";
mkdir "$outfile";
$outfile .= "/index.xml";
my $tos = "";
$tos = "<p>Check <a href=$tags{tos} rel=\"nofollow\">terms of service</a>.</p>\n"
if $tags{tos};
$pre =~ s/&/&/g;
$pre =~ s/</</g;
$pre =~ s/>/>/g;
open F_OUT, ">", $outfile;
print F_OUT <<EOF;
index: 0
title: $tags{name}
desc: [$tags{short}] <a href=$tags{web} rel="nofollow">$tags{web}</a>
body:
$tos<p>Status: $tags{status}</p>
<pre>$pre</pre>
EOF
close F_OUT and print " OK\n" or print " FAILED!\n";
utime $stat[ 8 ], $stat[ 9 ], $outfile;
}