Skip to content

Instantly share code, notes, and snippets.

@hernan604
Created November 8, 2013 02:25
Show Gist options
  • Select an option

  • Save hernan604/7365314 to your computer and use it in GitHub Desktop.

Select an option

Save hernan604/7365314 to your computer and use it in GitHub Desktop.
WWW Vimeo Download november 2013 version
use Moose;
use HTTP::Tiny;
use JSON::XS;
use DDP;
my $video_id = "78802560";
my $ua = HTTP::Tiny->new();
my $res = $ua->get( "http://vimeo.com/".$video_id );
my ( $stuff, $key ) = $res->{ content } =~ m!data-config-url="([^"]+)&s=([a-zA-Z0-9]+)"!;
warn $key;
my $metadata_video = "http://player.vimeo.com/v2/video/".$video_id."/config?byline=0&bypass_privacy=1&context=clip.main&default_to_hd=1&portrait=0&title=0&s=".$key;
$res = $ua->get( $metadata_video );
my $metadata = decode_json( $res->{ content } );
warn p $metadata->{ request }->{ files };
my $first_format_avail = $metadata->{ request }->{ files }->{ codecs }[0];
my $video_url;
foreach my $fmt ( qw/hd sd/ ) {
warn $fmt;
$video_url = $metadata->{ request }->{ files }->{ $first_format_avail }->{ $fmt }->{ url }
if exists $metadata->{ request }->{ files }->{ $first_format_avail }
and exists $metadata->{ request }->{ files }->{ $first_format_avail }->{ $fmt }
and exists $metadata->{ request }->{ files }->{ $first_format_avail }->{ $fmt }->{ url };
last if defined $video_url;
}
warn $video_url;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment