1: #!/usr/bin/perl -w
2:
3: # On irc.qeast.net, there's a channel called #hqa where you can go
4: # to download fansubbed anime. Their preferred method of
5: # distribution is ftp, and a list of participating ftp sites can
6: # be recieved by typing "!HQA-list" in the channel.
7: #
8: # The following script will take this list of ftp sites and
9: # reformat it into ncftp bookmark format before printing it to
10: # STDOUT. This output can be appended to ~/.ncftp/bookmarks.
11: #
12: # Then, if you use zsh 4.x (or greater) and have completions
13: # turned on, typing `ncftp [TAB]` should present you with list of
14: # bookmarks to choose from. Zsh's completions can be enabled by
15: # running `autoload -U compinit; compinit`.
16:
17: use strict;
18:
19: sub ip {
20: my $host = shift;
21: my $ip;
22: if ($host =~ /^d/) {
23: $ip = $host;
24: } else {
25: my $dat = gethostbyname($host);
26: if (defined($dat)) {
27: $ip = join('.', unpack('CCCC', $dat));
28: } else {
29: $ip = "";
30: }
31: }
32: $ip;
33: }
34:
35: my $fn = shift || "hqa-list.txt";
36: open(IN, $fn) || die($!);
37:
38: while (<IN>) {
39: last if /^Name/;
40: }
41: my @line = <IN>;
42: shift(@line);
43:
44: *F = *STDOUT;
45:
46: foreach (@line) {
47: my ($name, $host, $port, $login, $pass) = split(/\s+/, $_);
48: printf F (
49: "%s,%s,%s,,,%s,I,%d,%d,1,1,1,1,%s,,,,,,S,-1\n",
50: $name,
51: $host,
52: $login,
53: "",
54: $port,
55: 0,
56: ip($host),
57: );
58: }
59:
60: exit 0;