public static Collection <PartialMatche> Search(string strSearch, LanguageType language) { if (string.IsNullOrEmpty(strSearch) == false) { XElement restResponse = null; Uri strUrl = new Uri(string.Format(@"http://www.thetvdb.com/api/GetSeries.php?seriesname={0}&language={1}", Util.EncodeSearch(strSearch), language.ToString().ToLower())); string rest = Util.GetRest(strUrl); //Fix since version 2.5.5.0 if (string.IsNullOrWhiteSpace(rest) == false) { restResponse = XElement.Parse(rest); } if (restResponse == null) { return(null); } else { return(TVDB.SerieToPartialMatche(restResponse)); } } else { return(null); } }
private static void GetUpdates(TVDB tvdb) { var updates = tvdb.GetUpdates(Interval.Day); Console.WriteLine("Updates during the last 24 hours on thetvdb, since {0}", updates.Timestamp); DisplayUpdates.Print(updates); }
private static void SearchShow(TVDB tvdb) { //KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Service\Recording //Add or edit the String Value – ‘filenaming’ //% Ch – Channel Number //% Cn – Station Name //% T – Title of show //% Et – Episode Title //% Dt – Date and Time Console.WriteLine("Search for Saturday Night Live episode Lame Gretzky on tvdb"); var shows = tvdb.Search("Goldbergs"); foreach (var s in shows) { Console.WriteLine("Show name is: " + s.Name); } foreach (var e in shows[1].Episodes) { Console.WriteLine("Title: " + e.Title); } var episodes = shows[1].Episodes.Where(ep => ep.Title == "Lame Gretzky").ToList(); Console.WriteLine("Season number is: " + episodes[0].SeasonNumber.ToString()); Console.WriteLine("Episode number is: " + episodes[0].EpisodeNumber.ToString()); Console.WriteLine("-----------"); }
private static void GetEpFromTVDBByRecTime(ref RecTV show) { try { var tvdb = new TVDB(apikey); DateTime epRecTime = show.recDateTime; var shows = tvdb.Search(show.title); File.AppendAllText(logPath, "\tFound: \t" + shows.Count + " matching titles. Checking episodes..." + Environment.NewLine); foreach (var s in shows) { var episodes = s.Episodes.Where(ep => ep.FirstAired == epRecTime.Date).ToList(); if (episodes.Count > 0) { show.epName = episodes[0].Title; show.epID = 'S' + episodes[0].SeasonNumber.ToString() + 'E' + episodes[0].EpisodeNumber.ToString(); FormatEpID(ref show); File.AppendAllText(logPath, "\tFound a matching episode name. Taking the first match: " + show.epID + Environment.NewLine); break; } } } catch (Exception ex) { File.AppendAllText(logPath, DateTime.Now.ToString() + ": " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine); Console.WriteLine("Errors occurred. Check the log file at " + logPath); } }
private static void GetEpIDFromTVDB(ref RecTV show) { try { char[] ignoreChars = new char[] { ' ', ';', ',', '\r', '\t', '\n' }; var tvdb = new TVDB(apikey); string epName = show.epName.ToLower(); var shows = tvdb.Search(show.title); File.AppendAllText(logPath, "\tFound: \t" + shows.Count + " matching titles. Checking episodes..." + Environment.NewLine); foreach (var s in shows) { var episodes = s.Episodes.Where(ep => Regex.Replace(ep.Title.ToLower(), "[^0-9a-zA-Z]+", "") == Regex.Replace(epName, "[^0-9a-zA-Z]+", "")).ToList(); if (episodes.Count > 0) { show.epID = 'S' + episodes[0].SeasonNumber.ToString() + 'E' + episodes[0].EpisodeNumber.ToString(); FormatEpID(ref show); File.AppendAllText(logPath, "\tFound a matching episode name. Taking the first match: " + show.epID + Environment.NewLine); break; } } } catch (Exception ex) { File.AppendAllText(logPath, DateTime.Now.ToString() + ": " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine); Console.WriteLine("Errors occurred. Check the log file at " + logPath); } }
public MainWindow() { // If debug is set to true, we first allocate a console, // then we create a listener for Debug.WriteLine so that our debug messages gets printed in the console. if (debug) { AllocConsole(); TextWriterTraceListener writer = new TextWriterTraceListener(System.Console.Out); Debug.Listeners.Add(writer); } InitializeComponent(); Debug.WriteLine(Environment.GetEnvironmentVariable("TEMP")); refreshButton.VerticalAlignment = VerticalAlignment.Bottom; listBox.Height = this.Height - 100; setObj.ReadSettingsFromXml(settingsFilePath); setObj.PropertyChanged += SettingsChanged; fc = new FileController(setObj); tvdb = CreateTVDBObj(); string[] cmdLine = Environment.GetCommandLineArgs(); if (cmdLine.Length > 0) { foreach (var item in cmdLine) { Debug.WriteLine(item); try { if (item == "-r") { Debug.WriteLine("We are here"); // Implement here so that a search is done whenever the argument -r is passed via cmd // Can be used with programs that can run other programs whenever a task is finished newSeriesDirectoriesOrFiles = GetNewSeries(); Debug.WriteLine("1"); ShowNewSeriesMatches(); Debug.WriteLine("2"); MoveSeriesMatches(); Debug.WriteLine("3"); UpdateListbox(listBox1, new List <string>()); UpdateListbox(listBox, new List <string>()); //updateKodiLibrary(); Debug.WriteLine("4"); Application.Current.Shutdown(); } else { continue; } } catch (Exception e) { Utility.LogMessageToFile(e.ToString()); } } } }
public TVDB getNew() { string url = string.Format("https://api.themoviedb.org/3/tv/airing_today?&api_key={0}", apikey); tvdb = JsonConvert.DeserializeObject <TVDB>(ApiCall.ApiGET(url)); return(tvdb); }
/// <summary> /// Gets the cover for the specified show from The TVDB. /// </summary> /// <param name="show">The show to get the cover for.</param> /// <returns> /// URL to the image on TVDB's server. /// </returns> public static string GetCoverFromTVDB(string show) { Log.Debug("Getting cover for " + show + " from TVDB..."); var tvdb = new TVDB(); var res = tvdb.GetID(show).ToList(); if (res.Count != 0) { var guide = tvdb.GetData(res[0].ID); if (!string.IsNullOrWhiteSpace(guide.Cover)) { return(guide.Cover); } else { Log.Debug("TVDB doesn't have a cover associated to " + show + "."); } } else { Log.Debug("No shows were found on TVDB matching " + show + "."); } return(null); }
public ShowController() { _tvdb = new TVDB("86F59A0BFBA75DB4"); membersDb = new MembersRepository(); showInfoDb = new ShowInfoRepository(); episodeInfoDb = new EpisodeInfoRepository(); }
private static void GetSpecificEpisode(TVDB tvdb) { Console.WriteLine("Game of Thrones s04e01"); var episode = tvdb.GetEpisode(4721938); DisplayEpisodeDetails.Print(episode); Console.WriteLine("-----------"); }
private static void GetSpecificShow(TVDB tvdb) { Console.WriteLine("Game of Thrones"); var got = tvdb.GetShow(121361); DisplayShowDetails.Print(got); Console.WriteLine("-----------"); }
private static void SearchShow(TVDB tvdb) { Console.WriteLine("Search for Battlestar Galactica on tvdb"); var searchResults = tvdb.Search("Battlestar Galactica"); DisplaySearchResult.Print(searchResults); Console.WriteLine("-----------"); }
private static void GetEpisodeTitlesForSeason(TVDB tvdb) { Console.WriteLine("Episodes of Game of Thrones season 2"); var show = tvdb.GetShow(121361); var season2Episodes = show.Episodes.Where(ep => ep.SeasonNumber == 2).ToList(); DisplayEpisodeTitles.Print(season2Episodes); Console.WriteLine("-----------"); }
private static List <Artist> GetTvdbArtist(string strId, LanguageType languageType) { try { Uri strUrl = new Uri(string.Format(@"http://www.thetvdb.com/api/{0}/series/{1}/actors.xml", "48CBD9BD208348FB", strId)); //Fix since v2.6.0.0 string ressult = Util.GetRest(strUrl, false); if (string.IsNullOrWhiteSpace(ressult) == false) { XElement restResponse = XElement.Parse(ressult); if (MySettings.FastSearch == false) { if (MySettings.EnableAlloCineSeries == true && MySettings.EnableTMDBMovies == false) { return (TVDB.CastToArtist(restResponse) .Select(item => AlloCineServices.SearchPortrait(item.FulleName, false, languageType)) .ToList()); } else if (MySettings.EnableTMDBMovies == true) { //Fix Since version 2.5.5.0 List <Artist> artistList = new List <Artist>(); IEnumerable <Artist> artists = TVDB.CastToArtist(restResponse); Parallel.ForEach(artists, artist => { Artist newArtist = TheMovieDbServices.SearchPortrait(artist.FulleName, false, languageType); if (newArtist != null) { artistList.Add(newArtist); } }); return(artistList); } else { return(TVDB.CastToArtist(restResponse).ToList()); } } else { return(TVDB.CastToArtist(restResponse).ToList()); } } return(null); } catch (Exception ex) { Util.LogException(ex); return(null); } }
private static async Task GetEpisodeTitlesForSeason(TVDB tvdb) { Console.WriteLine("Episodes of Game of Thrones season 2"); var episodes = await tvdb.GetEpisodes(121361); var season2Episodes = episodes.Where(ep => ep.AiredSeason == 2).ToList(); DisplayEpisodeTitles.Print(season2Episodes); Console.WriteLine("-----------"); }
public MainWindow() { CurrentInstance = this; InitializeComponent(); tvdbhandler = new TVDB("517C3F261F6A0C96"); XdataProvider = (XmlDataProvider)FindResource("Xmldata"); _watchHandler = new WatchHandler(); InitControls(); }
private static async Task GetUpdates(TVDB tvdb) { var beginTime = new DateTime(2019, 12, 10); Console.WriteLine($"Updates in the 7 days since {beginTime}"); var updates = await tvdb.GetUpdates(beginTime); DisplayUpdates.Print(updates.Take(20).ToList()); Console.WriteLine("-----------"); }
private static async Task GetSpecificShow(TVDB tvdb) { Console.WriteLine("Game of Thrones"); var got = await tvdb.GetShow(121361); DisplayShowDetails.Print(got); var eps = await tvdb.GetEpisodes(121361); DisplayEpisodeDetails.Print(eps.First()); Console.WriteLine("-----------"); }
/// <summary> /// Takes in a Series object and returns possible matches from TheTVDB. /// </summary> /// <param name="series"> /// A Series object to look for in the tvdb /// </param> private HashSet <Series> FindMatch(TVDB obj, Series series) { Debug.WriteLine(String.Format("-----Currently in {0}-----", MethodBase.GetCurrentMethod().Name)); HashSet <Series> hs = new HashSet <Series>(new SeriesComparer()); var results = obj.Search(series.Name); if (results.Count == 0) { // If we get no match (probably because of weird additions to the name, we try to match it with currently exisiting folders and use the one with highest score) List <string> dirs = new List <string>(); foreach (var item in setObj.DestinationList) { dirs.AddRange(Directory.GetDirectories(item)); } Tuple <string, double> res = FindBestStringMatch(dirs, series.Name); Debug.WriteLine("Got no match with tvdb"); Debug.WriteLine("Best matching folder already existing"); Debug.WriteLine(res.Item1); Debug.WriteLine(res.Item2); results = obj.Search(res.Item1.Split('\\').Last()); } foreach (var ser in results) { foreach (var episode in ser.Episodes) { if (episode.EpisodeNumber == series.Episode && episode.SeasonNumber == series.Season) { Series s = new Series(ser.Name, episode.SeasonNumber, episode.EpisodeNumber, episode.Title, series.CurrentPath, series.Extension) { GotSubtitle = series.GotSubtitle, SubtitlePath = series.SubtitlePath, DestinationPath = series.DestinationPath }; if (!hs.Contains(s)) { hs.Add(s); } } } } foreach (var item in hs) { Debug.WriteLine(item.Name); } return(hs); }
private void Form1_Load(object sender, EventArgs e) { propertyGridApp.SelectedObject = Settings.Default; if (string.IsNullOrEmpty(Settings.Default.CachePath)) { Settings.Default.CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "TVDB Cache"); } tvdb = new TVDB(Settings.Default.CachePath); tvdb.Debug += new TVDB.StringEventHandler(tvdb_Debug); tvdb.CacheWorking = true; LoadSettings(); tvdb.CheckUpdates(); }
public DisplaySearchResult() { var apikey = ConfigurationManager.AppSettings["apikey"]; // Your own API key var series = "Battlestar Galactica"; var tvdb = new TVDB(apikey); var result = tvdb.Search(series, 3); foreach (var show in result) { Console.WriteLine("{0}:\t{1}", show.Name, show.ID); } Console.ReadKey(); }
public DisplayEpisodeTitlesForSeason() { var apikey = ConfigurationManager.AppSettings["apikey"]; // Your own API key var seriesid = "76290"; var tvdb = new TVDB(apikey); var result = tvdb.GetShow(seriesid).Episodes.Where(x => x.SeasonNumber == 2).ToList(); foreach (var episode in result) { Console.WriteLine(episode.Title); } Console.ReadKey(); }
/// <summary> /// This example demonstrates the retrieval and display of a show. /// </summary> public DisplayShowDetails() { var apikey = ConfigurationManager.AppSettings["apikey"]; // Your own API key var seriesid = "76290"; var tvdb = new TVDB(apikey); var result = tvdb.GetShow(seriesid); Console.WriteLine("{0}:\t{1}", "IMDB ID", result.ImdbID); Console.WriteLine("{0}:\t{1}", "ID", result.ID); Console.WriteLine("{0}:\t{1}", "Language", result.Language); Console.WriteLine("{0}:\t{1}", "Last update", result.LastUpdated); Console.WriteLine("{0}:\t{1}", "Name", result.Name); Console.WriteLine("{0}:\t{1}", "Network", result.Network); Console.WriteLine("{0}:\t{1}", "Poster", result.Poster); Console.WriteLine("{0}:\t{1}", "Rating", result.Rating); Console.WriteLine("{0}:\t{1}", "# Votes", result.RatingCount); Console.WriteLine("{0}:\t{1}", "Runtime", result.Runtime); Console.WriteLine("{0}:\t{1}", "Status", result.Status); Console.WriteLine("{0}:\t{1}", "Zap2it ID", result.Zap2ItID); Console.WriteLine("{0}:\t{1}", "Airday", result.AirDay); Console.WriteLine("{0}:\t{1}", "AirTime", result.AirTime); Console.WriteLine("{0}:\t{1}", "Banner", result.Banner); Console.WriteLine("{0}:\t{1}", "ContentRating", result.ContentRating); Console.WriteLine("{0}:\t{1}", "Description", result.Description); Console.WriteLine("{0}:\t{1}", "Fanart", result.Fanart); Console.WriteLine("{0}:\t{1}", "First aired", result.FirstAired); Console.Write("Actors:\t"); foreach (var element in result.Actors) { Console.Write("{0} | ", element); } Console.Write("Genres:\t"); foreach (var element in result.Genres) { Console.Write("{0} | ", element); } Console.Write("Episodes:"); foreach (var element in result.Episodes) { Console.WriteLine(element.Title); } Console.ReadKey(); }
public static async Task Main(string[] args) { // Your own API key var tvdb = new TVDB("apikey"); // Retrieve and display Game of Thrones await GetSpecificShow(tvdb); // Retrieve and display episode titles for Game of Thrones season 2 await GetEpisodeTitlesForSeason(tvdb); // Search for Battlestar Galactica on tvdb await SearchShow(tvdb); // Get updates of the last 24 hours await GetUpdates(tvdb); Console.ReadKey(); }
private static void GetEpFromTVDBByDesc(ref RecTV show) { try { var tvdb = new TVDB(apikey); string epDesc = show.epDesc.ToLower(); var shows = tvdb.Search(show.title); File.AppendAllText(logPath, "\tFound: \t" + shows.Count + " matching titles. Checking episodes..." + Environment.NewLine); switch (show.title.ToLower()) { case "saturday night live": Regex rgxStart = new Regex("^Host "); epDesc = rgxStart.Replace(epDesc, ""); Regex rgxEnd = new Regex(" performs.$"); epDesc = rgxEnd.Replace(epDesc, ""); Regex rgxEnd2 = new Regex(" hosts and performs.$"); epDesc = rgxEnd2.Replace(epDesc, ""); epDesc = epDesc.Replace("; ", "/"); break; } foreach (var s in shows) { var episodes = s.Episodes.Where(ep => ep.Description.ToLower() == epDesc).ToList(); if (episodes.Count > 0) { show.epName = episodes[0].Title; show.epID = 'S' + episodes[0].SeasonNumber.ToString() + 'E' + episodes[0].EpisodeNumber.ToString(); FormatEpID(ref show); File.AppendAllText(logPath, "\tFound a matching episode name. Taking the first match: " + show.epID + Environment.NewLine); break; } } } catch (Exception ex) { File.AppendAllText(logPath, DateTime.Now.ToString() + ": " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine); Console.WriteLine("Errors occurred. Check the log file at " + logPath); } }
/// <summary> /// Handles the situation when the show's ID is not saved. /// Populates the show possibilites grid with the possible show results so the user can choose the tv show they intended. /// If only one tv show is found with the given name, it is automatically selected and renamed. /// </summary> /// <param name="fvTVShowName">The TV Shows name</param> public void populateShowPossibilitiesList(String fvTVShowName) { _tvDbHandler = new TVDB(); _tvDbHandler.parentErrorCaller = formErrorCaller; List <ShowResultItem> results = _tvDbHandler.searchShowByName(fvTVShowName); if (results.Count == 0) // no results, so return { MessageBox.Show("No TV Show by the name '" + fvTVShowName + "' was found."); return; } // Only 1 tv show resulted from the given name query, so save the ID and choose this tvShow automatically else if (results.Count == 1) { _savedTVShowControl.saveNewTVShow(fvTVShowName, _TVShowName, results[0].ID); renameShow(results[0].ID); } // Multiple tvShows resulted from the given name query, so populate the listView // so the user can choose the tvShow they want else { MainForm.showPossibilities.Items.Clear(); foreach (ShowResultItem result in results) { ListViewItem item = new ListViewItem(result.ShowName); item.SubItems.Add(result.Network); item.SubItems.Add(parseFirstAiredValue(result.FirstAired)); item.Tag = result; MainForm.showPossibilities.Items.Add(item); } // Autosize the column widths to the data just added foreach (ColumnHeader column in MainForm.showPossibilities.Columns) { column.Width = -2; } enableControlVisibility(true); _shouldCloseAfterRename = false; } }
/// <summary> /// This example demonstrates the retrieval and display of an episode. /// </summary> public DisplayEpisodeDetails() { var apikey = ConfigurationManager.AppSettings["apikey"]; // Your own API key var seriesid = "76290"; var tvdb = new TVDB(apikey); var result = tvdb.GetShow(seriesid).Episodes.FirstOrDefault(x => x.EpisodeNumber == 8 && x.SeasonNumber == 2); Console.WriteLine("{0}:\t{1}", "IMDB ID", result.ImdbID); Console.WriteLine("{0}:\t{1}", "ID", result.ID); Console.WriteLine("{0}:\t{1}", "Language", result.Language); Console.WriteLine("{0}:\t{1}", "Last update", result.LastUpdated); Console.WriteLine("{0}:\t{1}", "Title", result.Title); Console.WriteLine("{0}:\t{1}", "Rating", result.Rating); Console.WriteLine("{0}:\t{1}", "# Votes", result.RatingCount); Console.WriteLine("{0}:\t{1}", "Description", result.Description); Console.WriteLine("{0}:\t{1}", "Director", result.Director); Console.WriteLine("{0}:\t{1}", "EpisodeNumber", result.EpisodeNumber); Console.WriteLine("{0}:\t{1}", "SeasonNumber", result.SeasonNumber); Console.WriteLine("{0}:\t{1}", "Filename", result.FileName); Console.WriteLine("{0}:\t{1}", "Series ID", result.SeriesID); Console.WriteLine("{0}:\t{1}", "Season ID", result.SeasonID); Console.WriteLine("{0}:\t{1}", "Thumbnail Height", result.ThumbHeight); Console.WriteLine("{0}:\t{1}", "Thumbnail Width", result.ThumbHeight); Console.Write("Gueststars:\t"); foreach (var element in result.GuestStars) { Console.Write(element); } Console.Write("Writers:\t"); foreach (var element in result.Writers) { Console.Write(element); } Console.ReadKey(); }
public static void Main(string[] args) { // Your own API key var tvdb = new TVDB(ConfigurationManager.AppSettings["apikey"]); // Retrieve and display Game of Thrones //GetSpecificShow(tvdb); // Retrieve and display Game of Thrones s04e01 //GetSpecificEpisode(tvdb); // Retrieve and display episode titles for Game of Thrones season 2 //GetEpisodeTitlesForSeason(tvdb); // Search for Battlestar Galactica on tvdb //SearchShow(tvdb); // Get updates of the last 24 hours GetUpdates(tvdb); Console.ReadKey(); }
/// <summary> /// Queries the TV Show database to get the most up to date episode information of a given show /// and renames the file. /// </summary> /// <param name="fvShowID">The input files Show ID.</param> private void renameShow(int fvShowID) { _tvDbHandler = new TVDB(); // TVDB will handle the TV show query _tvDbHandler.parentErrorCaller = formErrorCaller; Dictionary <String, EpisodeResultItem> episodeResults = _tvDbHandler.getEpisodesFromShowID(fvShowID); // Get all episodes for the given show ID if (episodeResults.Count > 0) { String tvEpisodeKey = "" + getSeasonNumberFrom(_episodeInfo) + getEpisodeNumberFrom(_episodeInfo); // The key to the episode in the dictionary _episodeTitle = episodeResults[tvEpisodeKey].Title; // Save the title of the episode char[] illegalChars = { '<', '>', ':', '"', '/', '\\', '|', '?', '*' }; // Loop through all the illegal filename characters and remove any if present foreach (char c in illegalChars) { _episodeTitle = _episodeTitle.Replace(c.ToString(), ""); } // Save the absolute path to the new filename so it can be renamed String tvAbsolutePathWithFileRenamed = getNewAbsolutePathWithFileRenamed(_absolutePathWithFile.Split('\\'), _TVShowName, _episodeInfo, _episodeTitle, _fileExtension); try { // Try to rename the file File.Move(_absolutePathWithFile, tvAbsolutePathWithFileRenamed); // Show a success notification MainForm.successNotification.ShowBalloonTip(1, "Success", _TVShowName + " " + _episodeInfo + " has been renamed to '" + _episodeTitle + "'", ToolTipIcon.Info); } catch (SystemException e) { // Catch any exception that might have occured MessageBox.Show("Exception occured while renaming file.\n" + "\n" + e); } } enableControlVisibility(false); prepareForNextEpisode(); }
/// <summary> /// Handles the Click event of the searchButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void SearchButtonOnClick(object sender, RoutedEventArgs e) { if (!_loaded || _sidx == database.SelectedIndex) { return; } database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = false; Guide guide; switch (database.SelectedIndex) { case 1: guide = new TVRage(); break; case 2: guide = new TVDB(); break; case 3: guide = new TMDb(); break; case 4: guide = new Freebase(); break; case 5: guide = new TVcom(); break; case 6: guide = new EPisodeWorld(); break; case 7: guide = new IMDb(); break; case 8: guide = new AniDB(); break; case 9: guide = new AnimeNewsNetwork(); break; case 11: guide = new EPGuides(); break; case 12: guide = new EPGuides(); break; default: database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true; return; } new ShowGuideTaskDialog().Search(guide, nameTextBox.Text, (language.SelectedItem as StackPanel).Tag as string, (id, title, lang) => { if (id == null) { Dispatcher.Invoke((Action)(() => { switch (Database.TVShows[_id].Source) { case "TVRage": database.SelectedIndex = 1; break; case "TVDB": database.SelectedIndex = 2; break; case "TMDb": database.SelectedIndex = 3; break; case "Freebase": database.SelectedIndex = 4; break; case "TVcom": database.SelectedIndex = 5; break; case "EPisodeWorld": database.SelectedIndex = 6; break; case "IMDb": database.SelectedIndex = 7; break; case "AniDB": database.SelectedIndex = 8; break; case "AnimeNewsNetwork": database.SelectedIndex = 9; break; case "EPGuides": database.SelectedIndex = 12; break; } database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true; })); TaskDialog.Show(new TaskDialogOptions { MainIcon = VistaTaskDialogIcon.Error, Title = "Not found", MainInstruction = _show, Content = "The currently set show title was not found on the selected guide.\r\nYour selection will be reverted. Try editing the official title.", CustomButtons = new[] { "OK" } }); } else { _newSource = guide.GetType().Name; _newSID = id; _newLang = lang; _change = _upReq = true; Dispatcher.Invoke((Action)(() => { nameTextBox.Text = title; _sidx = database.SelectedIndex; database.IsEnabled = language.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true; })); TaskDialog.Show(new TaskDialogOptions { MainIcon = VistaTaskDialogIcon.Information, Title = "Modified", MainInstruction = _show, Content = "The guide was successfully changed!\r\nAn update will be initiated to this TV show after you click Save.", CustomButtons = new[] { "OK" } }); } }); }
/// <summary> /// Handles the OnSelectionChanged event of the database control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void DatabaseOnSelectionChanged(object sender, RoutedEventArgs e) { if (!_loaded || _sidx == database.SelectedIndex) { return; } Guide guide; switch (database.SelectedIndex) { case 1: guide = new TVRage(); break; case 2: guide = new TVDB(); break; case 3: guide = new TVcom(); break; case 4: guide = new EPisodeWorld(); break; case 5: guide = new IMDb(); break; case 6: guide = new AniDB(); break; case 7: guide = new AnimeNewsNetwork(); break; case 9: guide = new EPGuides(); break; case 10: guide = new EPGuides(); break; default: return; } new ShowGuideTaskDialog().Search(guide, nameTextBox.Text, (language.SelectedItem as StackPanel).Tag as string, (id, title, lang) => { if (id == null) { Dispatcher.Invoke((Action)(() => { switch (Database.TVShows[_id].Source) { case "TVRage": database.SelectedIndex = 1; break; case "TVDB": database.SelectedIndex = 2; break; case "TVcom": database.SelectedIndex = 3; break; case "EPisodeWorld": database.SelectedIndex = 4; break; case "IMDb": database.SelectedIndex = 5; break; case "AniDB": database.SelectedIndex = 6; break; case "AnimeNewsNetwork": database.SelectedIndex = 7; break; case "EPGuides": database.SelectedIndex = 10; break; } })); } else { Database.TVShows[_id].Source = guide.GetType().Name; Database.TVShows[_id].SourceID = id; Database.TVShows[_id].Title = title; Database.TVShows[_id].Language = lang; _upReq = true; Dispatcher.Invoke((Action)(() => { nameTextBox.Text = title; _sidx = database.SelectedIndex; })); } }); }
/// <summary> /// Gets the cover for the specified show from The TVDB. /// </summary> /// <param name="show">The show to get the cover for.</param> /// <returns> /// URL to the image on TVDB's server. /// </returns> public static string GetCoverFromTVDB(string show) { var tvdb = new TVDB(); var res = tvdb.GetID(show).ToList(); if (res.Count != 0) { var guide = tvdb.GetData(res[0].ID); if (!string.IsNullOrWhiteSpace(guide.Cover)) { return guide.Cover; } } return null; }