diff options
author | psyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet> | 2016-08-10 15:28:39 +0000 |
---|---|---|
committer | psyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet> | 2016-08-10 15:28:39 +0000 |
commit | 3532b053f6643bd24536499891a504cb624ad7a7 (patch) | |
tree | a5c875fa6dab31997bf12d03fa6dd0f6316c3d73 /bin/psycamp | |
parent | 94acd94fe15b220b1780eac878f8f3769872e7a1 (diff) | |
download | perlpsyc-3532b053f6643bd24536499891a504cb624ad7a7.tar.gz perlpsyc-3532b053f6643bd24536499891a504cb624ad7a7.zip |
new -j scanning option for psycamp, mpv doesn't work yet
Diffstat (limited to 'bin/psycamp')
-rwxr-xr-x | bin/psycamp | 67 |
1 files changed, 45 insertions, 22 deletions
diff --git a/bin/psycamp b/bin/psycamp index 9c39a1c..1474ac5 100755 --- a/bin/psycamp +++ b/bin/psycamp | |||
@@ -143,7 +143,6 @@ my $screen = 0; | |||
143 | ($TWIDTH, $THEIGHT) = GetTerminalSize(); | 143 | ($TWIDTH, $THEIGHT) = GetTerminalSize(); |
144 | 144 | ||
145 | *name = *File::Find::name; # ugly style works | 145 | *name = *File::Find::name; # ugly style works |
146 | $scan = 0; | ||
147 | my %I; | 146 | my %I; |
148 | my $CDUR = 0; | 147 | my $CDUR = 0; |
149 | 148 | ||
@@ -196,6 +195,7 @@ MAIN: { | |||
196 | #% $wrapper = &which('aoss') || &which('padsp') || ""; | 195 | #% $wrapper = &which('aoss') || &which('padsp') || ""; |
197 | #% print "Using wrapper: $wrapper\n" if $opt_v; | 196 | #% print "Using wrapper: $wrapper\n" if $opt_v; |
198 | #: X | 197 | #: X |
198 | # $has_mpv = &which('mpv'); | ||
199 | print STDERR <<X unless $has_mplayer = &which('mplayer'); | 199 | print STDERR <<X unless $has_mplayer = &which('mplayer'); |
200 | Cannot find mplayer. Cannot play media without it. | 200 | Cannot find mplayer. Cannot play media without it. |
201 | 201 | ||
@@ -334,12 +334,12 @@ sub timeout { | |||
334 | #% #y $trick = 'seek 1 1'; | 334 | #% #y $trick = 'seek 1 1'; |
335 | #%# print " (kicking rxaudio with '$trick')\n" if DEBUG & 32; | 335 | #%# print " (kicking rxaudio with '$trick')\n" if DEBUG & 32; |
336 | #%# &gin( $trick ); | 336 | #%# &gin( $trick ); |
337 | #% print RED, "\n\t\t(kick) ", RESET if DEBUG & 32; | 337 | #% print MAGENTA, "\n\t\t(kick) ", RESET if DEBUG & 32; |
338 | #% &gin('seek 1 1'); #? X | 338 | #% &gin('seek 1 1'); #? X |
339 | #% &gin('seek 0 1'); #? !X | 339 | #% &gin('seek 0 1'); #? !X |
340 | #% &gin('pause'); #? !X | 340 | #% &gin('pause'); #? !X |
341 | #: X | 341 | #: X |
342 | print RED, "\n*** Playback problem. ", RESET, "Skipping $OpenedFile\n"; | 342 | print MAGENTA, "\n*** Playback problem. ", RESET, "Skipping $OpenedFile\n"; |
343 | # so far timeout only happens when the input file is b0rked, so we skip it | 343 | # so far timeout only happens when the input file is b0rked, so we skip it |
344 | &next(0); | 344 | &next(0); |
345 | #} X | 345 | #} X |
@@ -475,7 +475,7 @@ sub open { | |||
475 | &next(0); # hmmmm? | 475 | &next(0); # hmmmm? |
476 | } elsif (! -r $file) { | 476 | } elsif (! -r $file) { |
477 | my $f = &stringtail($file, $TWIDTH-4); | 477 | my $f = &stringtail($file, $TWIDTH-4); |
478 | print RED, "*** $f\n", RESET unless $opt_q; | 478 | print MAGENTA, "*** $f\n", RESET unless $opt_q; |
479 | &next(0); # hmmmm? | 479 | &next(0); # hmmmm? |
480 | } else { | 480 | } else { |
481 | # xaudio does this for us now | 481 | # xaudio does this for us now |
@@ -500,7 +500,6 @@ sub open { | |||
500 | $OpenedFile = $file; | 500 | $OpenedFile = $file; |
501 | $DUR = 0; | 501 | $DUR = 0; |
502 | &sleep(0.3); # have to wait for file to load? | 502 | &sleep(0.3); # have to wait for file to load? |
503 | $scan=0, &seek(5) if $scan; | ||
504 | # &seek(@_) if @_; | 503 | # &seek(@_) if @_; |
505 | # &vol(100); | 504 | # &vol(100); |
506 | } | 505 | } |
@@ -563,7 +562,6 @@ X | |||
563 | &printinfo; | 562 | &printinfo; |
564 | next; | 563 | next; |
565 | } | 564 | } |
566 | next unless /^\w/; | ||
567 | print "> $_\n" if $opt_v and $SCRIPT; | 565 | print "> $_\n" if $opt_v and $SCRIPT; |
568 | 566 | ||
569 | # techniques to seek in media file | 567 | # techniques to seek in media file |
@@ -575,7 +573,6 @@ X | |||
575 | /^skip\s(\w+)$/ and $SKIP=$1, next; | 573 | /^skip\s(\w+)$/ and $SKIP=$1, next; |
576 | # /^open\s+(\S*)\s*\b(\S*)\s*\b(\S*)\s*$/ and &open($1,$2,$3), next; | 574 | # /^open\s+(\S*)\s*\b(\S*)\s*\b(\S*)\s*$/ and &open($1,$2,$3), next; |
577 | /^o\s+(.*)\s*$/ and &open($1), next; | 575 | /^o\s+(.*)\s*$/ and &open($1), next; |
578 | /^scan\s+(.*)\s*$/ and $scan=1, &open($1), next; | ||
579 | /^(n|next)\b\s*(\S*)$/ and &next($2 || .05), next; | 576 | /^(n|next)\b\s*(\S*)$/ and &next($2 || .05), next; |
580 | #{ O | 577 | #{ O |
581 | if ( $ALLOW_DELETE_KEY ) { | 578 | if ( $ALLOW_DELETE_KEY ) { |
@@ -607,7 +604,7 @@ X | |||
607 | next; | 604 | next; |
608 | } | 605 | } |
609 | } | 606 | } |
610 | if ( /^(J|U|K|E|M|V|X|C|S|R)(\w?)\s*$/ ) { | 607 | if ( /^(J|U|K|E|M|V|X|C|F|S|R)(\w?)\s*$/ ) { |
611 | my $r = $2; | 608 | my $r = $2; |
612 | if ($r and $r ne $1) { | 609 | if ($r and $r ne $1) { |
613 | print BOLD, RED, ">> command $1$r not defined\n", RESET; | 610 | print BOLD, RED, ">> command $1$r not defined\n", RESET; |
@@ -622,14 +619,21 @@ X | |||
622 | $1 eq 'V' ? 'VOLATILE' : | 619 | $1 eq 'V' ? 'VOLATILE' : |
623 | $1 eq 'X' ? 'EXPORT' : | 620 | $1 eq 'X' ? 'EXPORT' : |
624 | $1 eq 'C' ? 'CRITICIZE' : | 621 | $1 eq 'C' ? 'CRITICIZE' : |
622 | $1 eq 'F' ? 'FAVES' : | ||
625 | $1 eq 'S' ? 'SECONDARY' : 'REPERTOIRE'; | 623 | $1 eq 'S' ? 'SECONDARY' : 'REPERTOIRE'; |
626 | my $f = $CurrentFile; | 624 | my $f = $CurrentFile; |
627 | $f = $ENV{PWD}. '/'. $f unless $f =~ m!^/!; | 625 | $f = $ENV{PWD}. '/'. $f unless $f =~ m!^/!; |
628 | unless ($f =~ s:\b(SHARE|T|COMPLETE|KEEP|EDITABLE|SECONDARY|REPERTOIRE|NEW|SEEK|TODO|USE|DEEJAY|REMASTER|CRITICIZE|INCOMING|EXPORT|VOLATILE)\b:$t:i) | 626 | my $f2 = $f; |
627 | unless ($f =~ s:\b(SHARE|T|COMPLETE|KEEP|EDITABLE|FAVES|SECONDARY|REPERTOIRE|NEW|SEEK|TODO|USE|DEEJAY|REMASTER|CRITICIZE|INCOMING|EXPORT|VOLATILE|BOMB|FLOW|SPARE|RADIO|BAR|LISTEN|byArtist|byGenre)\d?\b:$t:i) | ||
629 | { | 628 | { |
630 | print BOLD, RED, ">> not applicable for $f\n", RESET; | 629 | print BOLD, RED, ">> not applicable for $f\n", RESET; |
631 | next; | 630 | next; |
632 | } | 631 | } |
632 | if ($f eq $f2) { | ||
633 | print BOLD, BLUE, ">> no longer scheduled to go to $moveLater\n", RESET if $moveLater; | ||
634 | $moveLater = undef; | ||
635 | next; | ||
636 | } | ||
633 | if ($r) { | 637 | if ($r) { |
634 | $moveLater = $f; | 638 | $moveLater = $f; |
635 | print BOLD, BLUE, ">> scheduled to move to $t\n", RESET; | 639 | print BOLD, BLUE, ">> scheduled to move to $t\n", RESET; |
@@ -639,7 +643,14 @@ X | |||
639 | } | 643 | } |
640 | next; | 644 | next; |
641 | } | 645 | } |
646 | if ( /^\.\s*$/ ) { | ||
647 | print BOLD, BLUE, ">> no longer scheduled to go to $moveLater\n", RESET if $moveLater; | ||
648 | print BOLD, BLUE, ">> no longer scheduled for removal\n", RESET if $deleteLater; | ||
649 | $moveLater = $deleteLater = undef; | ||
650 | next; | ||
651 | } | ||
642 | #} O | 652 | #} O |
653 | next unless /^\w/; | ||
643 | # NEW: relative volume changes, only with mplayer | 654 | # NEW: relative volume changes, only with mplayer |
644 | # FIXME: why does it only work with leading v? | 655 | # FIXME: why does it only work with leading v? |
645 | /^v\+\s*$/ and &gin('volume 9'), next; #? !X | 656 | /^v\+\s*$/ and &gin('volume 9'), next; #? !X |
@@ -706,11 +717,16 @@ sub moveFile { | |||
706 | mkpath $d; | 717 | mkpath $d; |
707 | # unless (mkpath($d)) { | 718 | # unless (mkpath($d)) { |
708 | # print ">> could not mkdirhier $d\n"; | 719 | # print ">> could not mkdirhier $d\n"; |
709 | # next; | 720 | # return; |
710 | # } | 721 | # } |
711 | unless (rename ($CurrentFile, $f)) { | 722 | unless (rename ($CurrentFile, $f)) { |
712 | print BOLD, RED, ">> could not move file to $d\n", RESET; | 723 | print BOLD, RED, ">> could not move file to $d\n", RESET; |
713 | next; | 724 | return; |
725 | } | ||
726 | my $asd = $CurrentFile .".asd"; | ||
727 | if (-s $asd and not rename ($CurrentFile, $f .".asd")) { | ||
728 | print BOLD, RED, ">> could not move asd file to $d\n", RESET; | ||
729 | return; | ||
714 | } | 730 | } |
715 | print BOLD, BLUE, ">> moved to $d\n", RESET; | 731 | print BOLD, BLUE, ">> moved to $d\n", RESET; |
716 | } | 732 | } |
@@ -834,9 +850,10 @@ sub jump { | |||
834 | } | 850 | } |
835 | 851 | ||
836 | # if your system doesn't have "which" we're in trouble | 852 | # if your system doesn't have "which" we're in trouble |
853 | # even BSD has which in that place, so it is ok to use full path | ||
837 | sub which { | 854 | sub which { |
838 | my $cmd = shift; | 855 | my $cmd = shift; |
839 | $_ = `which $cmd 2>&1`; | 856 | $_ = `/usr/bin/which $cmd 2>&1`; |
840 | print STDERR "which $cmd: $_" if DEBUG & 1; | 857 | print STDERR "which $cmd: $_" if DEBUG & 1; |
841 | /^(\S+)\s*$/; | 858 | /^(\S+)\s*$/; |
842 | return $1; | 859 | return $1; |
@@ -973,9 +990,12 @@ sub enqueue { | |||
973 | } | 990 | } |
974 | } | 991 | } |
975 | sub wanted { | 992 | sub wanted { |
993 | # 2018: I changed 'lstat' to 'stat' here so that symlinks | ||
994 | # are processed properly. Does it have any side effects? | ||
995 | # | ||
976 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, | 996 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, |
977 | $atime,$mtime,$ctime,$blksize,$blocks) = lstat($_); | 997 | $atime,$mtime,$ctime,$blksize,$blocks) = stat($_); |
978 | my $neat = &stringtail($name, $TWIDTH-7); | 998 | my $neat = &stringtail($name, $TWIDTH-7) unless $opt_q; |
979 | if (-f _ && -r _ && -s _ > 9999 && /\.$FILETYPES$/io) { | 999 | if (-f _ && -r _ && -s _ > 9999 && /\.$FILETYPES$/io) { |
980 | $file[++$NS] = $name; | 1000 | $file[++$NS] = $name; |
981 | $size[$NS] = $size || -s _; | 1001 | $size[$NS] = $size || -s _; |
@@ -986,10 +1006,6 @@ sub wanted { | |||
986 | $prune = 1; | 1006 | $prune = 1; |
987 | &progress('pruned: ', $name); | 1007 | &progress('pruned: ', $name); |
988 | print "\n"; | 1008 | print "\n"; |
989 | # } elsif ( $decode && -f _ && /\bindex\.etx$/i ) { | ||
990 | # open(I, "$decode <$_ |") | ||
991 | # and @index = (@index, <I>) and close I; | ||
992 | # &progress('inf: ', $neat); | ||
993 | } else { | 1009 | } else { |
994 | &progress('no : ', $neat) if -f _; | 1010 | &progress('no : ', $neat) if -f _; |
995 | } | 1011 | } |
@@ -1031,10 +1047,12 @@ sub ginparse { | |||
1031 | #% $TC eq $1 #? X | 1047 | #% $TC eq $1 #? X |
1032 | $tc == $1 #? !X | 1048 | $tc == $1 #? !X |
1033 | ) { | 1049 | ) { |
1050 | &seek(84) if $opt_j and $tc == 8; | ||
1034 | #% $TC = $1; #? X | 1051 | #% $TC = $1; #? X |
1035 | $tc = $1; #? !X | 1052 | $tc = $1; #? !X |
1036 | $TC = time2str('[%T]', $tc, 0); #? !X | 1053 | $TC = time2str('[%T]', $tc, 0); #? !X |
1037 | print BOLD, GREEN, "\r$TC ", RESET unless $opt_q; | 1054 | print BOLD, GREEN, "\r$TC ", RESET unless $opt_q; |
1055 | # $TC then gets used all over the place... | ||
1038 | } | 1056 | } |
1039 | return 0; | 1057 | return 0; |
1040 | } | 1058 | } |
@@ -1160,7 +1178,7 @@ sub ginparse { | |||
1160 | # from the track, not producing a median | 1178 | # from the track, not producing a median |
1161 | # value for VBR tracks. amazing how people | 1179 | # value for VBR tracks. amazing how people |
1162 | # still don't dig VBR after 20 years. | 1180 | # still don't dig VBR after 20 years. |
1163 | print RED, "\rInconsistent bitrate info: ", RESET, | 1181 | print MAGENTA, "\rInconsistent bitrate info: ", RESET, |
1164 | "$I{bitrate} vs $br\n" if $opt_v and $br | 1182 | "$I{bitrate} vs $br\n" if $opt_v and $br |
1165 | and $I{bitrate} and abs($br-$I{bitrate}) > 1; | 1183 | and $I{bitrate} and abs($br-$I{bitrate}) > 1; |
1166 | $I{bitrate} = $br if $br; | 1184 | $I{bitrate} = $br if $br; |
@@ -1221,6 +1239,10 @@ sub ginstart { | |||
1221 | # to allow for fading we want to have the PCM channel, | 1239 | # to allow for fading we want to have the PCM channel, |
1222 | # this works for ALSA - does it fail otherwise? | 1240 | # this works for ALSA - does it fail otherwise? |
1223 | $GINPID = open3( \*W, \*R, \*R, $has_mplayer, '-slave', '-idle', '-v', '-fs', '-zoom', '-screen', $opt_S || $screen, '-mixer-channel', 'PCM' ); | 1241 | $GINPID = open3( \*W, \*R, \*R, $has_mplayer, '-slave', '-idle', '-v', '-fs', '-zoom', '-screen', $opt_S || $screen, '-mixer-channel', 'PCM' ); |
1242 | # my $mpvsock = '/tmp/.mpvsock'; | ||
1243 | # $GINPID = open3( \*WW, \*R, \*R, $has_mpv, "--input-ipc-server=$mpvsock", '--idle=yes', '-v', '--fs=yes', '--no-audio-display', "--screen=".($opt_S || $screen), '--alsa-mixer-name=PCM' ); | ||
1244 | # #open( \*R, '<', $mpvsock ); | ||
1245 | # open( \*W, '>', $mpvsock ); | ||
1224 | R->blocking(0); | 1246 | R->blocking(0); |
1225 | $GINPID || die "$has_mplayer: $!"; | 1247 | $GINPID || die "$has_mplayer: $!"; |
1226 | &ginxpect('^MPlayer'); | 1248 | &ginxpect('^MPlayer'); |
@@ -1351,7 +1373,7 @@ moved into a different subdirectory on the same hierarchy level by using | |||
1351 | the following uppercase commands: | 1373 | the following uppercase commands: |
1352 | 1374 | ||
1353 | J = send to DEEJAY folder | 1375 | J = send to DEEJAY folder |
1354 | U = send to USE | 1376 | F = send to FAVES |
1355 | K = send to KEEP | 1377 | K = send to KEEP |
1356 | X = send to EXPORT | 1378 | X = send to EXPORT |
1357 | S = send to SECONDARY | 1379 | S = send to SECONDARY |
@@ -1362,8 +1384,8 @@ If you prefer to execute the command *after* having finished playing it, | |||
1362 | you can schedule the move for later by doubling the command letter. So | 1384 | you can schedule the move for later by doubling the command letter. So |
1363 | you type 'KK' if you want to keep the file after having listened to it. | 1385 | you type 'KK' if you want to keep the file after having listened to it. |
1364 | You can change your mind while the track is playing - the last command | 1386 | You can change your mind while the track is playing - the last command |
1365 | you schedule is the one that counts. | 1387 | you schedule is the one that counts. You can cancel a scheduled operation |
1366 | The commands for deleting items are similar: | 1388 | using '.' (as in 'leave it here'). The commands for deletion are similar: |
1367 | 1389 | ||
1368 | D = delete the file now | 1390 | D = delete the file now |
1369 | DD = delete the file after having played it | 1391 | DD = delete the file after having played it |
@@ -1408,6 +1430,7 @@ __END__ | |||
1408 | [-c]alculate cumulative duration of selections | 1430 | [-c]alculate cumulative duration of selections |
1409 | [-L]oad the tracks in the playlist only if they really exist | 1431 | [-L]oad the tracks in the playlist only if they really exist |
1410 | [-x] will terminate perl and exec mplayer, use when short on memory | 1432 | [-x] will terminate perl and exec mplayer, use when short on memory |
1433 | [-j]ump to end of track: a way to scan through a playlist | ||
1411 | [-d]elete files after playing if the path contains the word '$VOLATILE'. | 1434 | [-d]elete files after playing if the path contains the word '$VOLATILE'. |
1412 | [-D]elete files after playing unless the path contains the word '$KEEP'. | 1435 | [-D]elete files after playing unless the path contains the word '$KEEP'. |
1413 | 1436 | ||