diff options
| author | jules on spawn <spawn@cortex> | 2018-05-13 12:03:37 +0200 |
|---|---|---|
| committer | jules on spawn <spawn@cortex> | 2018-05-13 12:03:37 +0200 |
| commit | a61412eb1538615578e87a20ddfbc618e1eeb041 (patch) | |
| tree | 2751107a89fbd4acae0c3435d6a9f9e655474bcf /get.pl | |
| parent | 3ff94cfea6b8953307e29d5d3ffba9d70cf7659e (diff) | |
get script now supports urls
Diffstat (limited to 'get.pl')
| -rwxr-xr-x | get.pl | 43 |
1 files changed, 38 insertions, 5 deletions
@@ -4,11 +4,44 @@ $SIG{TERM} = $SIG{INT} = sub { exit 1 }; chdir('datasets'); -foreach (@ARGV){ - my $s = $_; - if ($s !~/\..*$/) { $s .= ".wav"; } - system('/usr/bin/wget', 'https://neural:spawn5@asdf.us/neural/' . $s); - system('/usr/bin/perl', 'dataset.pl', $s); +my $fn, $new_fn; +foreach my $s (@ARGV){ + if ($s =~ /^http/) { + if ($s =~ /(wav|aiff?|flac|mp3|opus)$/i) { + my $fn = `basename $s`; + system('/usr/bin/wget', $s); + system('/usr/bin/perl', 'dataset.pl', $fn); + } else { + my $yt = `youtube-dl --extract-audio --audio-format flac -o "%(title)s.%(ext)s" $s`; + my @partz = split("\n", $yt); + foreach $part (@partz) { + if ($part =~ /\[ffmpeg\] Destination\: (.*\.flac)$/) { + $fn = $1; + } + } + if ($fn) { + $new_fn = lc $fn; + $new_fn =~ s/\.flac$//g; + $new_fn =~ s/\s+/_/g; + $new_fn =~ s/\W//g; + if (length($new_fn) == 0) { + $new_fn = lc $s; + $new_fn =~ s/\s+/_/g; + $new_fn =~ s/\W//g; + } + $new_fn =~ s/_+/_/g; + $new_fn .= '.flac'; + system('mv', $fn, $new_fn); + print"got fn, $fn => $new_fn\n"; + system('/usr/bin/perl', 'dataset.pl', $new_fn); + } + } + } else { + if ($s !~/\..*$/) { $s .= ".wav"; } + system('/usr/bin/wget', 'https://neural:spawn5@asdf.us/neural/' . $s); + system('/usr/bin/perl', 'dataset.pl', $s); + } + $fn = undef; } END { |
