Ejemplo n.º 1
0
        public SearchInfo findTitle(string ShowName)
        {
            SearchInfo TVShowID = new SearchInfo();

            if (ShowName == null)
            {
                return(TVShowID);
            }

            ShowName = ShowName.Replace("Gold Rush Alaska", "Gold Rush");
            ShowName = ShowName.Replace("Tosh 0", "Tosh.0");
            WebClient client = new WebClient();

            client.DownloadFile("http://epguides.com/common/allshows.txt", folder + "/allshows.txt");
            List <SearchInfo> TVShowList = parseCSV(folder + "/allshows.txt", ShowName);

            if (TVShowList != null && TVShowList.Count > 0)
            {
                if (TVShowList.Count() == 0)
                {
                    return(TVShowID);                                          //return if nothing found
                }
                if (TVShowList.Count() == 1)
                {
                    return(TVShowList[0]);
                }
                else
                {
                    if (selectionList.Count() == 0)
                    {
                        SelectMenu SelectMain = new SelectMenu(TVShowList, ShowName);
                        if (SelectMain.ShowDialog() == DialogResult.OK)
                        {
                            int selectedid = SelectMain.selected;
                            if (selectedid == -1)
                            {
                                return(TVShowID);
                            }
                            selectionList.Add(TVShowList[selectedid]);
                            SearchInfo temp = TVShowList[selectedid];
                            SelectMain.Close();
                            return(temp);
                        }
                    }
                    else
                    {
                        int idNumber = -1;
                        foreach (SearchInfo testIdem in selectionList)
                        {
                            if (testIdem.Title == ShowName)
                            {
                                idNumber = testIdem.SelectedValue;
                                break;
                            }
                        }
                        if (idNumber == -1)
                        {
                            SelectMenu SelectMain = new SelectMenu(TVShowList, ShowName);
                            if (SelectMain.ShowDialog() == DialogResult.OK)
                            {
                                int selectedid = SelectMain.selected;
                                if (selectedid == -1)
                                {
                                    return(TVShowID);
                                }
                                selectionList.Add(TVShowList[selectedid]);
                                SearchInfo temp = TVShowList[selectedid];
                                SelectMain.Close();
                                return(temp);
                            }
                        }
                        else
                        {
                            return(TVShowList[idNumber]);
                        }
                    }
                }
            }
            return(TVShowID);
        }
Ejemplo n.º 2
0
        public SearchInfo findTitle(string ShowName)
        {
            SearchInfo TVShowID = new SearchInfo();

            if (ShowName == null)
            {
                return(TVShowID);
            }
            ShowName = ShowName.Replace("Gold Rush Alaska", "Gold Rush");
            ShowName = ShowName.Replace("Tosh 0", "Tosh.0");
            //ICacheProvider m_cacheProvider = null;
            //TvdbHandler m_tvdbHandler = null;
            List <TvdbSearchResult> list = m_tvdbHandler.SearchSeries(ShowName);

            if (list != null && list.Count > 0)
            {
                List <int>    seriesId   = new List <int>();
                List <string> seriesName = new List <string>();
                for (int i = 0; i < list.Count(); i++)
                {
                    if (list[i].Id != 0)
                    {
                        seriesId.Add(list[i].Id);
                        seriesName.Add(list[i].SeriesName);
                    }
                }
                if (seriesId.Count() == 0)
                {
                    return(TVShowID);                                        //return if nothing found
                }
                int    selectedSeriesId = -1;
                string selectedTitle    = "";
                if (seriesId.Count() == 1)
                {
                    selectedSeriesId = seriesId[0];
                    selectedTitle    = seriesName[0];
                }
                else
                {
                    if (selectionList.Count() == 0)
                    {
                        SelectMenu SelectMain = new SelectMenu(seriesName, ShowName);
                        if (SelectMain.ShowDialog() == DialogResult.OK)
                        {
                            int selectedid = SelectMain.selected;
                            if (selectedid == -1)
                            {
                                return(TVShowID);
                            }
                            selectionList.Add(new SearchInfo(ShowName, selectedid));
                            selectedSeriesId = seriesId[selectedid];
                            selectedTitle    = seriesName[selectedid];
                            SelectMain.Close();
                        }
                    }
                    else
                    {
                        int idNumber = -1;
                        foreach (SearchInfo testIdem in selectionList)
                        {
                            if (testIdem.Title == ShowName)
                            {
                                idNumber = testIdem.SelectedValue;
                                break;
                            }
                        }
                        if (idNumber == -1)
                        {
                            SelectMenu SelectMain2 = new SelectMenu(seriesName, ShowName);
                            if (SelectMain2.ShowDialog() == DialogResult.OK)
                            {
                                int selectedid = SelectMain2.selected;
                                if (selectedid == -1)
                                {
                                    return(TVShowID);
                                }
                                selectionList.Add(new SearchInfo(ShowName, selectedid));
                                selectedSeriesId = seriesId[selectedid];
                                selectedTitle    = seriesName[selectedid];
                                SelectMain2.Close();
                            }
                        }
                        else
                        {
                            selectedSeriesId = seriesId[idNumber];
                        }
                    }
                }

                if (selectedSeriesId == -1)
                {
                    return(TVShowID);                                          //return if nothing is found
                }
                TVShowID.SelectedValue = selectedSeriesId;
                TVShowID.Title         = selectedTitle;
            }
            TVShowID.Title = TVShowID.Title.Replace(":", "").Replace("?", "").Replace("/", "").Replace("<", "").Replace(">", "").Replace("\\", "").Replace("*", "").Replace("|", "").Replace("\"", "");
            return(TVShowID);
        }
Ejemplo n.º 3
0
        public SearchInfo findTitle(string ShowName)
        {
            SearchInfo TVShowID = new SearchInfo();

            if (ShowName == null)
            {
                return(TVShowID);
            }
            ShowName = ShowName.Replace("Gold Rush Alaska", "Gold Rush");
            ShowName = ShowName.Replace("Tosh 0", "Tosh.0");
            List <SearchInfo> FinalList = new List <SearchInfo>();

            XDocument ShowList = XDocument.Load("http://services.tvrage.com/feeds/search.php?show=" + ShowName);

            var Categorys = from Show in ShowList.Descendants("show")
                            select new
            {
                ShowID = Show.Element("showid").Value,
                Name   = Show.Element("name").Value,
            };

            foreach (var wd in Categorys)
            {
                FinalList.Add(new SearchInfo(wd.Name, Int32.Parse(wd.ShowID)));
            }

            if (FinalList != null && FinalList.Count > 0)
            {
                if (FinalList.Count() == 0)
                {
                    return(TVShowID);                                         //return if nothing found
                }
                int    selectedSeriesId = -1;
                string selectedTitle    = "";
                if (FinalList.Count() == 1)
                {
                    selectedSeriesId = FinalList[0].SelectedValue;
                    selectedTitle    = FinalList[0].Title;
                }
                else
                {
                    if (FinalList.Count() != 0)
                    {
                        SelectMenu SelectMain = new SelectMenu(FinalList, ShowName);
                        if (SelectMain.ShowDialog() == DialogResult.OK)
                        {
                            int selectedid = SelectMain.selected;
                            if (selectedid == -1)
                            {
                                return(TVShowID);
                            }
                            selectedSeriesId = FinalList[selectedid].SelectedValue;
                            selectedTitle    = FinalList[selectedid].Title;
                            SelectMain.Close();
                        }
                        else
                        {
                            int idNumber = -1;
                            foreach (SearchInfo testIdem in selectionList)
                            {
                                if (testIdem.Title == ShowName)
                                {
                                    idNumber = testIdem.SelectedValue;
                                    break;
                                }
                            }
                            if (idNumber == -1)
                            {
                                SelectMenu SelectMain2 = new SelectMenu(FinalList, ShowName);
                                if (SelectMain2.ShowDialog() == DialogResult.OK)
                                {
                                    int selectedid = SelectMain2.selected;
                                    if (selectedid == -1)
                                    {
                                        return(TVShowID);
                                    }
                                    selectionList.Add(new SearchInfo(ShowName, selectedid));
                                    selectedSeriesId = FinalList[selectedid].SelectedValue;
                                    selectedTitle    = FinalList[selectedid].Title;
                                    SelectMain2.Close();
                                }
                            }
                            else
                            {
                                selectedSeriesId = FinalList[idNumber].SelectedValue;
                            }
                        }
                    }
                }

                if (selectedSeriesId == -1)
                {
                    return(TVShowID);                                          //return if nothing is found
                }
                TVShowID.SelectedValue = selectedSeriesId;
                TVShowID.Title         = selectedTitle;
            }
            TVShowID.Title = TVShowID.Title.Replace(":", "").Replace("?", "").Replace("/", "").Replace("<", "").Replace(">", "").Replace("\\", "").Replace("*", "").Replace("|", "").Replace("\"", "");
            return(TVShowID);
        }