Feltros has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,
Basically, i'm tired of people stealing my flash! I make little videos or simple little single tune playing bits and everyone steals them! I've traced back a ton of myspace accounts using my flash and a load of other website users seem to be using them on their profiles and its bloody annoying. Short of changing the address its saved at every few days, I thought... if I could do this in perl then I could simply screen the IP's or referrer's I allowed.

So in essence, how do I change a normal flash file into a perl file which streams flash to work in this kinda situation:

<object width="250" height="190" codebase="http://download.macromedia. +com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" type="appli +cation/x-shockwave-flash" data="http://www.myhost.co.uk/flash.pl?play +=false" id="videocast"> <param value="http://www.myhost.co.uk/flash.pl" name="movie"></param> <param name="quality" value="best"/> </object>

20060922 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: Using perl to stream flash
by Melly (Chaplain) on Sep 22, 2006 at 19:20 UTC

    I'm confused - is this about stealing flash or stealing bandwidth?

    I sort of assume the latter, in which case you should be able to prevent linking without needing perl. If you can place a .htaccess file in your flash folder, you can specify valid http_referer values (or invalid http_referer values).

    Tom Melly, tom@tomandlu.co.uk
Re: Using perl to stream flash
by crashtest (Curate) on Sep 23, 2006 at 02:34 UTC

    Assuming this is about stealing bandwidth (no way to stop people from saving your flash to their computers), and you're not into the Apache options posted above, this would be a way to serve up a file using CGI:

    use strict; use warnings; use CGI; my $flash_file = 'your_flash_file.swf'; open FLASH, '<', $flash_file or die $!; binmode FLASH; my $q = new CGI; print $q->header( -content-type => 'flash/swf' -content_Length => (stat FLASH)[7] ); my $buffer; while (read(FLASH, $buffer, 1024) > 0){ print $buffer; } close FLASH;
    (add error-checking!)

    You may need to do some research on the HTTP headers to send along with the data. I am just guessing at the Content-type, for instance.

    Hope this helps.

      Yea thats the kind of solution I was looking for crashtest just wondered whether it was available to simply put content-type => flash/swf or whether it'd be more complex really... To reply to the others I can't stop hotlink access because i'm using the same website as they are, the access rules are a bit more complex than just that. And yes its about bandwidth, I don't care if someone steals my rubbishy 3mb music video (its literally the music with a pic of the album cover on it) its the fact everyone is just abusing my bandwidth and using my video on their own profiles and in all likelihood most people won't go to the effort of stealing mine and hosting it themselves.
        Apparently its Content-type: application/x-shockwave-flash from my research although i'm still at a miss as to the content length variable since I don't understand HTTP headers all that greatly - and reading the w3 info on them isn't that useful.
Re: Using perl to stream flash
by barrycarlyon (Beadle) on Sep 22, 2006 at 19:11 UTC

    Not a perl solution but use a hotlink protection in the .htaccess file, but rather than an image extesntion use .swf, ive used it with images, javascipt (.js) and css (.css)

    Barry Carlyon barry@barrycarlyon.co.uk
Re: Using perl to stream flash
by zentara (Cardinal) on Sep 23, 2006 at 12:10 UTC
    Even if you use a cgi to download it, people can still copy it out of their browser's cache. All it takes is a rename of the cached file. I'm sure most flash thieves are aware of this trick.

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: Using perl to stream flash
by BigJoe (Curate) on Oct 03, 2006 at 12:54 UTC
    Another solution. Again non Perl is if you don't want people to be able to download your flash files embed them. Start with your initial framework which all it does is connects back to you server and starts pulling smaller parts of the whole flash in small files. This way people steal you 15k loader file but get non of the content.


    --BigJoe

    Learn patience, you must.
    Young PerlMonk, craves Not these things.
    Use the source Luke.