![]() |
perl script for automation (source) #!/usr/bin/perl # Author: Bodo Eggert <7eggert@gmx.de> # Status: pre-alpha # License: GPL # ObExcuse: This is my first perl script # # To use the script, make a subdirectory and save (or symlink) # it there. This will be the script data directory. # Adjust the path to your napshare temporary directory, # any file not blacklisted and existing in that directory will be # downloaded. # # While used as a filter, the filenames are normalized, matched # against some filters and, depending on the result, written to # 1.txt (new), 2.txt or 3.txt (different blocklists) as long as # they are neither in f_getlist or f_blocklist. # # to download, move a line from 1.txt to f_getlist. # to never display a line again, move it to f_blocklist. # (if the filter is still active, rename the .txt-file first). # ($cwd=$0)=~s/\/[^\/]*$//; chdir $cwd; #begin program variables $GETLIST="f_getlist"; $BLOCKLIST="f_blocklist"; $NAPDIR="/d/napshare/"; #don't omit the slash! #end program variables #begin system variables $FGREP="/usr/bin/fgrep"; #end system variables $blocklist_f = "remix|.(wma|asf)\$|\\bentire album\\b"; $block_f="^t - [0-9]{7}|\^read ?me"; $blocklist_a = "\\b(Backstreet Boys|Janet Jackson|Missy Elliott)\\b"; $genres="\\&|[6-9]0s( music)?|alternative|copy (\([0-9]+\) )?of|new wave|oldies $mode=' '; $instring = $ARGV[0]; if(($instring=~s/^-(.)$/$1/)==1){ $mode=$instring; $instring = $ARGV[1]; } ($ofilename, $size, $speed, $status, $tag) = split(/\//,$instring,5); check: while(1) { if($ofilename =~ /$block_f/i) { $status=3; last check; } ($filename=$ofilename) =~ s/_|%20|\~/ /g; $filename =~ s/\'| $//g; $filename =~ s/-/ - /g; $filename =~ s/ +/ /g; $filename =~ s/(- )+/- /g; do { $filename =~ s/^ -? ?//g; } until(($filename =~ s/^($genres|\(($genres)\)|\[$genres\]|\{$genres\} $filename =~ s/^ -? ?//g; if(($filename =~ s/^\(([A-Za-z0-9, ]*)\)/$1 - /) || ($filename =~ s/^\(([A-Za-z0-9, ]*)\)/$1 - /)){ $filename =~ s/ +/ /g; $filename =~ s/(- )+/- /g; $filename =~ s/^ -? ?//g; } if(!system $FGREP, '-qsxi', '--', $filename, $GETLIST) { $status=0; } elsif(!system $FGREP, '-qsxi', '--', $filename, $BLOCKLIST){ $status=18; } else { $status=1; ################################## if ($filename =~ /\.mp3$/i) { ($f=$filename) =~ s/(\.mp3)*$//i; if ($f=~ /$blocklist_f/i) { $status=2; last check; } elsif(-e $NAPDIR.$filename) { $status=0; last check; } @test = split(/ - /, $f, -1); for($i=0;$i<@test;$i++){ if($test[$i] eq ""){splice(@test,$i,1);} } if(@test==1) { @test = split(/[\(\)]/, $f, -1); for($i=0;$i<@test;$i++){ if($test[$i] eq ""){splice(@test,$i,1);} } } if ($test[0] =~ /$blocklist_a/i) { $status=2; last check; } print @test.'#' .join(':', @test) . "\n"; # $status=0; last check; ################################## } last check; } last check; } if($status == 0) { exit 0;} if($status<16){ $LogFile = $status.".txt"; ((-e $LogFile)? open(LOG,">>$LogFile"):open(LOG,">$LogFile")) || die("Can't open $LogFile: $!\n"); print LOG $filename."\n"; } else { print $status-16 .$filename."\n"; } exit $status!=0; |
All times are GMT -7. The time now is 06:29 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.
Copyright © 2020 Gnutella Forums.
All Rights Reserved.