Exemplo n.º 1
0
        public static void Rename(this DirectoryInfo dir)
        {
            if (dir.Checked())
            {
                return;
            }
            OmdbResult result;
            string     dirName = dir.Name;

            if (DirRegex.ScoreRegex.IsMatch(dir.Name))
            {
                if (!Settings.Config.Settings.Rename)
                {
                    return;
                }
                string score = DirRegex.ScoreRegex.Match(dirName).Groups["v"].Value;
                dirName = dirName.Replace(score, string.Empty).Trim();
            }
            if (dir.Name.Contains("IMDB"))
            {
                string name = DirRegex.YearRegex.Split(dirName)[0].Trim();
                string year = DirRegex.YearRegex.Match(dirName).Groups["v"].Value;
                result = OmdbSearch.Query(name, year);
            }
            else
            {
                if (!GetOmdbResult(dir, out result))
                {
                    return;
                }
            }
            string newFolderName = result.GetDirectoryName();

            Log($"For {dir.Name}, new name = {newFolderName}");
            try
            {
                string newPath = Path.Combine(dir.Parent.FullName, newFolderName);
                dir.MoveTo(newPath);
                result.WritePlotToFile(new DirectoryInfo(newPath));
            }
            catch (Exception e)
            {
                Error(e);
            }
        }
Exemplo n.º 2
0
        public static bool Search(this DirectoryInfo dir, out OmdbResult result)
        {
            result = default(OmdbResult);
            string name;
            string year;

            if (!dir.GetMovieName(out name))
            {
                Error($"Could not get movie name for {dir.Name}");
                return(false);
            }
            bool gotYear = dir.TryGetYear(out year);

            result = gotYear ? OmdbSearch.Query(name, year) : OmdbSearch.Query(name);
            if (result == default(OmdbResult) || Math.Abs(result.Score) < double.Epsilon)
            {
                Error($"Unable to get omdb result for {dir.Name}");
                return(false);
            }
            Log($"For dir {dir.Name} OMDB result = {result} ");
            return(true);
        }
Exemplo n.º 3
0
 public Movie(string name, string year)
 {
     var omdb = OmdbSearch.Query(name, year);
 }