void OnSearchResultSelected(GUIListItem item, GUIControl parent) { TorrentMatch selectedmatch = item.AlbumInfoTag as TorrentMatch; Thread backdrop = new Thread(delegate() { if (!string.IsNullOrEmpty(selectedmatch.tvdb)) { TraktShow show = TraktAPI.SeriesOverview(selectedmatch.tvdb); if (!string.IsNullOrEmpty(show.Title)) { GUIPropertyManager.SetProperty("#MyTorrents.Backdrop", show.Images.Fanart); GUIPropertyManager.SetProperty("#MyTorrents.Poster", show.Images.Poster); GUIPropertyManager.SetProperty("#MyTorrents.Title", show.Title); GUIPropertyManager.SetProperty("#MyTorrents.Year", show.Year.ToString()); GUIPropertyManager.SetProperty("#MyTorrents.Summary", show.Overview); GUIPropertyManager.SetProperty("#MyTorrents.Runtime", show.Runtime.ToString()); GUIPropertyManager.SetProperty("#MyTorrents.Certification", show.Certification); GUIPropertyManager.SetProperty("#MyTorrents.Rating", show.Rating); } } else if (!string.IsNullOrEmpty(selectedmatch.imdb)) { TraktMovie movie = TraktAPI.MovieOverview("tt" + Convert.ToInt32(selectedmatch.imdb).ToString("0000000")); if (!string.IsNullOrEmpty(movie.Title)) { GUIPropertyManager.SetProperty("#MyTorrents.Backdrop", movie.Images.Fanart); GUIPropertyManager.SetProperty("#MyTorrents.Poster", movie.Images.Poster); GUIPropertyManager.SetProperty("#MyTorrents.Title", movie.Title); GUIPropertyManager.SetProperty("#MyTorrents.Year", movie.Year); GUIPropertyManager.SetProperty("#MyTorrents.Summary", movie.Overview); GUIPropertyManager.SetProperty("#MyTorrents.Runtime", movie.Runtime.ToString()); GUIPropertyManager.SetProperty("#MyTorrents.Certification", movie.Certification); GUIPropertyManager.SetProperty("#MyTorrents.Rating", movie.Rating); GUIPropertyManager.SetProperty("#MyTorrents.Trailer", movie.Trailer); } } else { GUIPropertyManager.SetProperty("#MyTorrents.Backdrop", ""); GUIPropertyManager.SetProperty("#MyTorrents.Poster", ""); GUIPropertyManager.SetProperty("#MyTorrents.Title", ""); GUIPropertyManager.SetProperty("#MyTorrents.Year", ""); GUIPropertyManager.SetProperty("#MyTorrents.Summary", ""); GUIPropertyManager.SetProperty("#MyTorrents.Runtime", ""); GUIPropertyManager.SetProperty("#MyTorrents.Certification", ""); GUIPropertyManager.SetProperty("#MyTorrents.Rating", ""); } }) { IsBackground = true, Name = "MyTorrent Backdrop Lookup" }; backdrop.Start(); }
public void SearchItemClicked(TorrentMatch match) { GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); dlg.SetHeading("Download this torrent?"); dlg.SetLine(1, match.Title); dlg.SetLine(2, UnitConvert.SizeToString(match.Size)); //dlg.SetLine(3, item.Label3); dlg.DoModal(GUIWindowManager.ActiveWindow); if (!dlg.IsConfirmed) { return; } label = DialogAskLabel.Ask(); if (label == null) { return; } Log.Instance().Print("label is " + label.Name); List <DownloadDir> predefined = TorrentEngine.Instance().TorrentSession.ListDirs(); if (predefined == null) { //MyTorrents.Instance().DisplayError("Unable to connect", "Connection error. Please open your Torrent client before retrying."); //return; } GUIDialogMenu chooser = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (chooser == null) { return; } chooser.Reset(); chooser.SetHeading("Download options"); chooser.Add("No change"); //foreach (DownloadDir dir in predefined) //{ // GUIListItem element = new GUIListItem(); // element.Label = dir.path; // element.Label2 = String.Format("{0} MB Free", Convert.ToString(dir.available)); // chooser.Add(element); //} chooser.Add("Browse Folders"); chooser.DoModal(GUIWindowManager.ActiveWindow); if (chooser.SelectedId == -1) { return; } int selecteddirId = chooser.SelectedId; string selectedText = chooser.SelectedLabelText; Log.Instance().Print("download option is " + selectedText); bool ok = false; // KAT hack string dowOption = ""; if (_searchEngine.GetType() == typeof(TorrentSearch_Combiner)) { Log.Instance().Print("Selected engine is Combiner"); TorrentSearch_Combiner _eng = (TorrentSearch_Combiner)_searchEngine; if (_searchEngine.Parameters.ContainsKey("Options")) { dowOption = _eng.Engines.Where(e => e.Name == match.tracker).First().Parameters["Options"].ToString().Replace("%id%", match.Id); } } else { if (_searchEngine.Parameters.ContainsKey("Options")) { dowOption = _searchEngine.Parameters["Options"].ToString().Replace("%id%", match.Id); } } switch (selectedText) { case "Browse Folders": //FolderBrowser ViewFolders = new FolderBrowser(TorrentEngine.Instance().TorrentSession, label, match, dowOption); Log.Instance().Print("Loading file browser"); MyTorrents.ListType = "FolderBrowser"; MyTorrents.Instance().ShowFolderBrowser(); break; case "No change": if (label != null) { Log.Instance().Print("Starting torrent file downloading"); ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, dowOption, ""); } break; default: if (label != null) { Log.Instance().Print("Starting torrent file downloading"); ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, dowOption, String.Format("&download_dir={0}", selecteddirId - 2)); } break; } /* * if (!ok) * { * GUIDialogNotify notify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); * notify.Reset(); * notify.SetHeading("Failed!"); * notify.SetText("Unable to start download."); * notify.DoModal(GUIWindowManager.ActiveWindow); * * Log.Instance().Print("Downloading failed"); * } * */ }