private void UpdateNews(bool bShowWarning) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); try { if (m_strSiteURL.ToLowerInvariant().StartsWith("http://") == false && m_strSiteURL.ToLowerInvariant().StartsWith("file://") == false) { m_strSiteURL = "http://" + m_strSiteURL; } long startTime = Environment.TickCount; dlgProgress.SetHeading(704); dlgProgress.SetLine(1, GUILocalizeStrings.Get(705) + " " + m_strSiteName); dlgProgress.SetLine(2, ""); dlgProgress.SetLine(3, ""); dlgProgress.ShowProgressBar(false); dlgProgress.StartModal(GetID); dlgProgress.Progress(); Uri newURL = new Uri(m_strSiteURL); Download(newURL); UpdateButtons(); // Leave dialog on screen for minimum of 1 seconds // to eliminate the horrible flash of dialog before user can reed it long endTime = Environment.TickCount; if (endTime - startTime < 1000) { Thread.Sleep((int)(1000 - (endTime - startTime))); } dlgProgress.Close(); } catch (Exception e) { dlgProgress.Close(); if (bShowWarning) { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SHOW_WARNING, 0, 0, 0, 0, 0, 0); msg.Param1 = 9; //my news msg.Param2 = 912; //Unable to download latest news msg.Param3 = 0; msg.Label3 = m_strSiteURL; GUIWindowManager.SendMessage(msg); Log.Error(e); } } }
public bool OnDetailsEnd(IMDBFetcher fetcher) { GUIDialogProgress pDlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if ((pDlgProgress != null) && (pDlgProgress.IsInstance(fetcher))) { pDlgProgress.Close(); } return(true); }
void closeProgDialog() { if (dlgPrgrs != null) { dlgPrgrs.Close(); dlgPrgrs.Dispose(); dlgPrgrs = null; } else { GUIWaitCursor.Hide(); } }
private void UpdateSearchResults() { try { SearchResults.Clear(); } catch (Exception ex) { } IconMapping iconMapping = Configuration.Instance().Settings["MyTorrents.GlobalIconMapping"] as IconMapping; Regex re = null; if (_filter != "") { re = new Regex(_filter, RegexOptions.IgnoreCase); } foreach (TorrentMatch match in _matches) { if (re != null) { if (!re.IsMatch(match.Title)) { continue; } } GUIListItem item = new GUIListItem(); //item.PinImage = iconMapping.GetIcon(match.Title); item.PinImage = match.Icon; item.Label = String.Format("{0}- {1} - {2} ({3}:{4})", match.Category, match.SubCategory, match.Title, match.Seed, match.Leech); item.Label2 = match.Date.ToShortDateString(); item.Label3 = UnitConvert.SizeToString(match.Size); item.OnItemSelected += OnSearchResultSelected; item.AlbumInfoTag = match; SearchResults.Add(item); } GUIDialogProgress dlg = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); dlg.Close(); _progressDlg = null; GUIPropertyManager.SetProperty("#MyTorrents.Count", String.Format("{0}", SearchResults.Count)); }
void VideoDownloader_DownloadComplete(object sender, EventArgs e) { GUIDialogNotify dlg1 = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlg1 != null) { dlg1.Reset(); dlg1.SetHeading("Download done"); dlg1.SetText(VideoDownloader.DownloadingTo); dlg1.Reset(); dlg1.TimeOut = 5; dlg1.DoModal(GetID); } Youtube2MP._settings.LocalFile.Items.Add(new LocalFileStruct(VideoDownloader.DownloadingTo, VideoDownloader.Entry.VideoId, VideoDownloader.Entry.Title.Text)); Youtube2MP._settings.LocalFile.Save(); string imageFile = GetLocalImageFileName(GetBestUrl(VideoDownloader.Entry.Media.Thumbnails)); try { if (File.Exists(imageFile)) { File.Copy(imageFile, Path.GetDirectoryName(VideoDownloader.DownloadingTo) + "\\" + Path.GetFileNameWithoutExtension(VideoDownloader.DownloadingTo) + ".png"); } } catch { } if (dlgProgress != null) { dlgProgress.SetPercentage(100); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); dlgProgress.Close(); dlgProgress = null; } }
void filtersCreator_DoWork(object sender, DoWorkEventArgs e) { GUIDialogProgress progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); progressDialog.Reset(); progressDialog.ShowWaitCursor = true; progressDialog.SetHeading(Translation.CreatingFilters); progressDialog.Percentage = 0; progressDialog.SetLine(1, string.Empty); progressDialog.SetLine(2, string.Empty); progressDialog.StartModal(this.GetID); GUIWindowManager.Process(); TraktHandlers.MovingPictures.CreateMovingPicturesFilters(); progressDialog.SetHeading(Translation.UpdatingFilters); GUIWindowManager.Process(); TraktHandlers.MovingPictures.UpdateMovingPicturesFilters(); progressDialog.ShowWaitCursor = false; progressDialog.Close(); GUIWindowManager.Process(); }
void ShowOptionsForSite(OnlineVideosWebservice.Site site) { SiteSettings localSite = null; int localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(site.Name, out localSite); GUIDialogMenu dlgSel = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlgSel.ShowQuickNumbers = false; if (dlgSel != null) { dlgSel.Reset(); dlgSel.SetHeading(Translation.Instance.Actions); if (localSiteIndex == -1) { if (site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.AddToMySites); } } else { if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 2 && site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.UpdateMySite); dlgSel.Add(Translation.Instance.UpdateMySiteSkipCategories); } dlgSel.Add(Translation.Instance.RemoveFromMySites); } if (GUI_infoList.Count > 1) { dlgSel.Add(Translation.Instance.RemoveAllFromMySites); dlgSel.Add(Translation.Instance.UpdateAll); dlgSel.Add(Translation.Instance.UpdateAllSkipCategories); } if (!string.IsNullOrEmpty(site.Owner_FK) && localSiteIndex >= 0) // !only local && ! only global { dlgSel.Add(Translation.Instance.ShowReports); if (site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.ReportBroken); } } } dlgSel.DoModal(GUIWindowManager.ActiveWindow); if (dlgSel.SelectedId == -1) { return; // ESC used, nothing selected } if (dlgSel.SelectedLabelText == Translation.Instance.AddToMySites || dlgSel.SelectedLabelText == Translation.Instance.UpdateMySite || dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories) { if (CheckOnlineVideosVersion()) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback( () => { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites(null, new List <OnlineVideosWebservice.Site> { site }, false, dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories); if (updateResult == true) { newDllsDownloaded = true; } else if (updateResult == null) { newDataSaved = true; } return(updateResult != false); }, (success, result) => { if (success && (bool)result) { SiteImageExistenceCache.UnCacheImageForSite(site.Name); RefreshDisplayedOnlineSites(); } }, Translation.Instance.GettingSiteXml, true); } } else if (dlgSel.SelectedLabelText == Translation.Instance.UpdateAll || dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories) { if (CheckOnlineVideosVersion()) { GUIDialogProgress dlgPrgrs = PrepareProgressDialog(Translation.Instance.FullUpdate); new System.Threading.Thread(delegate() { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) => { if (dlgPrgrs != null) { if (!string.IsNullOrEmpty(m)) { dlgPrgrs.SetLine(1, m); } if (p != null) { dlgPrgrs.SetPercentage(p.Value); } return(dlgPrgrs.ShouldRenderLayer()); } else { return(true); } }, GUI_infoList.ListItems.Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList(), dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories); if (updateResult == true) { newDllsDownloaded = true; } else if (updateResult == null) { newDataSaved = true; } if (updateResult != false) { SiteImageExistenceCache.ClearCache(); } if (dlgPrgrs != null) { dlgPrgrs.Close(); } GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { RefreshDisplayedOnlineSites(); return(0); }, 0, 0, null); }) { Name = "OVSelectUpdate", IsBackground = true }.Start(); } } else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveFromMySites) { OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex); OnlineVideoSettings.Instance.SaveSites(); newDataSaved = true; RefreshDisplayedOnlineSites(GUI_infoList.SelectedListItemIndex); } else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveAllFromMySites) { bool needRefresh = false; foreach (var siteToRemove in GUI_infoList.ListItems.Where(g => g.IsPlayed).Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList()) { localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(siteToRemove.Name, out localSite); if (localSiteIndex >= 0) { OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex); needRefresh = true; } } if (needRefresh) { OnlineVideoSettings.Instance.SaveSites(); newDataSaved = true; RefreshDisplayedOnlineSites(); } } else if (dlgSel.SelectedLabelText == Translation.Instance.ShowReports) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback( () => { OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService(); return(ws.GetReports(site.Name)); }, (success, result) => { if (success) { OnlineVideosWebservice.Report[] reports = result as OnlineVideosWebservice.Report[]; if (reports == null || reports.Length == 0) { GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlg != null) { dlg.Reset(); dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon")); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetText(Translation.Instance.NoReportsForSite); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { selectedSite = site.Name; GUIControl.ClearControl(GetID, GUI_infoList.GetID); Array.Sort(reports, new Comparison <OnlineVideosWebservice.Report>(delegate(OnlineVideosWebservice.Report a, OnlineVideosWebservice.Report b) { return(b.Date.CompareTo(a.Date)); })); foreach (OnlineVideosWebservice.Report report in reports) { string shortMsg = report.Message.Replace(Environment.NewLine, " ").Replace("\n", " ").Replace("\r", " "); GUIListItem loListItem = new GUIListItem(shortMsg.Length > 44 ? shortMsg.Substring(0, 40) + " ..." : shortMsg); loListItem.TVTag = report; loListItem.Label2 = report.Type.ToString(); loListItem.Label3 = report.Date.ToString("g", OnlineVideoSettings.Instance.Locale); loListItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(OnReportSelected); GUI_infoList.Add(loListItem); } GUIControl.SelectItemControl(GetID, GUI_infoList.GetID, 0); GUIPropertyManager.SetProperty("#itemcount", GUI_infoList.Count.ToString()); GUIPropertyManager.SetProperty("#itemtype", Translation.Instance.Reports); } } }, Translation.Instance.GettingReports, true); } else if (dlgSel.SelectedLabelText == Translation.Instance.ReportBroken) { if (CheckOnlineVideosVersion()) { if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 1) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(site.Name); dlg.SetLine(1, Translation.Instance.PleaseUpdateLocalSite); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { string userReason = ""; if (GUIOnlineVideos.GetUserInputString(ref userReason, false)) { if (userReason.Length < 15) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, Translation.Instance.PleaseEnterDescription); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService(); string message = ""; bool success = ws.SubmitReport(site.Name, userReason, OnlineVideosWebservice.ReportType.Broken, out message); GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, success ? Translation.Instance.Done : Translation.Instance.Error); dlg.SetLine(2, message); dlg.DoModal(GUIWindowManager.ActiveWindow); } if (success) { // reload online sites OnlineVideos.Sites.Updater.GetRemoteOverviews(true); RefreshDisplayedOnlineSites(); } } } } } } }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (Gui2UtilConnector.Instance.IsBusy) { return; // wait for any background action e.g. online sites retrieval to finish } if (control == GUI_btnSort) { GUIControl.SelectItemControl(GetID, GUI_btnSort.GetID, GUI_btnSort.SelectedItem); RefreshDisplayedOnlineSites(); } else if (control == GUI_btnFilterState) { GUIControl.SelectItemControl(GetID, GUI_btnFilterState.GetID, GUI_btnFilterState.SelectedItem); RefreshDisplayedOnlineSites(); } else if (control == GUI_btnFilterCreator) { GUIControl.SelectItemControl(GetID, GUI_btnFilterCreator.GetID, GUI_btnFilterCreator.SelectedItem); RefreshDisplayedOnlineSites(); } else if (control == GUI_btnFilterLang) { GUIControl.SelectItemControl(GetID, GUI_btnFilterLang.GetID, GUI_btnFilterLang.SelectedItem); RefreshDisplayedOnlineSites(); } else if (control == GUI_infoList && actionType == Action.ActionType.ACTION_SELECT_ITEM) { if (GUI_infoList.SelectedListItem.TVTag is OnlineVideosWebservice.Site) { ShowOptionsForSite(GUI_infoList.SelectedListItem.TVTag as OnlineVideosWebservice.Site); } } else if (control == GUI_btnAutoUpdate) { if (CheckOnlineVideosVersion()) { Log.Instance.Info("SiteManager: Running AutoUpdate"); GUIDialogProgress dlgPrgrs = PrepareProgressDialog(Translation.Instance.AutomaticUpdate); new System.Threading.Thread(delegate() { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) => { if (dlgPrgrs != null) { if (!string.IsNullOrEmpty(m)) { dlgPrgrs.SetLine(1, m); } if (p != null) { dlgPrgrs.SetPercentage(p.Value); } return(dlgPrgrs.ShouldRenderLayer()); } else { return(true); } }); if (updateResult == true) { newDllsDownloaded = true; } else if (updateResult == null) { newDataSaved = true; } if (updateResult != false) { SiteImageExistenceCache.ClearCache(); } if (dlgPrgrs != null) { dlgPrgrs.Close(); } GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { RefreshDisplayedOnlineSites(); return(0); }, 0, 0, null); }) { Name = "OVAutoUpdate", IsBackground = true }.Start(); } } base.OnClicked(controlId, control, actionType); }
public List <string> deleteSeason(TVSeriesPlugin.DeleteMenuItems type) { List <string> resultMsg = new List <string>(); // Always delete from Local episode table if deleting from disk or database SQLCondition condition = new SQLCondition(); condition.Add(new DBEpisode(), DBEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBEpisode(), DBEpisode.cSeasonIndex, this[DBSeason.cIndex], SQLConditionType.Equal); /* TODO will include hidden episodes as hidden attribute is only in onlineepisodes. maybe we should include it in localepisodes also.. * if hidden episodes are excluded then the if (resultMsg.Count is wrong and should do another select to get proper count * if (!DBOption.GetOptions(DBOption.cShowHiddenItems)) * { * //don't include hidden seasons unless the ShowHiddenItems option is set * condition.Add(new DBEpisode(), idden, 0, SQLConditionType.Equal); * } */ List <DBEpisode> episodes = DBEpisode.Get(condition, false); if (episodes != null) { bool hasLocalEpisodesToDelete = episodes.Exists(e => !string.IsNullOrEmpty(e[DBEpisode.cFilename])); hasLocalEpisodesToDelete &= (type == TVSeriesPlugin.DeleteMenuItems.disk || type == TVSeriesPlugin.DeleteMenuItems.diskdatabase); DBSeries series = Helper.getCorrespondingSeries(this[DBSeason.cSeriesID]); string seriesName = series == null ? this[DBSeason.cSeriesID].ToString() : series.ToString(); // show progress dialog as this can be a long process esp for network drives // will show new progress for each season if deleting from the series level GUIDialogProgress progressDialog = null; if (!Settings.isConfig) { progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); progressDialog.Reset(); progressDialog.DisplayProgressBar = true; progressDialog.ShowWaitCursor = false; progressDialog.DisableCancel(true); progressDialog.SetHeading(Translation.Delete); progressDialog.Percentage = 0; progressDialog.SetLine(1, string.Format("{0} {1} {2}", seriesName, Translation.Season, this[DBSeason.cIndex])); progressDialog.SetLine(2, string.Empty); // only show progress dialog if we have local files in season if (hasLocalEpisodesToDelete) { progressDialog.StartModal(GUIWindowManager.ActiveWindow); } } int counter = 0; foreach (DBEpisode episode in episodes) { string episodeName = string.Format("{0}x{1} - {2}", episode[DBOnlineEpisode.cSeasonIndex], episode[DBOnlineEpisode.cEpisodeIndex], episode[DBOnlineEpisode.cEpisodeName]); if (!Settings.isConfig) { progressDialog.SetLine(2, episodeName); } if (!Settings.isConfig) { GUIWindowManager.Process(); } resultMsg.AddRange(episode.deleteEpisode(type, true)); if (!Settings.isConfig) { progressDialog.Percentage = Convert.ToInt32(((double)++counter / (double)episodes.Count) * 100.0); } if (!Settings.isConfig) { GUIWindowManager.Process(); } } // close progress dialog if (!Settings.isConfig) { progressDialog.Close(); } // if we have removed all episodes in season without error, cleanup the online table if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.disk) { condition = new SQLCondition(); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeasonIndex, this[DBSeason.cIndex], SQLConditionType.Equal); DBOnlineEpisode.Clear(condition); } } #region Facade Remote Color // if we were successful at deleting all episodes of season from disk, set HasLocalFiles to false // note: we only do this if the database entries still exist if (resultMsg.Count == 0 && type == TVSeriesPlugin.DeleteMenuItems.disk) { this[cHasLocalFiles] = false; this.Commit(); } // if we were successful at deleting all episodes of season from disk, // also check if any local episodes exist on disk for series and set HasLocalFiles to false if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.database) { // Check Series for Local Files SQLCondition episodeConditions = new SQLCondition(); episodeConditions.Add(new DBEpisode(), DBEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); List <DBEpisode> localEpisodes = DBEpisode.Get(episodeConditions); if (localEpisodes.Count == 0 && !DBSeries.IsSeriesRemoved) { DBSeries series = DBSeries.Get(this[DBSeason.cSeriesID]); if (series != null) { series[DBOnlineSeries.cHasLocalFiles] = false; series.Commit(); } } } #endregion #region Cleanup // if there are no error messages and if we need to delete from db if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.disk) { condition = new SQLCondition(); condition.Add(new DBSeason(), DBSeason.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBSeason(), DBSeason.cIndex, this[DBSeason.cIndex], SQLConditionType.Equal); DBSeason.Clear(condition); } DBSeries.IsSeriesRemoved = false; if (type != TVSeriesPlugin.DeleteMenuItems.disk) { // If local/online episode count is zero then delete the series and all seasons condition = new SQLCondition(); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); episodes = DBEpisode.Get(condition, false); if (episodes.Count == 0) { // Delete Seasons condition = new SQLCondition(); condition.Add(new DBSeason(), DBSeason.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBSeason.Clear(condition); // Delete Local Series condition = new SQLCondition(); condition.Add(new DBSeries(), DBSeries.cID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBSeries.Clear(condition); // Delete Online Series condition = new SQLCondition(); condition.Add(new DBOnlineSeries(), DBOnlineSeries.cID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBOnlineSeries.Clear(condition); DBSeries.IsSeriesRemoved = true; } } #endregion return(resultMsg); }
protected override void OnShowContextMenu() { if (listControl == null || listControl.SelectedListItem == null) { return; } GUIListItem selectedItem = listControl.SelectedListItem; YouTubeEntry videoEntry = selectedItem.MusicTag as YouTubeEntry; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu if (Youtube2MP.player.CurrentSong > -1 || Youtube2MP.temp_player.CurrentSong > -1) { dlg.Add(Translation.PlayNext); } dlg.Add(Translation.ShowPreviousWindow); dlg.Add(Translation.Fullscreen); if (videoEntry != null) { dlg.Add(Translation.AddPlaylist); dlg.Add(Translation.AddAllPlaylist); dlg.Add(Translation.Info); if (Youtube2MP.service.Credentials != null) { dlg.Add(Translation.AddFavorites); dlg.Add(Translation.AddWatchLater); } } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (dlg.SelectedLabelText == Translation.ShowPreviousWindow) { GUIWindowManager.ShowPreviousWindow(); } else if (dlg.SelectedLabelText == Translation.Fullscreen) { g_Player.ShowFullScreenWindow(); } else if (dlg.SelectedLabelText == Translation.AddPlaylist) { VideoInfo inf = SelectQuality(videoEntry); if (inf.Quality != VideoQuality.Unknow) { AddItemToPlayList(selectedItem, inf); } } else if (dlg.SelectedLabelText == Translation.AddAllPlaylist) { VideoInfo inf = SelectQuality(videoEntry); inf.Items = new Dictionary <string, string>(); if (inf.Quality != VideoQuality.Unknow) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetHeading(Translation.AddAllPlaylist); dlgProgress.SetLine(1, ""); dlgProgress.SetLine(2, ""); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); dlgProgress.StartModal(GetID); } int i = 0; for (int j = 0; j < listControl.Count; j++) { GUIListItem item = listControl[j]; if (dlgProgress != null) { double pr = ((double)i / (double)listControl.Count) * 100; dlgProgress.SetLine(1, item.Label); dlgProgress.SetLine(2, i.ToString() + "/" + listControl.Count.ToString()); dlgProgress.SetPercentage((int)pr); dlgProgress.Progress(); if (dlgProgress.IsCanceled) { break; } } i++; AddItemToPlayList(item, new VideoInfo(inf)); } if (dlgProgress != null) { dlgProgress.Close(); } } } else if (dlg.SelectedLabelText == Translation.AddFavorites) { try { Youtube2MP.service.Insert(new Uri(YouTubeQuery.CreateFavoritesUri(null)), videoEntry); } catch (Exception) { Err_message(Translation.WrongRequestWrongUser); } } else if (dlg.SelectedLabelText == Translation.AddWatchLater) { PlayListMember pm = new PlayListMember(); pm.Id = videoEntry.VideoId; Youtube2MP.request.Insert(new Uri("https://gdata.youtube.com/feeds/api/users/default/watch_later"), pm); } else if (dlg.SelectedLabelText == Translation.Info) { YoutubeGuiInfoEx scr = (YoutubeGuiInfoEx)GUIWindowManager.GetWindow(29053); scr.YouTubeEntry = videoEntry; //if (entry!=null) //{ // ArtistItem artistItem=ent //} GUIWindowManager.ActivateWindow(29053); } else if (dlg.SelectedLabelText == Translation.PlayNext) { PlayNext(videoEntry); } }
private static void ThreadEncodeTrack() { m_Ripping = true; try { CreateTempFolder(); if (mp3Background) { GUIWaitCursor.Show(); } else if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetPercentage(0); dlgProgress.StartModal(GetID); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); } while (importQueue.Count > 0) { TrackInfo trackInfo = (TrackInfo)importQueue.Dequeue(); if ((dlgProgress != null) && !mp3Background) { if (importQueue.Count > 0) { dlgProgress.SetHeading( string.Format(GUILocalizeStrings.Get(1105) + " ({0} " + GUILocalizeStrings.Get(1104) + ")", importQueue.Count + 1)); } else { dlgProgress.SetHeading(GUILocalizeStrings.Get(1103)); } dlgProgress.SetLine(2, string.Format("{0:00}. {1} - {2}", trackInfo.MusicTag.Track, trackInfo.MusicTag.Artist, trackInfo.MusicTag.Title)); //dlgProgress.SetLine(2, trackInfo.TempFileName); if (dlgProgress.IsCanceled) { m_CancelRipping = true; } } if (!m_CancelRipping) { m_Drive = new CDDrive(); SaveTrack(trackInfo); if (File.Exists(trackInfo.TempFileName) && !m_CancelRipping) { #region Tagging try { Tags tags = Tags.FromFile(trackInfo.TempFileName); tags["TRCK"] = trackInfo.MusicTag.Track.ToString() + "/" + trackInfo.TrackCount.ToString(); tags["TALB"] = trackInfo.MusicTag.Album; tags["TPE1"] = trackInfo.MusicTag.Artist; tags["TIT2"] = trackInfo.MusicTag.Title; tags["TCON"] = trackInfo.MusicTag.Genre; if (trackInfo.MusicTag.Year > 0) { tags["TYER"] = trackInfo.MusicTag.Year.ToString(); } tags["TENC"] = "MediaPortal / Lame"; tags.Save(trackInfo.TempFileName); } catch { } #endregion #region Database try { if (!Directory.Exists(trackInfo.TargetDir)) { Directory.CreateDirectory(trackInfo.TargetDir); } if (File.Exists(trackInfo.TargetFileName)) { if (mp3ReplaceExisting) { File.Delete(trackInfo.TargetFileName); } } if (!File.Exists(trackInfo.TargetFileName)) { File.Move(trackInfo.TempFileName, trackInfo.TargetFileName); } if (File.Exists(trackInfo.TargetFileName) && mp3Database) { if (importUnknown || (trackInfo.MusicTag.Artist != "Unknown Artist") || (trackInfo.MusicTag.Album != "Unknown Album")) { MusicDatabase dbs = MusicDatabase.Instance; dbs.AddSong(trackInfo.TargetFileName); } } } catch { Log.Info("CDIMP: Error moving encoded file {0} to new location {1}", trackInfo.TempFileName, trackInfo.TargetFileName); } #endregion } } } if (mp3Background) { GUIWaitCursor.Hide(); } else { dlgProgress.Close(); } } finally { CleanupTempFolder(); } m_CancelRipping = false; m_Ripping = false; }
public void GetAlbumCovers(string artist, string album, string strPath, int parentWindowID, bool checkForCompilationAlbum) { _SelectedAlbum = null; IsCompilationAlbum = false; if (checkForCompilationAlbum) { IsCompilationAlbum = GetIsCompilationAlbum(strPath, -1); } _Artist = artist; _Album = album; _AlbumPath = strPath; string origAlbumName = _Album; string filteredAlbumFormatString = GUILocalizeStrings.Get(4518); if (filteredAlbumFormatString.Length == 0) { filteredAlbumFormatString = "Album title not found\r\nTrying: {0}"; } _ThumbPath = GetCoverArtThumbPath(artist, album, strPath); amazonWS = new AmazonWebservice(); amazonWS.MaxSearchResultItems = MAX_SEARCH_ITEMS; amazonWS.FindCoverArtProgress += new AmazonWebservice.FindCoverArtProgressHandler(amazonWS_GetAlbumInfoProgress); amazonWS.FindCoverArtDone += new AmazonWebservice.FindCoverArtDoneHandler(amazonWS_FindCoverArtDone); Log.Info("Cover art grabber:getting cover art for [{0}-{1}]...", _Artist, _Album); if (IsCompilationAlbum) { Log.Info("Cover art grabber:compilation album found", _Artist, _Album); amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; _Artist = ""; string filterString = string.Format("{0} = \"{1}\"", GUILocalizeStrings.Get(484), " "); string filter = string.Format(filteredAlbumFormatString, filterString); Log.Info("Cover art grabber:trying again with blank artist name..."); InternalGetAlbumCovers(_Artist, _Album, filter); } else { InternalGetAlbumCovers(_Artist, _Album, string.Empty); } // Did we fail to find any albums? if (!amazonWS.HasAlbums && !amazonWS.AbortGrab) { // Check if the album title includes a disk number description that might // be altering the proper album title such as: White album (Disk 2) string cleanAlbumName = string.Empty; if (StripDiskNumberFromAlbumName(_Album, ref cleanAlbumName)) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, cleanAlbumName); } Log.Info("Cover art grabber:[{0}-{1}] not found. Trying [{0}-{2}]...", _Artist, _Album, cleanAlbumName); string filter = string.Format(filteredAlbumFormatString, cleanAlbumName); origAlbumName = _Album; InternalGetAlbumCovers(_Artist, cleanAlbumName, filter); } else if (GetProperAlbumName(_Album, ref cleanAlbumName)) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, cleanAlbumName); } Log.Info("Cover art grabber:[{0}-{1}] not found. Trying album name without sub-title [{0}-{2}]...", _Artist, _Album, cleanAlbumName); string filter = string.Format(filteredAlbumFormatString, cleanAlbumName); origAlbumName = _Album; InternalGetAlbumCovers(_Artist, cleanAlbumName, filter); } } // Still no albums? if (!IsCompilationAlbum && !amazonWS.HasAlbums && !amazonWS.AbortGrab) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, GUILocalizeStrings.Get(4506)); } string filterString = string.Format("{0} = \"{1}\"", GUILocalizeStrings.Get(483), " "); string filter = string.Format(filteredAlbumFormatString, filterString); // Try searching by artist only to get all albums for this artist... Log.Info("Cover art grabber:[{0}-{1}] not found. Trying again with blank album name...", _Artist, _Album); InternalGetAlbumCovers(_Artist, "", filter); } // if we're searching for a single album the progress dialog will // be displayed so we need to close it... if (SearchMode == SearchDepthMode.Album) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.SetPercentage(100); dlgProgress.Progress(); dlgProgress.Close(); } } amazonWS.FindCoverArtProgress -= new AmazonWebservice.FindCoverArtProgressHandler(amazonWS_GetAlbumInfoProgress); amazonWS.FindCoverArtDone -= new AmazonWebservice.FindCoverArtDoneHandler(amazonWS_FindCoverArtDone); }
void DoSubsequentLoad() { if (PreviousWindowId != OnlineVideos.MediaPortal1.Player.GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO && PluginConfiguration.Instance.updateOnStart != false && PluginConfiguration.Instance.lastFirstRun.AddHours(PluginConfiguration.Instance.updatePeriod) < DateTime.Now) { bool?doUpdate = PluginConfiguration.Instance.updateOnStart; if (!PluginConfiguration.Instance.updateOnStart.HasValue && !preventDialogOnLoad) { GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, Translation.Instance.PerformAutomaticUpdate); dlg.SetLine(2, Translation.Instance.UpdateAllYourSites); dlg.DoModal(GUIWindowManager.ActiveWindow); doUpdate = dlg.IsConfirmed; } } PluginConfiguration.Instance.lastFirstRun = DateTime.Now; if (doUpdate == true || PluginConfiguration.Instance.ThumbsAge >= 0) { GUIDialogProgress dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); if (dlgPrgrs != null) { dlgPrgrs.Reset(); dlgPrgrs.DisplayProgressBar = true; dlgPrgrs.ShowWaitCursor = false; dlgPrgrs.DisableCancel(true); dlgPrgrs.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow); } else { GUIWaitCursor.Init(); GUIWaitCursor.Show(); } new System.Threading.Thread(delegate() { if (doUpdate == true) { if (dlgPrgrs != null) { dlgPrgrs.SetHeading(string.Format("{0} - {1}", PluginConfiguration.Instance.BasicHomeScreenName, Translation.Instance.AutomaticUpdate)); } var onlineVersion = Sites.Updater.VersionOnline; if (OnlineVideos.Sites.Updater.VersionCompatible) { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) => { if (dlgPrgrs != null) { if (!string.IsNullOrEmpty(m)) { dlgPrgrs.SetLine(1, m); } if (p != null) { dlgPrgrs.SetPercentage(p.Value); } return(dlgPrgrs.ShouldRenderLayer()); } else { return(true); } } ); if (updateResult == true && OnlineVideoSettings.Instance.SiteUtilsList.Count > 0) { GUISiteUpdater.ReloadDownloadedDlls(); } else if (updateResult == null || OnlineVideoSettings.Instance.SiteUtilsList.Count > 0) { OnlineVideoSettings.Instance.BuildSiteUtilsList(); } if (updateResult != false) { PluginConfiguration.Instance.BuildAutomaticSitesGroups(); SiteImageExistenceCache.ClearCache(); } } else { // inform the user that autoupdate is disabled due to outdated version! dlgPrgrs.SetLine(1, Translation.Instance.AutomaticUpdateDisabled); dlgPrgrs.SetLine(2, onlineVersion != null ? string.Format(Translation.Instance.LatestVersionRequired, onlineVersion) : "Check your Internet Connection!"); Thread.Sleep(5000); dlgPrgrs.SetLine(2, string.Empty); } } if (PluginConfiguration.Instance.ThumbsAge >= 0) { if (dlgPrgrs != null) { dlgPrgrs.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlgPrgrs.SetLine(1, Translation.Instance.DeletingOldThumbs); dlgPrgrs.Percentage = 0; } ImageDownloader.DeleteOldThumbs(PluginConfiguration.Instance.ThumbsAge, r => { if (dlgPrgrs != null) { dlgPrgrs.Percentage = r; } return(dlgPrgrs != null ? dlgPrgrs.ShouldRenderLayer() : true); }); } if (dlgPrgrs != null) { dlgPrgrs.Percentage = 100; dlgPrgrs.SetLine(1, Translation.Instance.Done); dlgPrgrs.Close(); } else { GUIWaitCursor.Hide(); } GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { DoPageLoad(); return(0); }, 0, 0, null); }) { Name = "OVLoad", IsBackground = true }.Start(); return; } } DoPageLoad(); }
private static bool WakeupSystem(byte[] hwAddress, string wakeupTarget, int timeout) { int waited = 0; WakeOnLanManager wakeOnLanManager = new WakeOnLanManager(); Log.Debug("WOLMgr: Ping {0}", wakeupTarget); if (wakeOnLanManager.Ping(wakeupTarget, 200)) { Log.Debug("WOLMgr: {0} already started", wakeupTarget); return(true); } GUIDialogProgress progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow(101); //(int)Window.WINDOW_DIALOG_PROGRESS progressDialog.Reset(); progressDialog.SetHeading(GUILocalizeStrings.Get(1990)); progressDialog.ShowProgressBar(true); progressDialog.SetLine(1, GUILocalizeStrings.Get(1991)); progressDialog.StartModal(GUIWindowManager.ActiveWindow); // First, try to send WOL Packet if (!wakeOnLanManager.SendWakeOnLanPacket(hwAddress, IPAddress.Broadcast)) { Log.Debug("WOLMgr: FAILED to send the first wake-on-lan packet!"); } while (waited < timeout) { int percentange = (waited * 100) / timeout; progressDialog.SetPercentage(percentange); progressDialog.Progress(); Log.Debug("WOLMgr: Ping {0}", wakeupTarget); if (wakeOnLanManager.Ping(wakeupTarget, 200)) { progressDialog.SetPercentage(100); progressDialog.Progress(); progressDialog.Close(); int waittime; using (Settings xmlreader = new MPSettings()) { waittime = xmlreader.GetValueAsInt("WOL", "WaitTimeAfterWOL", 0); } if (waittime > 0) { GUIDialogProgress progressDialog2 = (GUIDialogProgress)GUIWindowManager.GetWindow(101); //(int)Window.WINDOW_DIALOG_PROGRESS progressDialog2.Reset(); progressDialog2.SetHeading(string.Empty); progressDialog2.ShowProgressBar(true); progressDialog2.SetLine(1, GUILocalizeStrings.Get(1994)); progressDialog2.StartModal(GUIWindowManager.ActiveWindow); waited = waittime; for (int i = waited; waited != 0; waited--) { percentange = (waited * 100) / waittime; progressDialog2.SetPercentage(percentange); progressDialog2.Progress(); System.Threading.Thread.Sleep(1000); } progressDialog2.SetPercentage(0); progressDialog2.Progress(); progressDialog2.Close(); } return(true); } // Send WOL Packet if (!wakeOnLanManager.SendWakeOnLanPacket(hwAddress, IPAddress.Broadcast)) { Log.Debug("WOLMgr: Sending the wake-on-lan packet failed (local network maybe not ready)! {0}s", waited); } Log.Debug("WOLMgr: System {0} still not reachable, waiting... {1}s", wakeupTarget, waited); System.Threading.Thread.Sleep(1000); waited++; } // Timeout was reached and WOL packet can't be send (we stop here) Log.Debug("WOLMgr: FAILED to send wake-on-lan packet after the timeout {0}, try increase the value!", timeout); progressDialog.SetPercentage(100); progressDialog.Progress(); progressDialog.Close(); GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(GUILocalizeStrings.Get(1992)); // Not available dlgOk.SetLine(1, GUILocalizeStrings.Get(1993)); dlgOk.DoModal(GUIWindowManager.ActiveWindow); return(false); }