示例#1
0
        private void checkBoxTVrageLookup_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxTVrageLookup.Checked)
            {
                string result = "ok";
                try
                {
                    toolStripStatusLabel1.Text = "Checking TVrage connection and speed, hold on, this might take a while ...";
                    this.Update();
                    sw.Reset();
                    sw.Start();
                    WebGet tvrageApiInterface = new WebGet("The Walking Dead", "01", "01");
                    tvrageApiInterface.ConsultTVrage("The Walking Dead", "01", "01");
                    result = tvrageApiInterface.webName;
                    sw.Stop();
                    decimal dSeconds = sw.ElapsedMilliseconds / 1000M;
                    if (result != "")
                    {
                        toolStripStatusLabel1.Text = "Managed to get a sane result from TVrage, time for 1 filename is " + dSeconds.ToString() +" seconds.";
                    }
                }
                catch (Exception ex)
                {
                    sw.Stop();
                    if (ex.Message.Contains("could not be resolved"))
                    {
                        MessageBox.Show("No connection to TVrage API, do you have internet connection ? else, TVrage might be down");
                        Logger.logError("Problem opening connection to TVrage: "+ex.Message.ToString(), 4);
                        toolStripStatusLabel1.Text = "Internet Test: Internet Borked";
                    }
                    else if (result == "")
                    {
                        MessageBox.Show("TVrage doesnt give the expected result, might be down");
                        Logger.logError("Bigass problems on the TVrage side", 4);
                        toolStripStatusLabel1.Text = "Internet Test: TVrage Borked";
                    }
                    else
                    {
                        MessageBox.Show("Some unknown problem with internet / starting up the WebGet class see log for details");
                        Logger.logError("Bigass problems, not internet down i guess, anyway, error result: " + ex.Message.ToString(), 4);
                        toolStripStatusLabel1.Text = "Internet Test: Unkown, tool borked ? nah, cant be, must be you !";
                    }
                    checkBoxTVrageLookup.Checked = false;
                }

            }
            if (checkBoxTVrageLookup.Checked == true)
            {
                if (removeEpInfo.Checked == true)
                {
                    removeEpInfo.Checked = false;
                }
            }
            else if (checkBoxTVrageLookup.Checked == false)
            {
                toolStripStatusLabel1.Text = "Not using TVrage lookup then, your call boss";
                if (checkBoxKeepScene.Checked == false)
                {
                    checkBoxKeepScene.Checked = true;
                }
            }
        }
示例#2
0
        private void BackgroundOutput_DoWork(object sender, DoWorkEventArgs e)
        {
            newFileNames.Clear();
            newFileNames.AddRange(fileNames);
            int progress = 0;

            //Mandatory loading of sceneNames and Qualities, for now here, later in some loading method for everything.
            List<string> sceneNames = new List<string>(GetSettings("SceneName"));
            Debug.WriteLine("Loaded: " + sceneNames.Count + " SceneNames");
            Logger.logError("Loaded: " + sceneNames.Count + " SceneNames", 1);
            List<string> sceneQuality = new List<string>(GetSettings("SceneQuality"));
            Debug.WriteLine("Loaded: " + sceneQuality.Count + " SceneQualities");
            Logger.logError("Loaded: " + sceneQuality.Count + " SceneQualities", 1);
            List<string> codecs = new List<string>(GetSettings("Codec"));
            Debug.WriteLine("Loaded: " + sceneQuality.Count + " Codecs");
            Logger.logError("Loaded: " + sceneQuality.Count + " Codecs", 1);
            List<string> showNames = new List<string>(GetSettings("ShowName"));
            Debug.WriteLine("Loaded: " + showNames.Count + " Codecs");
            Logger.logError("Loaded: " + showNames.Count + " CAPS only Show Names", 1);

            SplitEngine fileInfo = new SplitEngine(newFileNames[0]);
            string tempName, tempSeason, tempEpisode, tempEpScene;
            sw.Reset();

            for (int i = 0; i != (newFileNames.Count); i++)
            {
                Logger.logError("Got " + newFileNames[i] + " splitting the filename(s) now", 1);

                //doing the actual splitting
                fileInfo.Split(newFileNames[i]);

                if (fileInfo.Result.Contains("ok") && fileInfo.Result.Length < 3)
                {

                    tempName = (UppercaseFirst(fileInfo.Name));
                    if (checkBoxTVrageLookup.Checked == false)
                    {
                        tempName = CapsShowName(tempName, showNames);
                    }
                    Logger.logError("After split and cleanup, ShowName " + tempName, 1);
                    tempSeason = CorrectSeasonNumbering(fileInfo.Season);
                    Logger.logError("After split and cleanup, Season " + tempSeason, 1);
                    tempEpisode = (CorrectEpisodeNumbering(fileInfo.Ep));
                    Logger.logError("After split and cleanup, Episode " + tempEpisode, 1);

                    //escaping into API lookup before the filename lookup/check
                    if (checkBoxTVrageLookup.Checked == true)
                    {
                        sw.Start();
                        WebGet tvrageApiInterface = new WebGet("tmp", "tmp", "tmp");
                        tvrageApiInterface.ConsultTVrage(tempName, tempSeason, tempEpisode);
                        sw.Stop();
                        if (tvrageApiInterface.webName == "error")
                        {
                            MessageBox.Show("hmmm, timeout on TVrage for " + newFileNames[i] + ", or some other error, doing it manually, no episode lookup");
                            tempEpScene = removeSceneFromEpName(fileInfo.Show, "none", sceneNames, sceneQuality, codecs);
                        }
                        else
                        {
                        tempEpScene = UppercaseFirst(tvrageApiInterface.webName);
                        tempName = UppercaseFirst(tvrageApiInterface.webShow);
                        }

                        if (tempEpScene.Length <= 0)
                        {
                            MessageBox.Show("It seems TVrage doesnt know the episode for " + tempName + "check the log for more information");
                        }
                        else if (tempName.Length <= 0)
                        {
                            MessageBox.Show("It seems TVrage doesnt know the show for " + tempName + "check the log for more information");
                        }

                        if (checkBoxKeepScene.Checked == true)
                        {
                            tempEpScene = tempEpScene + removeSceneFromEpName(fileInfo.Show, tempEpScene, sceneNames, sceneQuality, codecs);
                        }
                        else
                        {
                            tempEpScene = tempEpScene + fileNames[i].Substring(fileNames[i].Length - 3);
                        }

                        ;
                    }
                    else
                    {
                        //tempEpScene = (EpisodeAndScene(fileInfo.Show, sceneNames, sceneQuality, codecs));
                        tempEpScene = removeSceneFromEpName(fileInfo.Show, "none", sceneNames, sceneQuality, codecs);
                    }
                    Logger.logError("After split and cleanup, Epname+Sceneinfo " + tempEpScene, 1);

                    newFileNames[i] = tempName + tempSeason + tempEpisode + tempEpScene;
                }
                else
                {
                    newFileNames[i] = fileInfo.Result;
                    MessageBox.Show("Unable to split " + newFileNames[i] + " keeping origional filename, rename manually");
                }
                //Moving the progress bar
                progress++;
                double dIndex = (double)progress;
                double dTotal = (double)newFileNames.Count;
                double dProgressPercentage = (dIndex / dTotal);
                int iProgressPercentage = (int)(dProgressPercentage * 100);
                BackgroundOutput.ReportProgress(iProgressPercentage, newFileNames[i]);

            }
        }