SVN: toys/rsget.pl/Video/MegaVideo

sparky sparky at pld-linux.org
Tue Oct 6 11:48:56 CEST 2009


Author: sparky
Date: Tue Oct  6 11:48:56 2009
New Revision: 10701

Added:
   toys/rsget.pl/Video/MegaVideo
Log:
- new


Added: toys/rsget.pl/Video/MegaVideo
==============================================================================
--- (empty file)
+++ toys/rsget.pl/Video/MegaVideo	Tue Oct  6 11:48:56 2009
@@ -0,0 +1,61 @@
+#!/usr/bin/perl
+
+name: MegaVideo
+short: V:MegaVideo
+uri: qr{megavideo\.com/\?v=}
+uri: qr{megaporn\.com/video/\?v=}
+slots: 8
+status: OK 2009-10-06
+
+start:
+	GET( $-{_uri} );
+
+	my %fv = /flashvars\.(.*?)\s*=\s*"(.*?)";/g;
+
+	my $fname = $fv{title};
+	$fname =~ tr/+/ /;
+	$fname = uri_unescape( $fname );
+	$fname =~ s{/}{_}g;
+	$fname .= ".flv";
+
+	my $hd = "";
+	$hd = "hd_" if $fv{hd};
+
+	INFO( name => $fname, quality => "${hd}flv" );
+
+	my $s = $fv{ $hd . "s" };
+	my $path = id_to_path( map { $fv{ $hd . $_ } } qw(un k1 k2) );
+	my $file_uri = "http://www${s}.megaporn.com/files/$path/";
+
+	DOWNLOAD( $file_uri, fname => $fname );
+
+perl:
+
+sub id_to_path
+{
+	my $un = shift;
+	my $key1 = 0 + shift;
+	my $key2 = 0 + shift;
+
+	my @bits = split //, unpack "B*", pack "H*", $un;
+
+	my @keys = map {
+		$key1 = ( $key1 * 11 + 77213 ) % 81371;
+		$key2 = ( $key2 * 17 + 92717 ) % 192811;
+		( $key1 + $key2 ) % 128;
+	} (1..384);
+
+	for ( my $i = 256; $i >= 0; $i-- ) {
+		my $pos1 = $keys[ $i ];
+		my $pos2 = $i % 128;
+		my $tmp = $bits[ $pos1 ];
+		$bits[ $pos1 ] = $bits[ $pos2 ];
+		$bits[ $pos2 ] = $tmp;
+	}
+
+	$bits[ $_ ] ^= $keys[ $_ + 256 ] & 1 foreach (0..127);
+
+	return unpack "H*", pack "B*", join "", @bits;
+}
+
+# vim:ts=4:sw=4


More information about the pld-cvs-commit mailing list