コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="videoNameText"></param>
        /// <param name="subtitleList"></param>
        /// <returns></returns>
        private string SearchForSubtitle(string videoNameText, List <string> subtitleList, bool ignoretitle)
        {
            foreach (string subName in subtitleList)
            {
                if (subName.Contains(videoNameText.Substring(0, videoNameText.LastIndexOf("."))))
                {
                    return("");
                }
            }

            ArrayList list = Renamer.Splitter(videoNameText);
            //string subName = "";
            string title   = (string)list[0];
            string season  = (string)list[1];
            string episode = (string)list[2];
            string info    = (string)list[3];

            //Renamer.DownloadSubtitle(videoNameText, title, int.Parse(season), int.Parse(episode), info);
            //Console.WriteLine(title);
            //Console.WriteLine("s: " + season + " e: " + episode);

            if (season.Equals("") && episode.Equals(""))
            {
                return("");
            }

            string titleregex = (ignoretitle) ? @".*" : title.Replace(@".", @".*");
            //Console.WriteLine(titleregex);
            Regex titlePattern = new Regex(titleregex);

            foreach (string subName in subtitleList)
            {
                string        tempsubName = subName.ToLower();
                StringBuilder sb;
                //Console.WriteLine(tempsubName);
                if (titlePattern.IsMatch(tempsubName))
                {
                    //s01e02
                    sb = new StringBuilder();
                    sb.Append("s" + season + "e" + episode);
                    if (tempsubName.Contains(sb.ToString()))
                    {
                        return(subName);
                    }

                    //01x02
                    sb = new StringBuilder();
                    sb.Append(season + "x" + episode);
                    if (tempsubName.Contains(sb.ToString()))
                    {
                        return(subName);
                    }

                    //1x02
                    sb = new StringBuilder();
                    sb.Append(season.Substring(1, 1) + "x" + episode);
                    if (tempsubName.Contains(sb.ToString()))
                    {
                        return(subName);
                    }

                    //1302 = s13e02
                    sb = new StringBuilder();
                    sb.Append(season + "" + episode);
                    if (tempsubName.Contains(sb.ToString()))
                    {
                        return(subName);
                    }

                    //102 = s01e02
                    sb = new StringBuilder();
                    sb.Append(season.Substring(1, 1) + "" + episode);
                    if (tempsubName.Contains(sb.ToString()))
                    {
                        return(subName);
                    }
                }
            }
            //no subtitle found
            return("");
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nodes"></param>
        private void Organize(TreeNodeCollection nodes)
        {
            string seriesDirPath = Settings.Default.defaultPath;

            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    DirectoryInfo dir = new DirectoryInfo(node.FullPath);

                    try
                    {
                        foreach (FileInfo fi in dir.GetFiles())
                        {
                            ArrayList list    = Renamer.Splitter(fi.Name);
                            string    title   = (string)list[0];
                            string    season  = (string)list[1];
                            string    episode = (string)list[2];
                            string    info    = (string)list[3];

                            if (season.Equals("") && episode.Equals(""))
                            {
                                continue;
                            }

                            if (SettingsOrganizer.Default.title == "space")
                            {
                                title = Renamer.ConvertDotToSpace(title);
                                info  = Renamer.ConvertDotToSpace(info);
                            }

                            //Console.WriteLine(title);
                            //Console.WriteLine(season);
                            //Console.WriteLine(episode);
                            //Console.WriteLine(info);

                            string newDirName = mintaLabel.Text;

                            newDirName = newDirName.Replace("{sorozatcím}", title);
                            newDirName = newDirName.Replace("{évad}", SettingsOrganizer.Default.season + season);
                            newDirName = newDirName.Replace("{epizód}", SettingsOrganizer.Default.episode + episode);
                            newDirName = newDirName.Replace("{info}", info);
                            //Console.WriteLine(newDirName);
                            //Console.WriteLine(fi.DirectoryName + @"\" + newDirName);
                            DirectoryInfo newDir = new DirectoryInfo(seriesDirPath + @"\" + newDirName);
                            if (!newDir.Exists)
                            {
                                try
                                {
                                    newDir.Create();
                                    File.Move(fi.DirectoryName + @"\" + fi.Name, newDir + @"\" + fi.Name);
                                }
                                catch (IOException)
                                {
                                }
                            }
                        }
                    }
                    catch (IOException e)
                    {
                        MessageBox.Show(dir.Name + " device not ready", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                Organize(node.Nodes);
            }
        }