Пример #1
0
        private void SetMoviesPath()
        {
            getCreateDirectory();
            if (directoryStructureAction != DirectoryStructureAction.CreateDirectoryStructure)
            {
                DestinationPath = "";
                return;
            }

            DestinationPath = Helper.ReadProperty(ConfigKeyConstants.DESTINATION_DIRECTORY_KEY);

            if (!Directory.Exists(DestinationPath))
            {
                DestinationPath = Filepath.goUpwards(FilePath.Path, ExtractedNameLevel);
            }
            if (IsMultiFileMovie)
            {
                DestinationPath = getMoviesDestinationPath(DestinationPath);
            }
            if (DestinationPath != FilePath.Path)
            {
                DestinationPath = DestinationPath;
            }
            else
            {
                DestinationPath = "";
            }
        }
Пример #2
0
        private void SetMoviesPath()
        {
            getCreateDirectory();
            if (createDirectoryStructure != DirectoryStructure.CreateDirectoryStructure)
            {
                Destination = "";
                return;
            }
            string DestinationPath = Helper.ReadProperty(Config.DestinationDirectory);

            if (!Directory.Exists(DestinationPath))
            {
                DestinationPath = Filepath.goUpwards(FilePath.Path, ExtractedNameLevel);
            }
            if (IsMultiFileMovie)
            {
                DestinationPath = getMoviesDestinationPath(DestinationPath);
            }
            if (DestinationPath != FilePath.Path)
            {
                Destination = DestinationPath;
            }
            else
            {
                Destination = "";
            }
        }
Пример #3
0
        public string ExtractSeriesName(InfoEntry ie)
        {
            reset();
            this.ie = ie;
            // Read plain filename
            string filename = System.IO.Path.GetFileNameWithoutExtension(ie.Filename);

            filename = NameCleanup.RemoveReleaseGroupTag(filename);
            folders  = Filepath.extractFoldernamesFromPath(ie.FilePath.Path);
            if (ie.InSeasonFolder && folders.Length > 2)
            {
                if (!Regex.IsMatch(folders[folders.Length - 2], pathBlacklist, RegexOptions.IgnoreCase))
                {
                    return(folders[folders.Length - 2]);
                }
            }
            extractNameFromSeasonsFolder();
            extractNameFromString(filename);
            if (folders.Length != 0)
            {
                extractNameFromString(folders[folders.Length - 1]);
            }
            fallbackFolderNames();
            name = NameCleanup.Postprocessing(name);
            if (name == null)
            {
                return("");
            }
            return(name);
        }
Пример #4
0
 private string getMoviesDestinationPath(string currentDestination)
 {
     string[] folders = Helper.splitFilePath(currentDestination);
     if (folders.Length > 0)
     {
         if (Helper.InitialsMatch(folders[folders.Length - 1], MovieNameWithoutPart()))
         {
             return(currentDestination);
         }
     }
     return(Filepath.goIntoFolder(currentDestination, MovieNameWithoutPart()));
 }
Пример #5
0
        private void initMembers()
        {
            source      = new Filepath();
            destination = new Filepath();

            nameOfSeries  = "";
            nameOfEpisode = "";

            season  = -1;
            episode = -1;

            isVideofile         = false;
            isSubtitle          = false;
            processingRequested = true;
            isMovie             = false;

            umlautUsage = UmlautAction.Unset;
            casing      = Case.Unset;
            createDirectoryStructure = DirectoryStructure.Unset;
            language           = Helper.Languages.None;
            ExtractedNameLevel = 0;
        }
Пример #6
0
        private void initMembers()
        {
            originalPath    = new Filepath();
            destinationPath = new Filepath();

            showname     = "";
            episodeTitle = "";

            seasonNr  = -1;
            episodeNr = -1;

            isVideoFile         = false;
            isSubtitleFile      = false;
            processingRequested = true;
            isMovie             = false;

            umlautAction             = UmlautAction.Unset;
            caseAction               = CaseAction.Unset;
            directoryStructureAction = DirectoryStructureAction.Unset;
            language           = Helper.Languages.None;
            ExtractedNameLevel = 0;
        }
Пример #7
0
        // TODO: function is still tooooooo large
        private void SetSeriesPath()
        {
            if (Season == -1 || Showname == "")
            {
                Destination = "";
                return;
            }
            //string basepath = Helper.ReadProperty(Config.LastDirectory);
            string DestinationPath = Helper.ReadProperty(Config.DestinationDirectory);

            if (!Directory.Exists(DestinationPath))
            {
                DestinationPath = FilePath.Path;
            }
            bool DifferentDestinationPath = FilePath.Path != DestinationPath;
            //for placing files in directory structure, figure out if selected directory is show name, otherwise create one
            bool isNetwork = FilePath.Path.StartsWith("" + Path.DirectorySeparatorChar + Path.DirectorySeparatorChar);

            string[] dirs        = this.source.Folders;
            bool     InSeriesDir = false;
            bool     InSeasonDir = false;
            //any (other) season dir
            bool InASeasonDir     = false;
            bool UseSeasonSubDirs = Helper.ReadBool(Config.UseSeasonSubDir);

            //figure out if we are in a season dir
            string[] seasondirs   = Helper.ReadProperties(Config.Extract);
            string   aSeasondir   = "";
            int      showdirlevel = 0;

            //figure out if we are in an extraction dir, if we are, we need to go upwards one level
            if (dirs.Length > 0 && Filepath.IsExtractionDirectory(dirs[dirs.Length - 1]))
            {
                DestinationPath = Filepath.goUpwards(DestinationPath, 1);
                List <string> blah = new List <string>(dirs);
                blah.RemoveAt(dirs.Length - 1);
                dirs = blah.ToArray();
            }

            //check if we are in a season and/or series directory
            //loop backwards so first season entry is used if nothing is recognized and folder has to be created
            for (int i = seasondirs.Length - 1; i >= 0; i--)
            {
                aSeasondir = RegexConverter.replaceSeriesname(seasondirs[i], nameOfSeries);
                bool InSomething = false;
                if (dirs.Length > 1)
                {
                    Match m = Regex.Match(dirs[dirs.Length - 1], aSeasondir);
                    int   parsedSeason;
                    Int32.TryParse(m.Groups["Season"].Value, out parsedSeason);
                    if (m.Success)
                    {
                        if (parsedSeason == season)
                        {
                            InSeasonDir = true;
                        }
                        InASeasonDir = true;
                        InSomething  = true;
                    }
                }

                //remove dots to avoid problems with series like "N.C.I.S." or "Dr. House"

                /*if (dirs.Length > 0 && dirs[dirs.Length - 1].Replace(".","").StartsWith(nameOfSeries.Replace(".",""))){
                 *  InSeriesDir=true;
                 * }*/
                if (dirs.Length > 0 && Helper.InitialsMatch(dirs[dirs.Length - 1], nameOfSeries))
                {
                    InSeriesDir = true;
                }
                /*else if (dirs.Length > 1 && dirs[dirs.Length - 2].Replace(".", "").StartsWith(nameOfSeries.Replace(".", "")))*/
                else if (dirs.Length > 1 && Helper.InitialsMatch(dirs[dirs.Length - 2], nameOfSeries))
                {
                    InSeriesDir  = true;
                    showdirlevel = 1;
                }
                if (InSomething)
                {
                    break;
                }
            }

            getCreateDirectory();
            if (createDirectoryStructure != DirectoryStructure.CreateDirectoryStructure || !isSeasonValid())
            {
                Destination = "";
                return;
            }
            //if files aren't meant to be moved somewhere else
            if (!DifferentDestinationPath)
            {
                //somewhere else, create new series dir
                if (!InSeriesDir && !InSeasonDir && !InASeasonDir)
                {
                    DestinationPath = addSeriesDir(DestinationPath);
                    DestinationPath = addSeasonsDirIfDesired(DestinationPath);
                }
                //in series dir, create seasons dir
                else if (InSeriesDir && !InASeasonDir)
                {
                    DestinationPath = addSeasonsDirIfDesired(DestinationPath);
                }
                //wrong season dir, add real seasons dir
                else if (InSeriesDir && InASeasonDir && !InSeasonDir)
                {
                    DestinationPath = Filepath.goUpwards(DestinationPath, 1);
                    if (showdirlevel == 0)
                    {
                        DestinationPath = addSeriesDir(DestinationPath);
                    }
                    DestinationPath = addSeasonsDirIfDesired(DestinationPath);
                }
                //wrong show dir, go back two levels and add proper dir structure
                else if (!InSeriesDir && InASeasonDir)
                {
                    DestinationPath = addSeriesDir(Filepath.goUpwards(DestinationPath, 2));
                    DestinationPath = addSeasonsDirIfDesired(DestinationPath);
                }
            }
            //if they should be moved
            else
            {
                DestinationPath = addSeriesDir(DestinationPath);
                DestinationPath = addSeasonsDirIfDesired(DestinationPath);
            }
            if (DestinationPath != FilePath.Path)
            {
                Destination = DestinationPath;
            }
            else
            {
                Destination = "";
            }
        }
Пример #8
0
 private void fallbackFolderNames()
 {
     if (folders.Length == 0)
     {
         return;
     }
     for (int i = 1; i < folders.Length - 1; i++)
     {
         if (!Regex.Match(folders[folders.Length - i], pathBlacklist, RegexOptions.IgnoreCase).Success)
         {
             if (name == null || (Helper.InitialsMatch(folders[folders.Length - 1], name) && !Filepath.IsExtractionDirectory(folders[folders.Length - 1])))
             {
                 name = folders[folders.Length - i];
                 break;
             }
         }
     }
     //Logger.Instance.LogMessage("SNE: fallbackFolderNames: " + name, LogLevel.DEBUG);
 }
Пример #9
0
        //NOTE: Need a feature to detect if the sequel name is already contained within the filename but was found somewhere else(eg directory) and added to the end again, e.g. "Hackers 2 Operation Takedown 2"
        public string ExtractMovieName(InfoEntry ie)
        {
            reset();
            this.ie = ie;
            name    = ie.FilePath.Name;
            folders = new List <string>(Filepath.extractFoldernamesFromPath(ie.FilePath.Path));

            //folderlevels are used to see which directory contains the video name, so we can set ie.extractednamelevel for path creation
            List <int> folderlevels = new List <int>();
            int        origcount    = folders.Count;

            if (Regex.IsMatch(name, filenameBlacklist, RegexOptions.IgnoreCase))
            {
                filenameBlacklisted = true;
                //must be atleast 1 then
                ie.ExtractedNameLevel = 1;
            }

            //Remove all illegal paths
            int j = 0;

            for (int i = 0; i < folders.Count; i++)
            {
                if (Regex.IsMatch(folders[i], pathBlacklist, RegexOptions.IgnoreCase))
                {
                    folders.RemoveAt(i);
                    i--;
                }
                else
                {
                    folderlevels.Add(origcount - j);
                }
                j++;
            }
            if (filenameBlacklisted && folders.Count == 0)
            {
                return("Not Recognized");
            }
            if (!filenameBlacklisted)
            {
                folders.Add(ie.FilePath.Name);
                folderlevels.Add(0);
            }


            //The idea here is to test if the current name might be a better name instead of the previous one
            //We go upwards and try to find part and sequel numbers, as well as movie name. Those might be from different folders, so we need to check all legit ones

            //Clean first name (sequel and part should still be -1
            name = "";
            for (int i = folders.Count - 1; i >= 0; i--)
            {
                string testname   = folders[i];
                int    testpart   = -1;
                int    testsequel = -1;

                //Test for sample
                if (testname.ToLower().Contains("sample"))
                {
                    name = "Sample";
                    return(name);
                }
                testname = NameCleanup.RemoveReleaseGroupTag(testname);

                int firsttag = testname.Length;
                //remove tags and store the first occurence of a tag
                //since we may miss a few tags, the string after the first occurence of a tag is removed later (not now since it may
                //contain additional information). Tags need to be removed before part and sequel detection, to avoid detecting things like 720p
                foreach (string s in MovieTagPatterns)
                {
                    Match m = Regex.Match(testname, s, RegexOptions.IgnoreCase);
                    if (m.Success)
                    {
                        if (m.Index < firsttag)
                        {
                            firsttag = m.Index;
                        }
                        testname = testname.Substring(0, m.Index) + testname.Substring(m.Index + m.Length, testname.Length - (m.Index + m.Length));
                    }
                }

                testpart = ExtractPartNumber(ref testname, ref firsttag);
                if (testpart != -1)
                {
                    ie.IsMultiFileMovie = true;
                }

                testsequel = ExtractSequelNumber(ref testname, ref firsttag);

                //now after recognition of part and sequel numbers, remove the rest too
                testname = testname.Substring(0, firsttag);
                testname = NameCleanup.Postprocessing(testname);

                //Some counterchecks against previous result here
                if (testpart != -1 && part == -1)
                {
                    part = testpart;
                    ie.ExtractedNameLevel = folderlevels[i];
                }
                if (testsequel != -1 && sequelNumber == -1)
                {
                    sequelNumber = testsequel;
                }
                if (name == "" || Helper.InitialsMatch(testname, name))
                {
                    name = testname;
                }
            }

            if (sequelNumber != -1)
            {
                name += " " + sequelNumber;
            }
            if (part != -1)
            {
                name += " CD" + part;
            }
            return(name);
        }
Пример #10
0
        private void initMembers()
        {
            source = new Filepath();
            destination = new Filepath();

            nameOfSeries = "";
            nameOfEpisode = "";

            season = -1;
            episode = -1;

            isVideofile = false;
            isSubtitle = false;
            processingRequested = true;
            isMovie = false;

            umlautUsage = UmlautAction.Unset;
            casing = Case.Unset;
            createDirectoryStructure = DirectoryStructure.Unset;
            language = Helper.Languages.None;
            ExtractedNameLevel = 0;
        }
Пример #11
0
        private void initMembers()
        {
            originalPath = new Filepath();
            destinationPath = new Filepath();

            showname = "";
            episodeTitle = "";

            seasonNr = -1;
            episodeNr = -1;

            isVideoFile = false;
            isSubtitleFile = false;
            processingRequested = true;
            isMovie = false;

            umlautAction = UmlautAction.Unset;
            caseAction = CaseAction.Unset;
            directoryStructureAction = DirectoryStructureAction.Unset;
            language = Helper.Languages.None;
            ExtractedNameLevel = 0;
        }