// Path: src/main/java/com/googlecode/eckoit/util/Slugger.java
// public class Slugger {
// 
//     public static String generateSlug(String text) {
//        return text.replaceAll("[^a-zA-Z0-9]", "_");
//     }
// 
// }


import com.googlecode.eckoit.util.Slugger;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.IOUtils;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.googlecode.eckoit.audio;



/**
 *
 * @author ryan
 */
public class RecordingFinishedHelper {

    File recordingInProgressDir;
    File recordingCompleteDir;
    String ffmpegComand;
    


    public RecordingFinishedHelper(File recordingInProgressDir, File recordingCompleteDir, String ffmpeg) {
        this.recordingInProgressDir = recordingInProgressDir;
        this.recordingCompleteDir = recordingCompleteDir;
        this.ffmpegComand = ffmpeg;

    }

    public File[] recordingFinished(String recordingId) throws FileNotFoundException, IOException {

        String safeId = Slugger.generateSlug(recordingId);
        File parent = new File(recordingInProgressDir, safeId);



        File[] mp3s = findFiles(parent, ".mp3");
        List<File> sortedMp3s = sortFilesNumerically(mp3s);
// Path: src/main/java/com/googlecode/eckoit/util/Slugger.java
// public class Slugger {
// 
//     public static String generateSlug(String text) {
//        return text.replaceAll("[^a-zA-Z0-9]", "_");
//     }
// 
// }


// Path: src/main/java/com/googlecode/eckoit/audio/RecordingFinishedHelper.java
import com.googlecode.eckoit.util.Slugger;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.IOUtils;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.googlecode.eckoit.audio;



/**
 *
 * @author ryan
 */
public class RecordingFinishedHelper {

    File recordingInProgressDir;
    File recordingCompleteDir;
    String ffmpegComand;
    


    public RecordingFinishedHelper(File recordingInProgressDir, File recordingCompleteDir, String ffmpeg) {
        this.recordingInProgressDir = recordingInProgressDir;
        this.recordingCompleteDir = recordingCompleteDir;
        this.ffmpegComand = ffmpeg;

    }

    public File[] recordingFinished(String recordingId) throws FileNotFoundException, IOException {

        String safeId = Slugger.generateSlug(recordingId);
        File parent = new File(recordingInProgressDir, safeId);



        File[] mp3s = findFiles(parent, ".mp3");
        List<File> sortedMp3s = sortFilesNumerically(mp3s);
        File finalMp3_bad = new File(recordingInProgressDir, safeId + ".mp3.tmp");