Package Utils

Source Code of Utils.VoUtils

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

package Utils;

import Model.SubTitleLanguage;
import Model.VideoFileVO;
import java.io.File;
import java.util.regex.Pattern;

/**
*
* @author Brunol
*/
public class VoUtils {
   
    public static VideoFileVO fileToMovieVO(File diskFile, SubTitleLanguage subTitleLanguage) {
        String regexTvShow = "(.*)\\.[sS](\\d{2})[eExX](\\d{2,4}).*(xvid|x264|h.264).(.[^\\.]*).*";
        Pattern patternTvShow = Pattern.compile(regexTvShow, Pattern.CASE_INSENSITIVE);

        VideoFileVO videoFileVO = new VideoFileVO();
        videoFileVO.setFileName(diskFile.getName());
        videoFileVO.setPathDir(FileUtils.getPathWithoutFileName(diskFile.getPath()));
        videoFileVO.setHasSubTitle(FileUtils.hasSubTitleFile(videoFileVO.getPathDir(), videoFileVO.getFileName(), subTitleLanguage));
        videoFileVO.setSize(diskFile.length());
        videoFileVO.setFile(diskFile);
        videoFileVO.setIsTvShow(patternTvShow.matcher(videoFileVO.getFileName()).find());
        return videoFileVO;
    }

}
TOP

Related Classes of Utils.VoUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.