aboutsummaryrefslogtreecommitdiff
path: root/bin/psycamp
diff options
context:
space:
mode:
authorpsyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet>2016-08-10 15:28:51 +0000
committerpsyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet>2016-08-10 15:28:51 +0000
commit1580386217695e12d8eb6152a2d447262ef2d29d (patch)
treea607544c3fa1eca69fbbcb31ae832be9a63c49ee /bin/psycamp
parent8b41a25b65da90b6c5432595059867d26ec3f70c (diff)
downloadperlpsyc-1580386217695e12d8eb6152a2d447262ef2d29d.tar.gz
perlpsyc-1580386217695e12d8eb6152a2d447262ef2d29d.zip
signals for remotor, improved trash and duration for psycamp
Diffstat (limited to 'bin/psycamp')
-rwxr-xr-xbin/psycamp75
1 files changed, 46 insertions, 29 deletions
diff --git a/bin/psycamp b/bin/psycamp
index d48baf9..f8844f6 100755
--- a/bin/psycamp
+++ b/bin/psycamp
@@ -386,6 +386,7 @@ sub ginread {
386 print RED, unlink ($deleteLater) ? 386 print RED, unlink ($deleteLater) ?
387 "\r***" : "\r - ", BOLD, GREEN, "[\n", RESET; 387 "\r***" : "\r - ", BOLD, GREEN, "[\n", RESET;
388 $deleteLater = undef; 388 $deleteLater = undef;
389 &trash;
389 } elsif ($opt_d && ($Volatile || 390 } elsif ($opt_d && ($Volatile ||
390 $CurrentFile =~ /\b$VOLATILE\b/oi)) { 391 $CurrentFile =~ /\b$VOLATILE\b/oi)) {
391 print RED, unlink ($CurrentFile) ? 392 print RED, unlink ($CurrentFile) ?
@@ -395,13 +396,13 @@ sub ginread {
395 $CurrentFile !~ /\b$KEEP\b/oi) { 396 $CurrentFile !~ /\b$KEEP\b/oi) {
396 print RED, unlink ($CurrentFile) ? 397 print RED, unlink ($CurrentFile) ?
397 "\r***" : "\r - ", BOLD, GREEN, "[\n", RESET; 398 "\r***" : "\r - ", BOLD, GREEN, "[\n", RESET;
398 } elsif ($DUR/1000 - $tc > 4) { 399 } elsif ($DUR - $tc > 4) {
399 # Both ffmpeg and mplayer have a bug of 400 # Both ffmpeg and mplayer have a bug of
400 # dividing the sum of frame bitrates by 401 # dividing the sum of frame bitrates by
401 # the duration of the complete track, thus 402 # the duration of the complete track, thus
402 # counting zero for the missing part. This 403 # counting zero for the missing part. This
403 # formula compensates for that bug. 404 # formula compensates for that bug.
404 my $estira = $I{bitrate} * $DUR/$tc/1000; 405 my $estira = $I{bitrate} * $DUR/$tc;
405 printf "%s%sIncomplete file. Estimated actual bitrate: %.1f%s\n", BOLD, YELLOW, $estira, RESET if $estira < 1000 and $estira > 50; 406 printf "%s%sIncomplete file. Estimated actual bitrate: %.1f%s\n", BOLD, YELLOW, $estira, RESET if $estira < 1000 and $estira > 50;
406 # Then again, this approach sometimes 407 # Then again, this approach sometimes
407 # fails if mplayer doesn't let us have 408 # fails if mplayer doesn't let us have
@@ -599,15 +600,7 @@ X
599 #{ O 600 #{ O
600 if ( $ALLOW_DELETE_KEY ) { 601 if ( $ALLOW_DELETE_KEY ) {
601 if ( /^T(T?)\s*$/ ) { 602 if ( /^T(T?)\s*$/ ) {
602 # 'T' deletes song and remembers it in the index of trash media 603 $trashLater = $CurrentFile;
603 if (open(HATE, ">>", HATEINDEX)) {
604 printf HATE "%10d %5s %3s\t%s\r\n",
605 $CurrentSize, $I{duration}, $I{bitrate}, $CurrentFile;
606 close HATE;
607 print CYAN, ">> marked as trash\n", RESET;
608 } else {
609 print BOLD, RED, "*** Failed to write to ", HATEINDEX, ":\n", RESET, $out;
610 }
611 # dirty way to fall through into one of the following ifs 604 # dirty way to fall through into one of the following ifs
612 $_ = $1? 'DD': 'D'; 605 $_ = $1? 'DD': 'D';
613 } 606 }
@@ -620,19 +613,20 @@ X
620 if ( /^D\s*$/ ) { 613 if ( /^D\s*$/ ) {
621 my $f = $CurrentFile; 614 my $f = $CurrentFile;
622 &ginclose; 615 &ginclose;
616 &trash;
623 print BOLD, RED, ">> deleted: $f\n", RESET if unlink $f; 617 print BOLD, RED, ">> deleted: $f\n", RESET if unlink $f;
624 &ginopen; 618 &ginopen;
625 &next(0); 619 &next(0);
626 next; 620 next;
627 } 621 }
628 } 622 }
629 if ( /^(J|U|K|E|M|V|X|C|F|L|W|S|R)(\w?)\s*$/ ) { 623 if ( /^(J|U|K|E|M|V|X|C|F|L|W|S|R|Y)(\w?)\s*$/ ) {
630 my $r = $2; 624 my $r = $2;
631 if ($r and $r ne $1) { 625 if ($r and $r ne $1) {
632 print BOLD, RED, ">> command $1$r not defined\n", RESET; 626 print BOLD, RED, ">> command $1$r not defined\n", RESET;
633 next; 627 next;
634 } 628 }
635 $deleteLater = undef; 629 $trashLater = $deleteLater = undef;
636 my $t = $1 eq 'J' ? 'DEEJAY' : 630 my $t = $1 eq 'J' ? 'DEEJAY' :
637 $1 eq 'U' ? 'USE' : 631 $1 eq 'U' ? 'USE' :
638 $1 eq 'K' ? 'KEEP' : 632 $1 eq 'K' ? 'KEEP' :
@@ -640,6 +634,7 @@ X
640 $1 eq 'M' ? 'REMASTER' : 634 $1 eq 'M' ? 'REMASTER' :
641 $1 eq 'V' ? 'VOLATILE' : 635 $1 eq 'V' ? 'VOLATILE' :
642 $1 eq 'X' ? 'EXPORT' : 636 $1 eq 'X' ? 'EXPORT' :
637 $1 eq 'Y' ? 'EASY' :
643 $1 eq 'C' ? 'CRITICIZE' : 638 $1 eq 'C' ? 'CRITICIZE' :
644 $1 eq 'F' ? 'FAVES' : 639 $1 eq 'F' ? 'FAVES' :
645 $1 eq 'W' ? 'WRONG' : 640 $1 eq 'W' ? 'WRONG' :
@@ -649,7 +644,7 @@ X
649 $f = $ENV{PWD}. '/'. $f unless $f =~ m!^/!; 644 $f = $ENV{PWD}. '/'. $f unless $f =~ m!^/!;
650 my $f2 = $f; 645 my $f2 = $f;
651 # the initial (.*) is a hack to make the regexp match the last occurance in the path string rather than earlier ones 646 # the initial (.*) is a hack to make the regexp match the last occurance in the path string rather than earlier ones
652 unless ($f =~ s:^(.*)/(SHARE|T|COMPLETE|KEEP|EDITABLE|FAVES|WRONG|SECONDARY|REPERTOIRE|NEW|SEEK|TODO|USE|DEEJAY|REMASTER|CRITICIZE|INCOMING|incomingDJ|EXPORT|VOLATILE|L8R|CHAOS|DJ|byArtist|byGenre|vol)\d?/:\1/$t/:i) 647 unless ($f =~ s:^(.*)/(SHARE|T|COMPLETE|KEEP|EDITABLE|FAVES|WRONG|SECONDARY|REPERTOIRE|NEW|TODO|USE|DEEJAY|REMASTER|CRITICIZE|EASY|INCOMING|incomingDJ|EXPORT|VOLATILE|L8R|CHAOS|DJ|byArtist|byGenre|vol)\d?/:\1/$t/:i)
653 { 648 {
654 print BOLD, RED, ">> not applicable for $f\n", RESET; 649 print BOLD, RED, ">> not applicable for $f\n", RESET;
655 next; 650 next;
@@ -661,7 +656,7 @@ X
661 } 656 }
662 if ($r) { 657 if ($r) {
663 $moveLater = $f; 658 $moveLater = $f;
664 print BOLD, BLUE, ">> scheduled to move to $t: $f\n", RESET; 659 print BOLD, BLUE, ">> scheduled to move to $t\n", RESET;
665 } else { 660 } else {
666 &moveFile($f); 661 &moveFile($f);
667 &next(0); 662 &next(0);
@@ -671,7 +666,7 @@ X
671 if ( /^\.\s*$/ ) { 666 if ( /^\.\s*$/ ) {
672 print BOLD, BLUE, ">> no longer scheduled to go to $moveLater\n", RESET if $moveLater; 667 print BOLD, BLUE, ">> no longer scheduled to go to $moveLater\n", RESET if $moveLater;
673 print BOLD, BLUE, ">> no longer scheduled for removal\n", RESET if $deleteLater; 668 print BOLD, BLUE, ">> no longer scheduled for removal\n", RESET if $deleteLater;
674 $moveLater = $deleteLater = undef; 669 $trashLater = $moveLater = $deleteLater = undef;
675 next; 670 next;
676 } 671 }
677 #} O 672 #} O
@@ -758,7 +753,7 @@ sub moveFile {
758 print BOLD, RED, ">> could not move asd file to $d\n", RESET; 753 print BOLD, RED, ">> could not move asd file to $d\n", RESET;
759 return; 754 return;
760 } 755 }
761 print BOLD, BLUE, ">> moved to $d\n", RESET; 756 print BOLD, BLUE, ">> moved to $f\n", RESET;
762} 757}
763 758
764sub sleep { 759sub sleep {
@@ -861,7 +856,7 @@ sub duration {
861 if ( $t =~ /(\d*)(:|')(\S+)/ ) { 856 if ( $t =~ /(\d*)(:|')(\S+)/ ) {
862 $t = $1 ? $1*60+$3 : $3; 857 $t = $1 ? $1*60+$3 : $3;
863 } 858 }
864 $DUR = $t * 1000; 859 $DUR = $t;
865 print YELLOW, "[duration is $t secs]\n", RESET unless $opt_q; 860 print YELLOW, "[duration is $t secs]\n", RESET unless $opt_q;
866 return 1; 861 return 1;
867} 862}
@@ -875,7 +870,7 @@ sub jump {
875 if ( $t =~ /(\d*)(:|')(\S*)/ ) { 870 if ( $t =~ /(\d*)(:|')(\S*)/ ) {
876 $t = $1 ? $1*60+$3 : $3; 871 $t = $1 ? $1*60+$3 : $3;
877 } 872 }
878 &gin( "seek ". $t*1000 .' '. $DUR ); 873 &gin( "seek ". $t*1000 .' '. $DUR*1000 );
879 return 1; 874 return 1;
880} 875}
881 876
@@ -1081,7 +1076,12 @@ sub ginparse {
1081#% $TC eq $1 #? X 1076#% $TC eq $1 #? X
1082 $tc == $1 #? !X 1077 $tc == $1 #? !X
1083 ) { 1078 ) {
1084 &seek(87) if $opt_j and $tc == 8; 1079 if ($opt_j) {
1080 # skip to 2/5 of track when 8th sec is reached
1081 &seek(48) if $tc == 8;
1082 # skip to end of track when 66% of track is reached
1083 &seek(96) if $tc == int($DUR*2/3);
1084 }
1085#% $TC = $1; #? X 1085#% $TC = $1; #? X
1086 $tc = $1; #? !X 1086 $tc = $1; #? !X
1087 $TC = time2str('[%T]', $tc, 0); #? !X 1087 $TC = time2str('[%T]', $tc, 0); #? !X
@@ -1102,14 +1102,13 @@ sub ginparse {
1102#% # kludge to get around a bug in xaudio (duration output twice) 1102#% # kludge to get around a bug in xaudio (duration output twice)
1103#% if ($1 != $LDUR) { 1103#% if ($1 != $LDUR) {
1104#% $LDUR = $DUR = $1; 1104#% $LDUR = $DUR = $1;
1105#% $DUR *= 1000 if $DUR < 1000;
1106#% $CDUR += $DUR; # cumulative duration 1105#% $CDUR += $DUR; # cumulative duration
1107#% } 1106#% }
1108#% return 0; 1107#% return 0;
1109#% } 1108#% }
1110#% if (/ stream info \[(.+)\]/) { 1109#% if (/ stream info \[(.+)\]/) {
1111#% %I = split /[=,\s]+/, $1; 1110#% %I = split /[=,\s]+/, $1;
1112#% my $d = $DUR / 1000; 1111#% my $d = $DUR;
1113#% $I{duration} = sprintf("%02d:%02d", $d / 60, $d % 60); 1112#% $I{duration} = sprintf("%02d:%02d", $d / 60, $d % 60);
1114#%# if ($opt_l) { 1113#%# if ($opt_l) {
1115#%# my $f = $file[$order[$CS]]; 1114#%# my $f = $file[$order[$CS]];
@@ -1119,7 +1118,7 @@ sub ginparse {
1119#%# } 1118#%# }
1120#% $I{mode} = lc $I{mode}; 1119#% $I{mode} = lc $I{mode};
1121#% if ($opt_c) { 1120#% if ($opt_c) {
1122#% my $d = $CDUR / 1000; 1121#% my $d = $CDUR;
1123#% $I{cumulative} = sprintf("%02d:%02d", $d / 60, $d % 60); 1122#% $I{cumulative} = sprintf("%02d:%02d", $d / 60, $d % 60);
1124#% &progress("$TC -> [$I{duration}] {$I{cumulative}} $I{bitrate} mp$I{layer}.$I{level} $I{frequency} $I{mode} "); 1123#% &progress("$TC -> [$I{duration}] {$I{cumulative}} $I{bitrate} mp$I{layer}.$I{level} $I{frequency} $I{mode} ");
1125#% } else { 1124#% } else {
@@ -1158,8 +1157,7 @@ sub ginparse {
1158 $CurrentCodec = $codec; 1157 $CurrentCodec = $codec;
1159 $CurrentSize = $size || -s $nf; 1158 $CurrentSize = $size || -s $nf;
1160 if ($CurrentFile ne $nf) { 1159 if ($CurrentFile ne $nf) {
1161 $moveLater = undef; 1160 $trashLater = $deleteLater = $moveLater = undef;
1162 $deleteLater = undef;
1163 $size = undef; 1161 $size = undef;
1164 $codec = undef; 1162 $codec = undef;
1165 } 1163 }
@@ -1218,7 +1216,7 @@ sub ginparse {
1218 and $I{bitrate} and abs($br-$I{bitrate}) > 1; 1216 and $I{bitrate} and abs($br-$I{bitrate}) > 1;
1219 $I{bitrate} = $br if $br; 1217 $I{bitrate} = $br if $br;
1220 $I{duration} = $hh eq '00' ? "$mm:$ss" : "$hh:$mm:$ss"; 1218 $I{duration} = $hh eq '00' ? "$mm:$ss" : "$hh:$mm:$ss";
1221 $DUR = (60*60*$1 + 60*$2 + $3) * 1000; 1219 $DUR = 60*60*$1 + 60*$2 + $3;
1222 $CDUR += $DUR; # cumulative duration 1220 $CDUR += $DUR; # cumulative duration
1223 break; 1221 break;
1224 } 1222 }
@@ -1316,10 +1314,24 @@ sub ginopen {
1316 $output_open = 1; 1314 $output_open = 1;
1317} 1315}
1318 1316
1317sub trash {
1318 if ($trashLater eq $CurrentFile) {
1319 # 'T' deletes song and remembers it in the index of trash media
1320 if (open(HATE, ">>", HATEINDEX)) {
1321 printf HATE "%10d %5s %3s\t%s\r\n",
1322 $CurrentSize, $I{duration}, $I{bitrate}, $CurrentFile;
1323 close HATE;
1324 print RED, ">> marked as trash\n", RESET;
1325 } else {
1326 print BOLD, RED, "*** Failed to write to ", HATEINDEX, ":\n", RESET, $out;
1327 }
1328 }
1329 $trashLater = undef;
1330}
1331
1319sub exit { 1332sub exit {
1320 &ginstop; 1333 &ginstop;
1321 if ($CDUR and not $opt_q) { 1334 if ($CDUR and not $opt_q) {
1322 $CDUR /= 1000;
1323 my $SS = int $CDUR % 60; 1335 my $SS = int $CDUR % 60;
1324 my $M2 = int $CDUR / 60; 1336 my $M2 = int $CDUR / 60;
1325 my $HH = int $M2 / 60; 1337 my $HH = int $M2 / 60;
@@ -1382,7 +1394,7 @@ sub addtolist {
1382 1394
1383sub help { print BOLD, BLACK, &head, RESET, <<X, &sep('='); } 1395sub help { print BOLD, BLACK, &head, RESET, <<X, &sep('='); }
1384 1396
1385basics: (q)uit (h)elp 1397basics: (h)elp, (q)uit, (qq)uit after this song is over
1386 1398
1387motion: (p)lay (s)top pa(u)se 1399motion: (p)lay (s)top pa(u)se
1388 [ (j)ump ] <mm:ss> jump to an absolute point in the song 1400 [ (j)ump ] <mm:ss> jump to an absolute point in the song
@@ -1418,15 +1430,20 @@ Whenever media is in a directory like INCOMING, NEW or TODO, it can be
1418moved into a different subdirectory on the same hierarchy level by using 1430moved into a different subdirectory on the same hierarchy level by using
1419the following uppercase commands: 1431the following uppercase commands:
1420 1432
1433 C = send to CRITICIZE folder
1434 E = send to EDITABLE folder
1421 F = send to FAVES folder 1435 F = send to FAVES folder
1422 J = send to DEEJAY folder 1436 J = send to DEEJAY folder
1423 L = send to L8R
1424 K = send to KEEP 1437 K = send to KEEP
1438 L = send to L8R
1439 M = send to REMASTER
1425 R = send to REPERTOIRE 1440 R = send to REPERTOIRE
1426 S = send to SECONDARY 1441 S = send to SECONDARY
1442 S = send to USE
1427 V = send to VOLATILE 1443 V = send to VOLATILE
1428 W = send to WRONG 1444 W = send to WRONG
1429 X = send to EXPORT 1445 X = send to EXPORT
1446 Y = send to EASY
1430 1447
1431If you prefer to execute the command *after* having finished playing it, 1448If you prefer to execute the command *after* having finished playing it,
1432you can schedule the move for later by doubling the command letter. So 1449you can schedule the move for later by doubling the command letter. So