void VideoDownloader_ProgressChanged(object sender, DownloadEventArgs e) { if (dlgProgress != null) { dlgProgress.SetLine(2, string.Format("{0} Mb / {1} Mb ({2}%)", e.TotalFileSize / 1024 / 1024, e.CurrentFileSize / 1024 / 1024, e.PercentDone)); dlgProgress.ShowProgressBar(true); dlgProgress.SetPercentage(e.PercentDone); dlgProgress.Progress(); } }
public int DoReorg() { /// Todo: move this statement to the GUI. /// Database Reorg now fully in music.database /// GUIDialogProgress pDlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); if (null == pDlgProgress) { return((int)Errors.ERROR_REORG_SONGS); } pDlgProgress.SetHeading(313); pDlgProgress.SetLine(2, ""); pDlgProgress.SetLine(3, ""); pDlgProgress.SetPercentage(0); pDlgProgress.Progress(); pDlgProgress.SetLine(1, 316); pDlgProgress.ShowProgressBar(true); ///TFRO71 4 june 2005 ///Connect the event to a method that knows what to do with the event. MusicDatabase.DatabaseReorgChanged += new MusicDBReorgEventHandler(SetPercentDonebyEvent); ///Execute the reorganisation int appel = m_dbs.MusicDatabaseReorg(null); ///Tfro Disconnect the event from the method. MusicDatabase.DatabaseReorgChanged -= new MusicDBReorgEventHandler(SetPercentDonebyEvent); pDlgProgress.SetLine(2, "Klaar"); return((int)Errors.ERROR_OK); }
void _progressTimer_Elapsed(object sender, ElapsedEventArgs e) { GUIDialogProgress _progress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); int percentage = _progress.Percentage; percentage = percentage + (int)(100.0 / _steps); _progress.SetPercentage(percentage > 100 ? 100 : percentage); _progress.ShowProgressBar(true); _progress.Progress(); }
void setProgress(int percent, string info) { if (dlgPrgrs != null) { dlgPrgrs.SetPercentage(percent); dlgPrgrs.SetLine(1, info); } if (handler.IsComplete) { closeProgDialog(); } }
private void SetPercentDonebyEvent(object sender, DatabaseReorgEventArgs e) { GUIDialogProgress pDlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); if (null == pDlgProgress) { return; } pDlgProgress.SetPercentage(e.progress); pDlgProgress.SetLine(1, e.phase); pDlgProgress.Progress(); }
public void UpdateSearchResults(string sortOrder) { GUIDialogProgress dlg = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); dlg.Reset(); dlg.SetHeading("Torrents"); dlg.SetLine(1, "Fetching torrents..."); dlg.SetPercentage(0); dlg.ShowProgressBar(true); dlg.StartModal(GUIWindowManager.ActiveWindow); _progressDlg = new ProgressUpdater(); _progressDlg.SetAutoUpdate(1000, 20); TorrentEngine.Instance().SearchTorrent(_searchEngine.Name, _searchString, sortOrder, dlg); }
public void OnProgress(string line1, string line2, string line3, int percent) { if (!GUIWindowManager.IsRouted) { return; } GUIDialogProgress pDlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); pDlgProgress.ShowProgressBar(true); pDlgProgress.SetLine(1, line1); pDlgProgress.SetLine(2, line2); if (percent > 0) { pDlgProgress.SetPercentage(percent); } pDlgProgress.Progress(); }
private bool InternalGetAlbumCovers(string artist, string album, string filteredAlbumText) { if (amazonWS.AbortGrab) { return(false); } amazonWS.ArtistName = artist; amazonWS.AlbumName = album; bool result = false; if (SearchMode == SearchDepthMode.Album) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.SetHeading(185); dlgProgress.SetLine(1, album); dlgProgress.SetLine(2, artist); dlgProgress.SetLine(3, filteredAlbumText); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(false); GUIWindowManager.Process(); } result = amazonWS.GetAlbumInfo(); } else { result = amazonWS.GetAlbumInfo(); } return(result); }
private void amazonWS_GetAlbumInfoProgress(AmazonWebservice aws, int progressPercent) { if (SearchMode == SearchDepthMode.Album) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.ShowProgressBar(true); dlgProgress.SetPercentage(progressPercent); dlgProgress.Progress(); } } else { // The GUICoverArtGrabberProgress window will manage showing cover art grabber progress if (FindCoverArtProgress != null) { FindCoverArtProgress(amazonWS, progressPercent); } } }
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); }
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); }
/// <summary> /// Called when [show context menu]. /// </summary> protected override void OnShowContextMenu() { GUIListItem selectedItem = listControl.SelectedListItem; YouTubeEntry videoEntry; LocalFileStruct file = selectedItem.MusicTag as LocalFileStruct; if (file != null) { Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + file.VideoId); Video video = Youtube2MP.request.Retrieve <Video>(videoEntryUrl); videoEntry = video.YouTubeEntry; } else { videoEntry = selectedItem.MusicTag as YouTubeEntry; } if (videoEntry == null) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu dlg.Add("Related Videos"); dlg.Add("Video responses for this video"); dlg.Add("All videos from this user : "******"Add to playlist"); dlg.Add("Add All to playlist"); dlg.Add("Add to favorites"); dlg.Add("Options"); dlg.Add("Download Video"); dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedLabel) { case 0: //relatated { if (videoEntry.RelatedVideosUri != null) { YouTubeQuery query = new YouTubeQuery(videoEntry.RelatedVideosUri.Content); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No item was found !"); } } } break; case 1: //respponse { if (videoEntry.VideoResponsesUri != null) { YouTubeQuery query = new YouTubeQuery(videoEntry.VideoResponsesUri.Content); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No response was found !"); } } } break; case 2: //relatated { if (videoEntry.RelatedVideosUri != null) { Video video = Youtube2MP.request.Retrieve <Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoEntry.VideoId)); YouTubeQuery query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", video.Author)); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No item was found !"); } } } break; case 3: { VideoInfo inf = SelectQuality(videoEntry); if (inf.Quality != VideoQuality.Unknow) { AddItemToPlayList(selectedItem, inf); } } break; case 4: { VideoInfo inf = SelectQuality(videoEntry); inf.Items = new Dictionary <string, string>(); foreach (GUIListItem item in listControl.ListView.ListItems) { AddItemToPlayList(item, new VideoInfo(inf)); } } break; case 5: { try { service.Insert(new Uri(YouTubeQuery.CreateFavoritesUri(null)), videoEntry); } catch (Exception) { Err_message("Wrong request or wrong user identification"); } } break; case 6: DoOptions(); break; case 7: // download { if (Youtube2MP._settings.LocalFile.Get(videoEntry.VideoId) != null) { Err_message("Item already downloaded !"); } else { if (VideoDownloader.IsBusy) { Err_message("Another donwnload is in progress"); dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetHeading("Download progress"); dlgProgress.SetLine(1, ""); dlgProgress.SetLine(2, ""); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); dlgProgress.DoModal(GetID); } } else { VideoInfo inf = SelectQuality(videoEntry); string streamurl = Youtube2MP.StreamPlaybackUrl(videoEntry, inf); VideoDownloader.AsyncDownload(streamurl, Youtube2MP._settings.DownloadFolder + "\\" + Utils.GetFilename(videoEntry.Title.Text + "{" + videoEntry.VideoId + "}") + Path.GetExtension(streamurl)); VideoDownloader.Entry = videoEntry; } } } break; } }
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(); }
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); }