Saturday, July 2, 2016

Perl and Bash Shell Scripts To Download All Driver Packs Torrent Files

This is nice to use to mirror the driverpacks. Use with your torrent client's watch directory.


#!/bin/bash
#
# dl_all_dps.sh
#
# Downloads all the torrents for the current lastest releases of driver packs
# for all Windows operating systemss and all their architectures.
# TLDR: Downloads all available driver packs
#
# © Michael Craze -- http://projectcraze.us.to

for x in `lynx -dump http://driverpacks.net/driverpacks/latest | grep "http:\/\/driverpacks\.net\/driverpacks\/windows\/" | awk '{print $2;}'`; do
        #/driverpacks/windows/7/x86/monitors/10.01/download/torrent
        echo "Getting: $x";

        # This should work, but it doesn't - couldn't figure out why so rewrote script in perl
        #lynx -dump "$x" | grep "\/download\/torrent" | awk '{print $2}' | wget -i -
        lynx -force_html -dump "$x" | grep "\/download\/torrent" | awk '{print $2}'
done

#!/usr/bin/perl
#
# Downloads all torrents for all driver packs for all windows operating systems
# and architectures
#
# © Michael Craze -- http://projectcraze.us.to

use strict;
use warnings;
use LWP::Simple;

my $debug=0;
my $domain="http://driverpacks.net";
my $url=$domain."/driverpacks/latest";
my $content=get($url);
die "Couldn't get url: $url" unless defined $content;

if ($debug){
        print "$content\n";
}

my @torrent_links=($content =~ /(\/driverpacks\/windows\/(7|xp)\/(x86|x64)\/[-a-zA-Z]+\/\d+\.\d+)/g);
foreach my $link (@torrent_links){
        if($link =~ /(\/driverpacks\/windows\/(7|xp)\/(x86|x64)\/[-a-zA-Z]+\/\d+\.\d+)/g){
                #print "Getting: $domain"."$link\n";
                my $link_content=get($domain.$link);
                die "Couldn't get url: $url" unless defined $link_content;
                if($debug){
                        print "$link_content\n";
                }
                if($link_content =~ /(\/driverpacks\/windows\/(7|xp)\/(x86|x64)\/[-a-zA-Z]+\/\d+\.\d+\/download\/torrent)/g){
                        my $uri=$domain.$1;
                        print "Downloading: $uri\n";
                        my @dirs=split("/",$1);
                        my $filename="DP_".$dirs[2]."_".$dirs[3]."_".$dirs[4]."_".$dirs[5]."_".$dirs[6].".torrent";
                        print " Filename: $filename\n";
                        my $status=getstore($uri,$filename);
                        die "$status error while getting $uri" unless is_success($status);
                }
        }
}

No comments:

Post a Comment