"Fossies" - the Fresh Open Source Software Archive

Member "pacpl-code/plugins/gnome/thunar/PACPL-Convert" (9 Feb 2021, 2789 Bytes) of package /linux/privat/pacpl-6.1.3.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "PACPL-Convert": 6.1.2_vs_6.1.3.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


    1 #!/usr/bin/perl
    2 #
    3 # Copywrite (C) Philip Lyons 2013-2021 (vorzox@gmail.com)
    4 #
    5 #    This program is free software; you can redistribute it and/or modify
    6 #    it under the terms of the GNU General Public License as published by
    7 #    the Free Software Foundation; either version 3 of the License, or
    8 #    (at your option) any later version.
    9 #
   10 #    This program is distributed in the hope that it will be useful,
   11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 #    GNU General Public License for more details.
   14 #
   15 #    You should have received a copy of the GNU General Public License
   16 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
   17 
   18 use strict;
   19 use warnings;
   20 use File::Spec::Functions qw(rel2abs);
   21 
   22 my $debug = 0;
   23 my $input = '';
   24 
   25 my $name = "Perl Audio Converter";
   26 
   27 my $formats = "FALSE 3G2 FALSE 3GP FALSE 8SVX FALSE AAC FALSE AC3 FALSE ADTS FALSE AIF FALSE AIFF FALSE AL FALSE AMB FALSE AMR FALSE APE FALSE AU FALSE AVR FALSE BONK FALSE CAF FALSE CDR FALSE CVU FALSE DAT FALSE DTS FALSE DVMS FALSE F32 FALSE F64 FALSE FAP FALSE FLA FALSE FLAC FALSE FSSD FALSE GSRT FALSE HCOM FALSE IMA FALSE IRCAM FALSE LA FALSE M4A FALSE MAT FALSE MAT4 FALSE MAT5 FALSE MAUD FALSE MMF FALSE MP2 FALSE MP3 FALSE MP3HD FALSE MP4 FALSE MPC FALSE MPP FALSE NIST FALSE OFF FALSE OFR FALSE OFS FALSE OGA FALSE OGG FALSE OPUS FALSE PAF FALSE PRC FALSE PVF FALSE RA FALSE RAW FALSE RF64 FALSE RM FALSE SD2 FALSE SF FALSE SHN FALSE SMP FALSE SND FALSE SOU FALSE SPX FALSE TTA FALSE TXW FALSE VMS FALSE VOC FALSE W64 FALSE WAV FALSE WMA FALSE WV";
   28 
   29 # main sub
   30 sub process_files {
   31 
   32   # sort through input files and discard those with unsupported formats (excluding directories)
   33   foreach (@ARGV) {
   34 
   35           chomp($_);
   36 
   37           $_ = rel2abs($_);
   38 
   39           my $input_ext = `echo \"$_\" | awk -F"." '{print \$NF}'`;
   40           print "\"$_\" has the ext $input_ext\n" if $debug == 1;
   41           
   42           if (-f $_ and not `pacpl --formats | grep $input_ext`) 
   43           {
   44              print "$_ has unrecognized extension, skipping...\n" if $debug == 1;
   45             `notify-send \"$name\" \"Unable to convert $_ (unsupported format)\"`;
   46              next;
   47           }
   48           else 
   49           {             
   50              $input = "$input \"$_\"";
   51           }
   52   }       
   53   
   54   # invoke pacpl and start conversion process
   55   if ($input) {
   56 
   57       my $out_format = `zenity --title \"$name\" --width 250 --height 300 --list --radiolist --column 'Select' --column 'Output Format' $formats`;
   58     
   59       chomp($out_format);
   60       
   61       print  "pacpl --to $out_format $input --gui --gnome\n" if $debug == 1;
   62       system("pacpl --to $out_format $input --gui --gnome");
   63   }
   64   
   65 }
   66 
   67 # start main
   68 process_files();
   69