#!/usr/bin/perl -w use strict; # # Version 1.1 17-May-2002 # Written by David Adams # # 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"; SWF $Name HEAD open(CAT, "$SWFPARSE -t '$Input'|") || die "$SWFPARSE doesn't want to be opened using pipe\n"; print "\n"; my $c = 0; while () { ### 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 ' ', "\n"; $c++; } close CAT; print "\n\n"; print STDERR "No links extracted\n" if ($c == 0); exit;