package com.greinet.tvtotalripper;

import java.io.File;

public class TvTotalTagger {
    
    
    
    
    public static void main(String[] args) {
        File folderTvTotal = new File("D:/Users/Andreas/Videos/MySpass/tv-total");
        MetaDataWriter mdw = new MetaDataWriter();
        
        for(File folderSeason:folderTvTotal.listFiles()){
            if(folderSeason.getName().contains("2015")){
            for(File fileEpisode:folderSeason.listFiles()){
                if(fileEpisode.isDirectory()){
                    continue;
                }
                
                String fileName;
                if(fileEpisode.getName().contains("Casting Sp.")){
                    fileName = fileEpisode.getName().replace("Casting Sp. ", "").replace("(", "").replace(")", "");
                }else{
                    fileName = fileEpisode.getName();
                }
                
                try{
                    int episodeNumber = Integer.parseInt(fileName.substring(0, fileName.indexOf("-")).trim());
                    
                    //System.out.println(show +" - "+artist+" - "+title+" - "+episodeNumber);
                    //mdw.writeMetadata(fileEpisode.getAbsolutePath(), title, artist, show, Integer.toString(episodeNumber));
                    
                    File newFile = new File(folderSeason.getAbsoluteFile(),"TV Total s2015e"+episodeNumber+".mp4");
                    System.out.println(fileEpisode.getName() + ":"+newFile.getName());
                    fileEpisode.renameTo(newFile);
                    
                
                }catch(Exception e){
                    System.out.println("ERROR: "+fileEpisode.getName());
                }
            }}
        }
        
        
        /*
        String title = file.getName().substring(file.getName().indexOf("-")+2,file.getName().length()-".mp4".length());
        System.out.println(title);
        
        String episodeNumberString = file.getName().substring(0, file.getName().indexOf("-"));
        int episodeNumber = Integer.parseInt(episodeNumberString.trim());
        System.out.println(episodeNumber);*/
        
    }
    
    
}
