summaryrefslogtreecommitdiffstats
path: root/debian/htdig/htdig-3.2.0b6/contrib/doc2html/swf2html.pl
blob: 5f0cdb078d61893f8206615d2ac5146cdbc171bb (plain)
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
#!/usr/bin/perl -w
use strict;
#
# Version 1.1	17-May-2002
# Written by David Adams <d.j.adams@soton.ac.uk>
#
# Uses swfparse utlity to extract URL's from  Shockwave flash files
#  
# Can be called directly from htdig as an external converter,
#  or may be called by doc2html.pl converter script. 
#

####--- Configuration ---####
# Full path of swfparse
# (get it from http:/www.htdig.org/files/contrib/contrib/parsers/)

##### YOU MUST SET THIS  ####

my $SWFPARSE = "/.. .../swfdump";

####--- End of configuration ---###

if (! -x $SWFPARSE) { die "Unable to execute swfparse" }

my $Input = $ARGV[0] || die "Usage: swf2html.pl filename [mime-type] [URL]";
my $MIME_type = $ARGV[1] || '';
if ($MIME_type and ($MIME_type !~ m#^application/x-shockwave-flash#i)) {
  die "MIME/type $MIME_type wrong";
}

my $Name = $ARGV[2] || '';
$Name =~ s#^(.*/)##;
# decode if 2nd argument was a URL 
$Name =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie if $1;

print <<"HEAD";
<HTML>
<HEAD>
<TITLE>SWF $Name</TITLE>
<META NAME="robots" CONTENT="follow, noindex">
</HEAD>
HEAD

open(CAT, "$SWFPARSE -t '$Input'|") || 
	  die "$SWFPARSE doesn't want to be opened using pipe\n";

print "<BODY>\n";
my $c = 0;
while (<CAT>) {
###    if ($_ !~ m/\s+getUrl\s+(.*?)\s+.*$/) { next }
    if ($_ !~ m/\s+getUrl\s+(.*)$/) { next }
    my $link = $1 . ' ';
    if ($link =~ m/^FSCommand:/) { next }
    if ($link =~ m/\s+target\s+/) {
      $link =~ s/^(.*)\s+target\s+.*$/$1/;  
    } else {
      $link =~ s/^(.*?)\s+.*$/$1/; 
    }
    print '<A href="', $link, '"> </a>', "\n";
    $c++;
}
close CAT;

print "</BODY>\n</HTML>\n";
print STDERR "No links extracted\n" if ($c == 0);

exit;