Ejemplo n.º 1
0
 /*
  * The folders within a path are extrected.
  */
 public void processDirectory(string path, int depth, string title)
 {
     try
     {
         dirEntries = Directory.GetDirectories(path);        //Get all folders in path
         foreach (string dir in dirEntries)
         {
             if (depth < 1)
             {
                 processDirectory(dir, 1, RemoveFullPathFromFolder.getFolder(dir));             //Go one directory deeper
             }
             else if (depth == 1)
             {
                 String dire      = RemoveFullPathFromFolder.getFolder(dir);                 //Cut the full path to get the folder name for checking the first character of the folder to know if fansub exists
                 char   firstChar = dire[0];
                 if (firstChar == '[' || firstChar == '(')                                   //Folders which starts with '[' or '(' will be parsed to the corresponding Object
                 {
                     AnimeCreateInterface tmp = (AnimeCreateInterface)HashMap.getInstance().getMap()["WithFansub"];
                     tmp.createAnimeObject(dir, title);
                 }
                 else
                 {
                     AnimeCreateInterface tmp = (AnimeCreateInterface)HashMap.getInstance().getMap()["NoFansub"];
                     tmp.createAnimeObject(dir, title);
                 }
             }
         }
     }
     catch (DirectoryNotFoundException e)
     {
         Console.Write("{0} ", e.Message);
     }
 }
Ejemplo n.º 2
0
    public void createAnimeObject(string path, string title)
    {
        int    episodes = AmountOfEpisodes.getSumOfEpisodes(path);
        string img      = PathOfImage.getPathOfImage(path);

        string[] mediaFiles  = PathOfEpisode.getPathOfEpisode(path);
        string   folder      = RemoveFullPathFromFolder.getFolder(path);
        string   description = Description.readFromFile(Description.getDescription(path));

        char[]   split     = { '[', ']', '(', ')' };
        string[] animeInfo = folder.Split(split);


        title = title.Replace("_", " ");
        List <string> sourceList = new List <string>();
        List <string> voiceList  = new List <string>();
        List <string> subList    = new List <string>();
        List <string> fansubList = new List <string>();


        if (animeInfo.Length == 1)
        {
        }
        else if (animeInfo.Length == 2 || animeInfo.Length == 3)
        {
            sourceList.Add(animeInfo[1]);
        }
        else if (animeInfo.Length == 4 || animeInfo.Length == 5)
        {
            sourceList.Add(animeInfo[1]);
            voiceList.Add(animeInfo[3]);
        }
        else if (animeInfo.Length == 7)
        {
            sourceList.Add(animeInfo[1]);
            voiceList.Add(animeInfo[3]);
            subList.Add(animeInfo[5]);
        }

        if (title.First() == ' ')                           //Check if the first character is a space then remove it
        {
            title = title.Substring(1, title.Count() - 1);
        }

        if (!instance.checkIfAnimeIsAlreadyInTheList(title))
        {
            instance.addAnimeToList(title, episodes, description, fansubList, sourceList, subList, voiceList, img, mediaFiles);
        }
        else
        {
            instance.addSourceToAnime(title, sourceList[0]);
            instance.addVoiceOutputToAnime(title, voiceList);
            instance.addSubToAnime(title, subList);
            instance.addImgPath(title, img);
            instance.addMediaFiles(title, mediaFiles);
        }
    }
Ejemplo n.º 3
0
    public void createAnimeObject(string path, string title)
    {
        int    episodes = AmountOfEpisodes.getSumOfEpisodes(path);
        string img      = PathOfImage.getPathOfImage(path);

        string[] mediaFiles  = PathOfEpisode.getPathOfEpisode(path);
        string   folder      = RemoveFullPathFromFolder.getFolder(path);
        string   description = Description.readFromFile(Description.getDescription(path));


        char[]   split     = { '[', ']', '(', ')' };
        string[] animeInfo = folder.Split(split);                   /*Important! When the seperator is at the beginning then an empty element will be added to the array, furthermore when two seperators are one after
                                                                     * then again an empty element will be added, last but not least when a seperator is at the end then again an empty element will be added to the array */

        List <string> fansubList = new List <string>();

        title = title.Replace("_", " ");
        List <string> voiceOutput = new List <string>();
        List <string> sub         = new List <string>();
        List <string> sourceList  = new List <string>();

        if (animeInfo.Length == 3)
        {
            fansubList.Add(animeInfo[1]);
        }
        else if (animeInfo.Length == 4 || animeInfo.Length == 5)
        {
            fansubList.Add(animeInfo[1]);
            sourceList.Add(animeInfo[3]);
        }
        else if (animeInfo.Length == 6 || animeInfo.Length == 7)
        {
            fansubList.Add(animeInfo[1]);
            sourceList.Add(animeInfo[3]);
            if (animeInfo[5].Contains("Sub"))
            {
                sub.Add(animeInfo[5]);
            }
            else
            {
                voiceOutput.Add(animeInfo[5]);
            }
        }
        else if (animeInfo.Length == 9)
        {
            fansubList.Add(animeInfo[1]);
            sourceList.Add(animeInfo[3]);
            voiceOutput.Add(animeInfo[5]);
            sub.Add(animeInfo[7]);
        }


        if (title.First() == ' ')                       //Check if the first character is a space then remove it
        {
            title = title.Substring(1, title.Count() - 1);
        }

        if (!instance.checkIfAnimeIsAlreadyInTheList(title))                                                    //If the anime is not in the list, then add it as new anime.
        {
            instance.addAnimeToList(title, episodes, description, fansubList, sourceList, sub, voiceOutput, img, mediaFiles);
        }
        else
        {
            instance.addFansubToAnime(title, fansubList.First());                                                               //If the same anime is already in the list, then add parameters like fansub, source, sub, etc. to the anime.
            if (sourceList.Count != 0)
            {
                instance.addSourceToAnime(title, sourceList.First());
            }
            instance.addSubToAnime(title, sub);
            instance.addVoiceOutputToAnime(title, voiceOutput);
            instance.addImgPath(title, img);
            instance.addMediaFiles(title, mediaFiles);
        }
    }