"Fossies" - the Fresh Open Source Software Archive

Member "pacpl-code/plugins/kde/PACPL-Konvert" (9 Feb 2021, 2474 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 last Fossies "Diffs" side-by-side code changes report for "PACPL-Konvert": 6.1.0_vs_6.1.2.

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-2019 (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 = "3G2 3GP 8SVX AAC AC3 ADTS AIF AIFF AL AMB AMR APE AU AVR BONK CAF CDR CVU DAT DTS DVMS F32 F64 FAP FLA FLAC FSSD GSRT HCOM IMA IRCAM LA M4A MAT MAT4 MAT5 MAUD MMF MP2 MP3 MP3HD MP4 MPC MPP NIST OFF OFR OFS OGA OGG OPUS PAF PRC PVF RA RAW RF64 RM SD2 SF SHN SMP SND SOU SPX TTA TXW VMS VOC W64 WAV WMA WV";
   28 
   29 # main sub
   30 sub process_files {
   31 
   32  system("kdialog --title 'Ooops...' --error 'Perl Audio Converter Not Installed. Exiting...'") if not `which pacpl`;
   33  exit 1 if not `which pacpl`;
   34 
   35  # sort through input files and discard those with unsupported formats (excluding directories)
   36  foreach (@ARGV) {
   37 
   38           chomp($_);
   39 
   40           $_ = rel2abs($_);
   41           
   42           my $input_ext = `echo \"$_\" | awk -F"." '{print \$NF}'`;
   43           
   44           print "$_ has the ext $input_ext\n" if $debug == 1;
   45                     
   46           if (-f $_ and not `pacpl --formats | grep $input_ext`) 
   47           {
   48              print "$_ has unrecognized extension, skipping...\n" if $debug == 1;
   49              system("kdialog --passivepopup '$name' Unable to convert '$_' (unsupported format)");
   50              next;
   51           }
   52           else 
   53           {             
   54              $input = "$input \"$_\"";
   55           }
   56   }       
   57   
   58   # invoke pacpl and start conversion process
   59   if ($input) {
   60   
   61       my $out_format = `kdialog --title \"$name\" --combobox 'Output Format' $formats`;
   62       chomp($out_format);
   63       
   64       print  "pacpl --to $out_format $input --gui --kde\n" if $debug == 1;
   65       system("pacpl --to $out_format $input --gui --kde");
   66   }
   67   
   68 }
   69 
   70 # start main
   71 process_files();
   72