示例#1
0
        public Episode(string filename)
        {
            // we don't need the full path
            if (filename.Contains("\\"))
            {
                filename = filename.Split('\\').ToList().Last();
            }
            StrafeForm.Log("Processing [" + filename + "]");

            RawShowName = System.IO.Path.GetFileNameWithoutExtension(filename).ToLower();
            string seSubstring = ExtractSE(filename); // eg, S01E01

            if (seSubstring == "")
            {
                StrafeForm.Log("Can't determine season/episode number");
                Error = "Can't determine season/episode number.";
            }
            else
            {
                StrafeForm.Log("Found SE string: \"" + seSubstring + "\"");
                // assume everything before the SE string is the show name
                RawShowName = filename.Substring(0, filename.IndexOf(seSubstring));
            }

            RawShowName = Regex.Replace(RawShowName, @"'", "");    // remove some punctuation
            RawShowName = Regex.Replace(RawShowName, @"\W", " ");  // convert others to spaces
            RawShowName = Regex.Replace(RawShowName, @"\s+", " "); // consolidate white space
            RawShowName = RawShowName.Trim();
            StrafeForm.Log("Raw show name: \"" + RawShowName + "\"");

            /* TODO: whenever TheTVDB starts working and I can log in, provide a switch in Config as to which service to get show info from // https://api.thetvdb.com/swagger
             * for now, we just use TVMaze (which seems to work really well) */

            try {
                TVMaze_Show tvmazeResult = TVMaze.GetShowName(RawShowName);
                TVMazeId = tvmazeResult.TVMazeId;
                ShowName = tvmazeResult.ShowName;
                Year     = tvmazeResult.Year;

                if (Season > 0 || EpisodeNumber > 0)
                {
                    EpisodeName = TVMaze.GetEpisodeName(TVMazeId, Season, EpisodeNumber);
                }
            } catch (TVMazeException tvExc) {
                Error = tvExc.Message;
            }
        }
示例#2
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBoxSearch.Text))
            {
                return;
            }

            comboBoxShow.Items.Clear();
            try {
                List <string> shows = TVMaze.GetShowList(textBoxSearch.Text);
                //foreach (string show in shows) comboBoxShow.Items.Add(new ShowSelectionComboItem(show));
                foreach (ShowSelectionComboItem option in shows.Select(o => new ShowSelectionComboItem(o)).OrderByDescending(o => o.Year))
                {
                    comboBoxShow.Items.Add(option);
                }
            } catch { }

            if (comboBoxShow.Items.Count == 0)
            {
                comboBoxShow.Items.Add(new ShowSelectionComboItem("0,,(No Matches)"));
            }
            comboBoxShow.SelectedItem = comboBoxShow.Items[0];
        }
示例#3
0
        public EpisodeSelectionForm(TVFile tvFile, string previouslySelectedEpisodeName = "")
        {
            InitializeComponent();

            labelFilepath.Text = tvFile.OriginalFile.Name;
            labelShowName.Text = tvFile.Episode.ShowName;

            // get list of episodes and display in combo box
            try {
                List <string> episodeList = TVMaze.GetEpisodeList(tvFile.Episode.TVMazeId);
                episodeList.Reverse(); // let's make the last one first
                foreach (string episodeResult in episodeList)
                {
                    comboBoxEpisodes.Items.Add(new EpisodeSelectionComboItem(episodeResult));
                }
            } catch (TVMazeException tvExc) {
                // something went wrong, couldn't get episodes
            }

            if (comboBoxEpisodes.Items.Count == 0)
            {
                comboBoxEpisodes.Items.Add(new EpisodeSelectionComboItem("-1,-1,(No Episodes)"));
            }
            comboBoxEpisodes.SelectedItem = comboBoxEpisodes.Items[0];

            if (!string.IsNullOrWhiteSpace(previouslySelectedEpisodeName))
            {
                for (int i = 0; i < comboBoxEpisodes.Items.Count - 1; i++)
                {
                    if (((EpisodeSelectionComboItem)comboBoxEpisodes.Items[i]).EpisodeName == previouslySelectedEpisodeName)
                    {
                        comboBoxEpisodes.SelectedItem = comboBoxEpisodes.Items[i + 1];
                        break;
                    }
                }
            }
        }