/// <summary> /// Constructor. /// </summary> /// <param name="filename">Filename of the currently played episode</param> public NowPlayingSeries(string filename) { try { SQLCondition query = new SQLCondition(new DBEpisode(), DBEpisode.cFilename, filename, SQLConditionType.Equal); List <DBEpisode> episodes = DBEpisode.Get(query); if (episodes.Count > 0) { episodeFound = true; SeriesId = episodes[0].onlineEpisode[DBOnlineEpisode.cSeriesID]; SeasonId = episodes[0].onlineEpisode[DBOnlineEpisode.cSeasonID]; EpisodeId = episodes[0].onlineEpisode[DBOnlineEpisode.cID]; CompositeId = episodes[0].fullItem[DBEpisode.cCompositeID]; Episode = episodes[0].onlineEpisode[DBOnlineEpisode.cEpisodeIndex]; Season = episodes[0].onlineEpisode[DBOnlineEpisode.cSeasonIndex]; Plot = episodes[0].onlineEpisode[DBOnlineEpisode.cEpisodeSummary]; Title = episodes[0].onlineEpisode[DBOnlineEpisode.cEpisodeName]; Director = episodes[0].onlineEpisode[DBOnlineEpisode.cDirector]; Writer = episodes[0].onlineEpisode[DBOnlineEpisode.cWriter]; Rating = episodes[0].onlineEpisode[DBOnlineEpisode.cRating]; MyRating = episodes[0].onlineEpisode[DBOnlineEpisode.cMyRating]; RatingCount = episodes[0].onlineEpisode[DBOnlineEpisode.cRatingCount]; AirDate = episodes[0].onlineEpisode[DBOnlineEpisode.cFirstAired]; DBSeries s = Helper.getCorrespondingSeries(episodes[0].onlineEpisode[DBOnlineEpisode.cSeriesID]); Series = s[DBOnlineSeries.cPrettyName]; Status = s[DBOnlineSeries.cStatus]; Genre = s[DBOnlineSeries.cGenre]; // Get season poster path DBSeason season = DBSeason.getRaw(SeriesId, episodes[0].onlineEpisode[DBOnlineEpisode.cSeasonIndex]); ImageName = ImageAllocator.GetSeasonBannerAsFilename(season); // Fall back to series poster if no season poster is available if (String.IsNullOrEmpty(ImageName)) { ImageName = ImageAllocator.GetSeriesPosterAsFilename(s); } } } catch (Exception e) { WifiRemote.LogMessage("Error getting now playing tvseries: " + e.Message, WifiRemote.LogType.Error); } }
public GetUpdates(OnlineAPI.UpdateType type) { if (type != OnlineAPI.UpdateType.all) { MPTVSeriesLog.Write(string.Format("Downloading updates from the last {0}", type.ToString())); } else { MPTVSeriesLog.Write("Downloading all updates"); } XmlNode updates = OnlineAPI.Updates(type); series = new Dictionary <DBValue, long>(); episodes = new Dictionary <DBValue, long>(); banners = new Dictionary <DBValue, long>(); fanart = new Dictionary <DBValue, long>(); // if updates via zip fails, try xml if (updates == null) { MPTVSeriesLog.Write("Failed to get updates from 'zip' file, trying 'xml'..."); updates = OnlineAPI.Updates(type, OnlineAPI.Format.Xml); // if we're still failing to get updates... if (updates == null) { // manually define what series need updating basis whether the series is continuing and has local episodes SQLCondition condition = new SQLCondition(); condition.Add(new DBOnlineSeries(), DBOnlineSeries.cID, 0, SQLConditionType.GreaterThan); condition.Add(new DBOnlineSeries(), DBOnlineSeries.cHasLocalFiles, 1, SQLConditionType.Equal); condition.Add(new DBOnlineSeries(), DBOnlineSeries.cStatus, "Ended", SQLConditionType.NotEqual); condition.Add(new DBSeries(), DBSeries.cScanIgnore, 0, SQLConditionType.Equal); condition.Add(new DBSeries(), DBSeries.cDuplicateLocalName, 0, SQLConditionType.Equal); var lContinuingSeries = DBSeries.Get(condition, false, false); MPTVSeriesLog.Write($"Failed to get updates from online, manually defining series and images for updates. Database contains '{lContinuingSeries.Count}' continuing series with local files"); // force our local download cache to expire after a 12hrs timestamp = DateTime.UtcNow.Subtract(new TimeSpan(0, 12, 0, 0)).ToEpoch(); foreach (var lSeries in lContinuingSeries) { string lSeriesId = lSeries[DBOnlineSeries.cID]; series.Add(lSeriesId, timestamp); banners.Add(lSeriesId, timestamp); fanart.Add(lSeriesId, timestamp); // get the most recent season as that is the one that is most likely recently updated // NB: specials could also be recently updated var lSeasons = DBSeason.Get(int.Parse(lSeriesId)); if (lSeasons != null && lSeasons.Count > 0) { int lSeasonIndex = lSeasons.Max(s => ( int )s[DBSeason.cIndex]); var lEpisodes = DBEpisode.Get(int.Parse(lSeriesId), lSeasonIndex); lEpisodes.AddRange(DBEpisode.Get(int.Parse(lSeriesId), 0)); foreach (var episode in lEpisodes) { episodes.Add(episode[DBOnlineEpisode.cID], timestamp); } } } } else { long.TryParse(updates.Attributes["time"].Value, out timestamp); // get all available series in database, there is not point processing updates from online if not needed var lAvailableSeriesInDb = DBSeries.Get(new SQLCondition()).Select(field => (string)field[DBOnlineSeries.cID]).ToList(); // NB: updates from xml only includes series (no episodes or artwork!) foreach (XmlNode node in updates.SelectNodes("/Data/Series")) { long.TryParse(node.SelectSingleNode("time").InnerText, out long lTime); string lSeriesId = node.SelectSingleNode("id").InnerText; // check if we're interested in this series if (!lAvailableSeriesInDb.Contains(lSeriesId)) { continue; } series.Add(lSeriesId, lTime); banners.Add(lSeriesId, lTime); fanart.Add(lSeriesId, lTime); // get the most recent season as that is the one that is most likely recently updated // NB: specials could also be recently updated if (Helper.getCorrespondingSeries(int.Parse(lSeriesId)) != null) { var lSeasons = DBSeason.Get(int.Parse(lSeriesId)); if (lSeasons != null && lSeasons.Count > 0) { int lSeasonIndex = lSeasons.Max(s => ( int )s[DBSeason.cIndex]); var lEpisodes = DBEpisode.Get(int.Parse(lSeriesId), lSeasonIndex); lEpisodes.AddRange(DBEpisode.Get(int.Parse(lSeriesId), 0)); foreach (var episode in lEpisodes) { episodes.Add(episode[DBOnlineEpisode.cID], lTime); } } } } } return; } // process zip file update... long.TryParse(updates.Attributes["time"].Value, out this.timestamp); // get all the series ids foreach (XmlNode node in updates.SelectNodes("/Data/Series")) { long time; long.TryParse(node.SelectSingleNode("time").InnerText, out time); this.series.Add(node.SelectSingleNode("id").InnerText, time); } // get all the episode ids foreach (XmlNode node in updates.SelectNodes("/Data/Episode")) { long time; long.TryParse(node.SelectSingleNode("time").InnerText, out time); this.episodes.Add(node.SelectSingleNode("id").InnerText, time); } // get all the season banners string id = string.Empty; long value; foreach (XmlNode node in updates.SelectNodes("/Data/Banner[type='season']")) { long time; long.TryParse(node.SelectSingleNode("time").InnerText, out time); id = node.SelectSingleNode("Series").InnerText; if (!this.banners.TryGetValue(id, out value)) { this.banners.Add(id, time); } } //get all the series banners foreach (XmlNode node in updates.SelectNodes("/Data/Banner[type='series']")) { long time; long.TryParse(node.SelectSingleNode("time").InnerText, out time); id = node.SelectSingleNode("Series").InnerText; if (!this.banners.TryGetValue(id, out value)) { this.banners.Add(id, time); } } //get all the poster banners foreach (XmlNode node in updates.SelectNodes("/Data/Banner[type='poster']")) { long time; long.TryParse(node.SelectSingleNode("time").InnerText, out time); id = node.SelectSingleNode("Series").InnerText; if (!this.banners.TryGetValue(id, out value)) { this.banners.Add(id, time); } } //get all the fanart banners id = string.Empty; foreach (XmlNode node in updates.SelectNodes("/Data/Banner[type='fanart']")) { long time; long.TryParse(node.SelectSingleNode("time").InnerText, out time); id = node.SelectSingleNode("Series").InnerText; if (!this.fanart.TryGetValue(id, out value)) { this.fanart.Add(id, time); } } }
static void getTableFieldname(string what, out DBTable table, out string fieldname) { string sTable = string.Empty; fieldname = string.Empty; table = null; what = what.Replace("<", "").Replace(">", "").Trim(); sTable = what.Split('.')[0]; switch (sTable) { case "Series": if(new DBOnlineSeries().FieldNames.Contains(what.Split('.')[1])) { table = new DBOnlineSeries(); fieldname = what.Split('.')[1]; } else { table = new DBSeries(); fieldname = what.Split('.')[1]; } break; case "Season": table = new DBSeason(); fieldname = what.Split('.')[1]; break; case "Episode": if (new DBOnlineEpisode().FieldNames.Contains(what.Split('.')[1])) { table = new DBOnlineEpisode(); fieldname = what.Split('.')[1]; } else { table = new DBEpisode(); fieldname = what.Split('.')[1]; } break; } }
private void UpdateEpisodes(DBSeries series, DBSeason season, DBEpisode episode) { List<DBValue> epIDsUpdates = new List<DBValue>(); List<DBValue> seriesIDsUpdates = new List<DBValue>(); SQLCondition conditions = null; string searchPattern = string.Empty; // Get selected Series and/or list of Episode(s) to update switch (this.listLevel) { case Listlevel.Series: seriesIDsUpdates.Add(series[DBSeries.cID]); conditions = new SQLCondition(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, series[DBSeries.cID], SQLConditionType.Equal); epIDsUpdates.AddRange(DBEpisode.GetSingleField(DBOnlineEpisode.cID, conditions, new DBOnlineEpisode())); searchPattern = "*.jpg"; break; case Listlevel.Season: conditions = new SQLCondition(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, season[DBSeason.cSeriesID], SQLConditionType.Equal); conditions.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeasonIndex, season[DBSeason.cIndex], SQLConditionType.Equal); epIDsUpdates.AddRange(DBEpisode.GetSingleField(DBOnlineEpisode.cID, conditions, new DBOnlineEpisode())); searchPattern = season[DBSeason.cIndex] + "x*.jpg"; break; case Listlevel.Episode: epIDsUpdates.Add(episode[DBOnlineEpisode.cID]); conditions = new SQLCondition(new DBOnlineEpisode(), DBOnlineEpisode.cID, episode[DBOnlineEpisode.cID], SQLConditionType.Equal); searchPattern = episode[DBOnlineEpisode.cSeasonIndex] + "x" + episode[DBOnlineEpisode.cEpisodeIndex] + ".jpg"; break; } // Delete Physical Thumbnails // Dont prompt if just doing a single episode update bool deleteThumbs = true; if (this.listLevel != Listlevel.Episode) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.Reset(); dlgYesNo.SetHeading(Translation.DeleteThumbnailsHeading); dlgYesNo.SetLine(1, Translation.DeleteThumbnailsLine1); dlgYesNo.SetLine(2, Translation.DeleteThumbnailsLine2); dlgYesNo.SetDefaultToYes(false); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (!dlgYesNo.IsConfirmed) deleteThumbs = false; } } if (deleteThumbs) { string thumbnailPath = Helper.PathCombine(Settings.GetPath(Settings.Path.banners), Helper.cleanLocalPath(series.ToString()) + @"\Episodes"); // Search and delete matching files that actually exist string[] fileList = Directory.GetFiles(thumbnailPath, searchPattern); foreach (string file in fileList) { MPTVSeriesLog.Write("Deleting Episode Thumbnail: " + file); FileInfo fileInfo = new FileInfo(file); try { fileInfo.Delete(); } catch (Exception ex) { MPTVSeriesLog.Write("Failed to Delete Episode Thumbnail: " + file + ": " + ex.Message); } } // Remove local thumbnail reference from db so that it thumbnails will be downloaded DBEpisode.GlobalSet(new DBOnlineEpisode(), DBOnlineEpisode.cEpisodeThumbnailFilename, (DBValue)"", conditions); } // Execute Online Parsing Actions if (epIDsUpdates.Count > 0) { lock (m_parserUpdaterQueue) { List<ParsingAction> parsingActions = new List<ParsingAction>(); // Conditional parsing actions if (this.listLevel == Listlevel.Series) parsingActions.Add(ParsingAction.UpdateSeries); parsingActions.Add(ParsingAction.UpdateEpisodes); if (deleteThumbs) parsingActions.Add(ParsingAction.UpdateEpisodeThumbNails); parsingActions.Add(ParsingAction.UpdateEpisodeCounts); m_parserUpdaterQueue.Add(new CParsingParameters(parsingActions, seriesIDsUpdates, epIDsUpdates)); } } }
private void ShowDeleteMenu(DBSeries series, DBSeason season, DBEpisode episode) { String sDialogHeading = String.Empty; switch (this.listLevel) { case Listlevel.Series: sDialogHeading = Translation.Delete_that_series; break; case Listlevel.Season: sDialogHeading = Translation.Delete_that_season; break; case Listlevel.Episode: sDialogHeading = Translation.Delete_that_episode; break; } IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return; dlg.Reset(); dlg.SetHeading(sDialogHeading); // Add Menu items GUIListItem pItem = null; pItem = new GUIListItem(Translation.DeleteFromDisk); dlg.Add(pItem); pItem.ItemId = (int)DeleteMenuItems.disk; pItem = new GUIListItem(Translation.DeleteFromDatabase); dlg.Add(pItem); pItem.ItemId = (int)DeleteMenuItems.database; pItem = new GUIListItem(Translation.DeleteFromFileDatabase); dlg.Add(pItem); pItem.ItemId = (int)DeleteMenuItems.diskdatabase; if (this.listLevel == Listlevel.Episode && episode != null && episode.checkHasLocalSubtitles()) { pItem = new GUIListItem(Translation.DeleteSubtitles); dlg.Add(pItem); pItem.ItemId = (int)DeleteMenuItems.subtitles; } pItem = new GUIListItem(Translation.Cancel); dlg.Add(pItem); pItem.ItemId = (int)DeleteMenuItems.cancel; // Show Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0 || dlg.SelectedId == (int)DeleteMenuItems.cancel) return; List<string> resultMsg = null; string msgDlgCaption = string.Empty; #region Delete Subtitles if (dlg.SelectedId == (int)DeleteMenuItems.subtitles) { msgDlgCaption = Translation.UnableToDeleteSubtitles; switch (this.listLevel) { case Listlevel.Episode: if (episode == null) return; resultMsg = episode.deleteLocalSubTitles(); break; } } #endregion #region Delete From Disk, Database or Both if (dlg.SelectedId != (int)DeleteMenuItems.subtitles) { msgDlgCaption = Translation.UnableToDelete; switch (this.listLevel) { #region Delete Series case Listlevel.Series: resultMsg = series.deleteSeries((DeleteMenuItems)dlg.SelectedId); break; #endregion #region Delete Season case Listlevel.Season: resultMsg = season.deleteSeason((DeleteMenuItems)dlg.SelectedId); break; #endregion #region Delete Episode case Listlevel.Episode: resultMsg = episode.deleteEpisode((DeleteMenuItems)dlg.SelectedId); break; #endregion } // only update the counts if the database entry for the series still exists if (!DBSeries.IsSeriesRemoved) DBSeries.UpdateEpisodeCounts(series); } #endregion // Re-load the facade to accurately reflect actions taked above LoadFacade(); // Show errors, if any if (resultMsg != null && resultMsg.Count > 0) { GUIDialogText errorDialog = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT); errorDialog.SetHeading(msgDlgCaption); errorDialog.SetText(string.Join("\n", resultMsg.ToArray())); errorDialog.DoModal(GUIWindowManager.ActiveWindow); } }
private void Series_OnItemSelected(GUIListItem item) { if (m_bQuickSelect) return; m_SelectedSeason = null; m_SelectedEpisode = null; if (item == null || item.TVTag == null || !(item.TVTag is DBSeries)) return; setNewListLevelOfCurrView(m_CurrViewStep); DBSeries series = item.TVTag as DBSeries; if (series == null) return; m_SelectedSeries = series; // set watched/unavailable flag if (dummyIsWatched != null) dummyIsWatched.Visible = (int.Parse(series[DBOnlineSeries.cEpisodesUnWatched]) == 0); if (dummyIsAvailable != null) dummyIsAvailable.Visible = series[DBSeason.cHasLocalFiles]; clearGUIProperty(guiProperty.EpisodeImage); seasonbanner.Filename = ""; setGUIProperty(guiProperty.Title, FieldGetter.resolveDynString(m_sFormatSeriesTitle, series)); setGUIProperty(guiProperty.Subtitle, FieldGetter.resolveDynString(m_sFormatSeriesSubtitle, series)); setGUIProperty(guiProperty.Description, FieldGetter.resolveDynString(m_sFormatSeriesMain, series)); // Delayed Image Loading of Series Banners/Posters seriesbanner.Filename = ImageAllocator.GetSeriesBannerAsFilename(series); seriesposter.Filename = ImageAllocator.GetSeriesPosterAsFilename(series); setGUIProperty(guiProperty.Logos, localLogos.getLogos(ref series, logosHeight, logosWidth)); pushFieldsToSkin(m_SelectedSeries, "Series"); // Load Fanart // Re-initialize timer for random fanart m_FanartItem = m_SelectedSeries; if (DBOption.GetOptions(DBOption.cFanartRandom)) { // We should update fanart as soon as new series is selected or // if timer was disabled (e.g. fullscreen playback) if (m_SelectedSeries[DBSeries.cID].ToString() != m_prevSeriesID || m_bFanartTimerDisabled) m_FanartTimer.Change(0, DBOption.GetOptions(DBOption.cRandomFanartInterval)); } else loadFanart(m_FanartItem); // Remember last series, so we dont re-initialize random fanart timer m_prevSeriesID = m_SelectedSeries[DBSeries.cID]; }
private void Season_OnItemSelected(GUIListItem item) { if (m_bQuickSelect) return; m_SelectedEpisode = null; if (item == null || item.TVTag == null) return; setNewListLevelOfCurrView(m_CurrViewStep); DBSeason season = item.TVTag as DBSeason; if (season == null) return; m_SelectedSeason = season; // set watched/unavailable flag if (dummyIsWatched != null) dummyIsWatched.Visible = (int.Parse(season[DBOnlineSeries.cEpisodesUnWatched]) == 0); if (dummyIsAvailable != null) dummyIsAvailable.Visible = season[DBSeason.cHasLocalFiles]; setGUIProperty(guiProperty.Title, FieldGetter.resolveDynString(m_sFormatSeasonTitle, season)); setGUIProperty(guiProperty.Subtitle, FieldGetter.resolveDynString(m_sFormatSeasonSubtitle, season)); setGUIProperty(guiProperty.Description, FieldGetter.resolveDynString(m_sFormatSeasonMain, season)); // Delayed Image Loading of Season Banners string filename = ImageAllocator.GetSeasonBannerAsFilename(season); if (filename.Length == 0) { // Load Series Poster instead if (DBOption.GetOptions(DBOption.cSubstituteMissingArtwork) && m_SelectedSeries != null) { filename = ImageAllocator.GetSeriesPosterAsFilename(m_SelectedSeries); } } seasonbanner.Filename = filename; setGUIProperty(guiProperty.Logos, localLogos.getLogos(ref season, logosHeight, logosWidth)); clearGUIProperty(guiProperty.EpisodeImage); if (!m_CurrLView.stepHasSeriesBeforeIt(m_CurrViewStep)) { // it is the case m_SelectedSeries = Helper.getCorrespondingSeries(season[DBSeason.cSeriesID]); if (m_SelectedSeries != null) { seriesbanner.Filename = ImageAllocator.GetSeriesBannerAsFilename(m_SelectedSeries); seriesposter.Filename = ImageAllocator.GetSeriesPosterAsFilename(m_SelectedSeries); } else { clearGUIProperty(guiProperty.SeriesBanner); clearGUIProperty(guiProperty.SeriesPoster); } } pushFieldsToSkin(m_SelectedSeason, "Season"); // Load Fanart m_FanartItem = m_SelectedSeason; if (DBOption.GetOptions(DBOption.cFanartRandom)) { // We should update fanart as soon as new series is selected or // if timer was disabled (e.g. fullscreen playback) if (m_SelectedSeries[DBSeries.cID].ToString() != m_prevSeriesID || m_bFanartTimerDisabled) m_FanartTimer.Change(0, DBOption.GetOptions(DBOption.cRandomFanartInterval)); } else loadFanart(m_FanartItem); // Remember last series, so we dont re-initialize random fanart timer m_prevSeriesID = m_SelectedSeries[DBSeries.cID]; }
public static String GetSeasonBanner(DBSeason season, bool createIfNotExist, bool isCoverflow) { Size size = isCoverflow ? reqSeasonPosterCFSize : reqSeasonPosterSize; String sFileName = season.Banner; String sTextureName = null; if (sFileName.Length > 0 && System.IO.File.Exists(sFileName)) { if (DBOption.GetOptions(DBOption.cAltImgLoading)) sTextureName = sFileName; // bypass memoryimagebuilder else sTextureName = buildMemoryImageFromFile(sFileName, size); } if (createIfNotExist && string.IsNullOrEmpty(sTextureName)) { // no image, use text, create our own string text = (season[DBSeason.cIndex] == 0) ? Translation.specials : Translation.Season + season[DBSeason.cIndex]; string ident = season[DBSeason.cSeriesID] + "S" + season[DBSeason.cIndex]; sTextureName = buildMemoryImage(drawSimpleBanner(size, text), ident, size, true); } // nothing left we can do, so return empty if still nothing if (string.IsNullOrEmpty(sTextureName)) return string.Empty; s_SeasonsImageList.Add(sTextureName); return sTextureName; }
private void Episode_OnItemSelected(GUIListItem item) { if (item == null || item.TVTag == null) return; setNewListLevelOfCurrView(m_CurrViewStep); DBEpisode episode = item.TVTag as DBEpisode; if (episode == null) return; // set watched/unavailable flag if (dummyIsWatched != null) dummyIsWatched.Visible = episode[DBOnlineEpisode.cWatched]; if (dummyIsAvailable != null) dummyIsAvailable.Visible = episode[DBEpisode.cFilename].ToString().Length > 0; m_SelectedEpisode = episode; setGUIProperty(guiProperty.Logos, localLogos.getLogos(ref episode, logosHeight, logosWidth)); setGUIProperty(guiProperty.EpisodeImage, ImageAllocator.GetEpisodeImage(m_SelectedEpisode)); setGUIProperty(guiProperty.Title, FieldGetter.resolveDynString(m_sFormatEpisodeTitle, episode)); setGUIProperty(guiProperty.Subtitle, FieldGetter.resolveDynString(m_sFormatEpisodeSubtitle, episode)); setGUIProperty(guiProperty.Description, FieldGetter.resolveDynString(m_sFormatEpisodeMain, episode)); // with groups in episode view its possible the user never selected a series/season (flat view) // thus its desirable to display the series_banner and season banner on hover) if (!m_CurrLView.stepHasSeriesBeforeIt(m_CurrViewStep) || m_bUpdateBanner) { // it is the case m_SelectedSeason = Helper.getCorrespondingSeason(episode[DBEpisode.cSeriesID], episode[DBEpisode.cSeasonIndex]); m_SelectedSeries = Helper.getCorrespondingSeries(episode[DBEpisode.cSeriesID]); if (m_SelectedSeries != null) { seriesbanner.Filename = ImageAllocator.GetSeriesBannerAsFilename(m_SelectedSeries); seriesposter.Filename = ImageAllocator.GetSeriesPosterAsFilename(m_SelectedSeries); pushFieldsToSkin(m_SelectedSeries, "Series"); } else { clearGUIProperty(guiProperty.SeriesBanner); clearGUIProperty(guiProperty.SeriesPoster); } if (m_SelectedSeason != null) { string filename = ImageAllocator.GetSeasonBannerAsFilename(m_SelectedSeason); if (filename.Length == 0) { // Load Series Poster instead if (DBOption.GetOptions(DBOption.cSubstituteMissingArtwork) && m_SelectedSeries != null) { filename = ImageAllocator.GetSeriesPosterAsFilename(m_SelectedSeries); } } seasonbanner.Filename = filename; pushFieldsToSkin(m_SelectedSeason, "Season"); } else clearGUIProperty(guiProperty.SeasonPoster); m_bUpdateBanner = false; } pushFieldsToSkin(m_SelectedEpisode, "Episode"); // Load Fanart for Selected Series, might be in Episode Only View e.g. Recently Added, Latest if (m_SelectedSeries == null) return; m_FanartItem = m_SelectedSeries; if (DBOption.GetOptions(DBOption.cFanartRandom)) { // We should update fanart as soon as new series is selected or // if timer was disabled (e.g. fullscreen playback) if (m_SelectedSeries[DBSeries.cID].ToString() != m_prevSeriesID || m_bFanartTimerDisabled) m_FanartTimer.Change(0, DBOption.GetOptions(DBOption.cRandomFanartInterval)); } else loadFanart(m_FanartItem); // Remember last series, so we dont re-initialize random fanart timer m_prevSeriesID = m_SelectedSeries[DBSeries.cID]; }
private void CycleSeasonPoster(DBSeason season, bool next) { if (season.BannerList.Count <= 1) return; int nCurrent = season.BannerList.IndexOf(season.Banner); if (next) { nCurrent++; if (nCurrent >= season.BannerList.Count) nCurrent = 0; } else { nCurrent--; if (nCurrent < 0) nCurrent = season.BannerList.Count - 1; } season.Banner = season.BannerList[nCurrent]; season.Commit(); m_bUpdateBanner = true; // No need to re-load the facade for non-graphical layouts if (m_Facade.CurrentLayout == GUIFacadeControl.Layout.List) seasonbanner.Filename = ImageAllocator.GetSeasonBannerAsFilename(season); else LoadFacade(); }
protected override void OnPageLoad() { MPTVSeriesLog.Write("OnPageLoad() started.", MPTVSeriesLog.LogLevel.Debug); if (m_Facade == null) { // Most likely the skin does not exist GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading(Translation.wrongSkin); dlg.DoModal(GetID); GUIWindowManager.ShowPreviousWindow(); return; } GUIPropertyManager.SetProperty("#currentmodule", pluginName); ImageAllocator.SetFontName(m_Facade.AlbumListLayout == null ? m_Facade.ListLayout.FontName : m_Facade.AlbumListLayout.FontName); #region Clear GUI Properties // Clear GUI Properties when first entering the plugin // This will avoid ugly property names being seen before // its corresponding value is assigned if (!m_bPluginLoaded) { clearGUIProperty(guiProperty.Subtitle); clearGUIProperty(guiProperty.Title); clearGUIProperty(guiProperty.Description); clearGUIProperty(guiProperty.CurrentView); clearGUIProperty(guiProperty.SimpleCurrentView); clearGUIProperty(guiProperty.NextView); clearGUIProperty(guiProperty.LastView); clearGUIProperty(guiProperty.SeriesCount); clearGUIProperty(guiProperty.GroupCount); clearGUIProperty(guiProperty.FilteredEpisodeCount); clearGUIProperty(guiProperty.WatchedCount); clearGUIProperty(guiProperty.UnWatchedCount); clearFieldsForskin("Series"); clearFieldsForskin("Season"); clearFieldsForskin("Episode"); } #endregion localLogos.appendEpImage = m_Episode_Image == null ? true : false; #region View Setup and Loading Parameters bool viewSwitched = false; m_LoadingParameter = GetLoadingParameter(); if (m_LoadingParameter.Type != LoadingParameterType.None && m_LoadingParameter.Type != LoadingParameterType.View) { m_JumpToViewLevel = true; if (m_allViews == null || m_allViews.Count == 0) m_allViews = logicalView.getAll(false); if (m_CurrLView == null) switchView((string)DBOption.GetOptions("lastView")); int viewLevels = m_CurrLView.m_steps.Count; m_SelectedSeries = Helper.getCorrespondingSeries(Convert.ToInt32(m_LoadingParameter.SeriesId)); if (m_SelectedSeries == null) { MPTVSeriesLog.Write("Failed to get series object from loading parameter!", MPTVSeriesLog.LogLevel.Debug); m_LoadingParameter.Type = LoadingParameterType.None; } else { MPTVSeriesLog.Write(string.Format("Loading into series: {0}", m_SelectedSeries.ToString(), MPTVSeriesLog.LogLevel.Debug)); m_stepSelection = new string[] { m_LoadingParameter.SeriesId }; m_stepSelections.Add(m_stepSelection); pushFieldsToSkin(m_SelectedSeries, "Series"); } switch (m_LoadingParameter.Type) { #region Series case LoadingParameterType.Series: // load into Season view if multiple seasons exists // will auto drill down to current available season if only one exists if (viewLevels > 1) m_CurrViewStep = viewLevels - 2; else m_CurrViewStep = 0; this.listLevel = Listlevel.Season; break; #endregion #region Season case LoadingParameterType.Season: m_SelectedSeason = Helper.getCorrespondingSeason(Convert.ToInt32(m_LoadingParameter.SeriesId), Convert.ToInt32(m_LoadingParameter.SeasonIdx)); if (m_SelectedSeason == null) { m_LoadingParameter.Type = LoadingParameterType.None; break; } // load into episode view for series/season if (viewLevels > 1) m_CurrViewStep = viewLevels - 1; else m_CurrViewStep = 0; this.listLevel = Listlevel.Episode; m_stepSelection = new string[] { m_LoadingParameter.SeriesId, m_LoadingParameter.SeasonIdx }; m_stepSelections.Add(m_stepSelection); break; #endregion #region Episode case LoadingParameterType.Episode: m_SelectedEpisode = DBEpisode.Get(Convert.ToInt32(m_LoadingParameter.SeriesId), Convert.ToInt32(m_LoadingParameter.SeasonIdx), Convert.ToInt32(m_LoadingParameter.EpisodeIdx)); if (m_SelectedEpisode == null) { m_LoadingParameter.Type = LoadingParameterType.None; break; } // load into episode view for series/season if (viewLevels > 1) m_CurrViewStep = viewLevels - 1; else m_CurrViewStep = 0; this.listLevel = Listlevel.Episode; m_stepSelection = new string[] { m_LoadingParameter.SeriesId, m_LoadingParameter.SeasonIdx }; m_stepSelections.Add(m_stepSelection); break; #endregion } setViewLabels(); } // Initialize View, also check if current view is locked after exiting and re-entering plugin if (m_LoadingParameter.Type == LoadingParameterType.None || m_LoadingParameter.Type == LoadingParameterType.View) { m_JumpToViewLevel = false; if (m_CurrLView == null || (m_CurrLView.ParentalControl && logicalView.IsLocked) || !string.IsNullOrEmpty(m_LoadingParameter.ViewName)) { // Get available Views m_allViews = logicalView.getAll(false); if (m_allViews.Count > 0) { try { if (m_LoadingParameter.Type == LoadingParameterType.View) { viewSwitched = switchView(m_LoadingParameter.ViewName); } else { viewSwitched = switchView((string)DBOption.GetOptions("lastView")); } } catch { viewSwitched = false; MPTVSeriesLog.Write("Error when switching view"); } } else { viewSwitched = false; MPTVSeriesLog.Write("Error, cannot display items because no Views have been found!"); } } else { viewSwitched = true; setViewLabels(); } // If unable to load view, exit if (!viewSwitched) { GUIWindowManager.ShowPreviousWindow(); return; } } #endregion backdrop.GUIImageOne = FanartBackground; backdrop.GUIImageTwo = FanartBackground2; backdrop.LoadingImage = loadingImage; DBEpisode previouslySelectedEpisode = m_SelectedEpisode; LoadFacade(); m_Facade.Focus = true; // Update Button Labels with translations if (viewMenuButton != null) viewMenuButton.Label = Translation.ButtonSwitchView; if (filterButton != null) filterButton.Label = Translation.Filters; if (ImportButton != null) ImportButton.Label = Translation.ButtonRunImport; if (LayoutMenuButton != null) LayoutMenuButton.Label = Translation.ButtonChangeLayout; if (OptionsMenuButton != null) OptionsMenuButton.Label = Translation.ButtonOptions; setProcessAnimationStatus(m_parserUpdaterWorking); if (m_Logos_Image != null) { logosHeight = m_Logos_Image.Height; logosWidth = m_Logos_Image.Width; } m_bPluginLoaded = true; Helper.disableNativeAutoplay(); // Ask to Rate Episode, onPageLoad is triggered after returning from player if (ask2Rate != null) { showRatingsDialog(ask2Rate, true); ask2Rate = null; // Refresh the facade if we want to see the submitted rating if (this.listLevel == Listlevel.Episode) { LoadFacade(); } } // Play after subtitle download if (m_PlaySelectedEpisodeAfterSubtitles && previouslySelectedEpisode != null && previouslySelectedEpisode == m_SelectedEpisode) { CommonPlayEpisodeAction(); m_PlaySelectedEpisodeAfterSubtitles = false; } // Push last update time to skin setGUIProperty(guiProperty.LastOnlineUpdate, DBOption.GetOptions(DBOption.cImport_OnlineUpdateScanLastTime)); MPTVSeriesLog.Write("OnPageLoad() completed.", MPTVSeriesLog.LogLevel.Debug); }
protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) { if (control == null) return; // may enter tvs from another window via click if (control == this.viewMenuButton) { showViewSwitchDialog(); GUIControl.UnfocusControl(GetID, viewMenuButton.GetID); GUIControl.FocusControl(GetID, m_Facade.GetID); return; } if (control == this.filterButton) { ShowFiltersMenu(); GUIControl.UnfocusControl(GetID, filterButton.GetID); GUIControl.FocusControl(GetID, m_Facade.GetID); } if (control == this.LayoutMenuButton) { ShowLayoutMenu(); GUIControl.UnfocusControl(GetID, LayoutMenuButton.GetID); GUIControl.FocusControl(GetID, m_Facade.GetID); return; } if (control == this.OptionsMenuButton) { ShowOptionsMenu(); GUIControl.UnfocusControl(GetID, OptionsMenuButton.GetID); GUIControl.FocusControl(GetID, m_Facade.GetID); return; } if (control == this.ImportButton) { lock (m_parserUpdaterQueue) { m_parserUpdaterQueue.Add(new CParsingParameters(true, true)); } // Start Import if delayed m_scanTimer.Change(1000, 1000); GUIControl.UnfocusControl(GetID, ImportButton.GetID); GUIControl.FocusControl(GetID, m_Facade.GetID); return; } if (control == this.LoadPlaylistButton) { OnShowSavedPlaylists(DBOption.GetOptions(DBOption.cPlaylistPath)); GUIControl.UnfocusControl(GetID, LoadPlaylistButton.GetID); GUIControl.FocusControl(GetID, m_Facade.GetID); return; } if (actionType != Action.ActionType.ACTION_SELECT_ITEM) return; // some other events raised onClicked too for some reason? if (control == this.m_Facade) { if (this.m_Facade.SelectedListItem == null || this.m_Facade.SelectedListItem.TVTag == null) return; #region Parental Control Check for Tagged Views if (this.listLevel == Listlevel.Group && logicalView.IsLocked) { string viewName = this.m_Facade.SelectedListItem.Label; DBView[] views = DBView.getTaggedViews(); foreach (DBView view in views) { if (view[DBView.cTransToken] == viewName || view[DBView.cPrettyName] == viewName) { // check if we are entering a protected view if (view[DBView.cParentalControl]) { GUIPinCode pinCodeDlg = (GUIPinCode)GUIWindowManager.GetWindow(GUIPinCode.ID); pinCodeDlg.Reset(); pinCodeDlg.MasterCode = DBOption.GetOptions(DBOption.cParentalControlPinCode); pinCodeDlg.EnteredPinCode = string.Empty; pinCodeDlg.SetHeading(Translation.PinCode); pinCodeDlg.SetLine(1, string.Format(Translation.PinCodeDlgLabel1, viewName)); pinCodeDlg.SetLine(2, Translation.PinCodeDlgLabel2); pinCodeDlg.Message = Translation.PinCodeMessageIncorrect; pinCodeDlg.DoModal(GUIWindowManager.ActiveWindow); if (!pinCodeDlg.IsCorrect) { MPTVSeriesLog.Write("PinCode entered was incorrect, showing Views Menu"); return; } else logicalView.IsLocked = false; } } } } #endregion m_back_up_select_this = null; switch (this.listLevel) { case Listlevel.Group: this.m_CurrViewStep++; setNewListLevelOfCurrView(m_CurrViewStep); m_stepSelection = new string[] { this.m_Facade.SelectedListItem.Label }; m_stepSelections.Add(m_stepSelection); m_stepSelectionPretty.Add(this.m_Facade.SelectedListItem.Label); MPTVSeriesLog.Write("Group Clicked: ", this.m_Facade.SelectedListItem.Label, MPTVSeriesLog.LogLevel.Debug); LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.Series: this.m_SelectedSeries = this.m_Facade.SelectedListItem.TVTag as DBSeries; if (m_SelectedSeries == null) return; this.m_CurrViewStep++; setNewListLevelOfCurrView(m_CurrViewStep); m_stepSelection = new string[] { m_SelectedSeries[DBSeries.cID].ToString() }; m_stepSelections.Add(m_stepSelection); m_stepSelectionPretty.Add(this.m_SelectedSeries.ToString()); MPTVSeriesLog.Write("Series Clicked: ", m_stepSelection[0], MPTVSeriesLog.LogLevel.Debug); this.LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.Season: this.m_SelectedSeason = this.m_Facade.SelectedListItem.TVTag as DBSeason; if (m_SelectedSeason == null) return; this.m_CurrViewStep++; setNewListLevelOfCurrView(m_CurrViewStep); m_stepSelection = new string[] { m_SelectedSeason[DBSeason.cSeriesID].ToString(), m_SelectedSeason[DBSeason.cIndex].ToString() }; m_stepSelections.Add(m_stepSelection); m_stepSelectionPretty.Add(m_SelectedSeason[DBSeason.cIndex] == 0 ? Translation.specials : Translation.Season + " " + m_SelectedSeason[DBSeason.cIndex]); MPTVSeriesLog.Write("Season Clicked: ", m_stepSelection[0] + " - " + m_stepSelection[1], MPTVSeriesLog.LogLevel.Debug); this.LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.Episode: m_SelectedEpisode = this.m_Facade.SelectedListItem.TVTag as DBEpisode; if (m_SelectedEpisode == null) return; MPTVSeriesLog.Write("Episode Clicked: ", m_SelectedEpisode[DBEpisode.cCompositeID].ToString(), MPTVSeriesLog.LogLevel.Debug); CommonPlayEpisodeAction(); break; } } base.OnClicked(controlId, control, actionType); }
static string replaceSeasonTags(DBSeason s, string what) { if (s == null || what.Length < seasonIdentifier.Length) return what; return getValuesOfType(s, what, seasonParse, seasonIdentifier); }
public static String GetSeasonBannerAsFilename(DBSeason season) { String sFileName = season.Banner; return sFileName; }
private void Group_OnItemSelected(GUIListItem item) { m_SelectedSeries = null; m_SelectedSeason = null; m_SelectedEpisode = null; if (item == null) return; setNewListLevelOfCurrView(m_CurrViewStep); // let's try to give the user a bit more information string groupedBy = m_CurrLView.groupedInfo(m_CurrViewStep); if (groupedBy.Contains("<Ser")) { int count = 0; string seriesNames = string.Empty; SQLCondition cond = new SQLCondition(); cond.AddOrderItem(DBOnlineSeries.Q(DBOnlineSeries.cPrettyName), SQLCondition.orderType.Ascending); cond.SetLimit(20); bool requiresSplit = false; // use sql 'like' for split fields // selected group label string selectedItem = this.m_Facade.SelectedListItem.Label.ToString(); // unknown really is "" so get all with null values here if (selectedItem == Translation.Unknown) { selectedItem = string.Empty; } else if (m_CurrLView.m_steps[m_CurrViewStep].groupedBy.attempSplit) requiresSplit = true; string field = groupedBy.Substring(groupedBy.IndexOf('.') + 1).Replace(">", ""); string tableName = "online_series"; string tableField = tableName + "." + field; string userEditField = tableField + DBTable.cUserEditPostFix; string value = requiresSplit ? "like " + "'%" + selectedItem + "%'" : "= " + "'" + selectedItem + "'"; string sql = string.Empty; // check if the useredit column exists if (DBTable.ColumnExists(tableName, field + DBTable.cUserEditPostFix)) { sql = "(case when (" + userEditField + " is null or " + userEditField + " = " + "'" + "'" + ") " + "then " + tableField + " else " + userEditField + " " + "end) " + value; } else { sql = tableField + " " + value; } cond.AddCustom(sql); if (DBOption.GetOptions(DBOption.cView_Episode_OnlyShowLocalFiles)) { // not generic SQLCondition fullSubCond = new SQLCondition(); fullSubCond.AddCustom(DBOnlineEpisode.Q(DBOnlineEpisode.cSeriesID), DBOnlineSeries.Q(DBOnlineSeries.cID), SQLConditionType.Equal); cond.AddCustom(" exists( " + DBEpisode.stdGetSQL(fullSubCond, false) + " )"); } if (!DBOption.GetOptions(DBOption.cShowHiddenItems)) cond.AddCustom("exists ( select id from local_series where id = online_series.id and hidden = 0)"); foreach (string series in DBOnlineSeries.GetSingleField(DBOnlineSeries.cPrettyName, cond, new DBOnlineSeries())) { seriesNames += series + Environment.NewLine; count++; } setGUIProperty(guiProperty.SeriesCount, count.ToString()); setGUIProperty(guiProperty.Subtitle, count.ToString() + " " + (count == 1 ? Translation.Series : Translation.Series_Plural)); setGUIProperty(guiProperty.Description, seriesNames); } else { clearGUIProperty(guiProperty.Description); clearGUIProperty(guiProperty.Subtitle); } setGUIProperty(guiProperty.Title, item.Label.ToString()); setGUIProperty(guiProperty.Logos, localLogos.getLogos(m_CurrLView.groupedInfo(m_CurrViewStep), this.m_Facade.SelectedListItem.Label, logosHeight, logosWidth)); clearGUIProperty(guiProperty.EpisodeImage); DisableFanart(); }
private void CreateSeasonTree(TreeNode seriesNode, DBSeason season) { Font fontDefault = treeView_Library.Font; TreeNode seasonNode = null; if (season[DBSeason.cIndex] == 0) seasonNode = new TreeNode(Translation.specials); else seasonNode = new TreeNode(Translation.Season + " " + season[DBSeason.cIndex]); seasonNode.Name = DBSeason.cTableName; seasonNode.Tag = (DBSeason)season; seriesNode.Nodes.Add(seasonNode); // set no local files color if (season[DBSeason.cEpisodeCount] == 0) { seasonNode.ForeColor = System.Drawing.SystemColors.GrayText; } else { // set color for watched season if (season[DBSeason.cUnwatchedItems] == 0) seasonNode.ForeColor = System.Drawing.Color.DarkBlue; } // set FontStyle if (season[DBSeason.cHidden]) seasonNode.NodeFont = new Font(fontDefault.Name, fontDefault.Size, FontStyle.Italic); }
public static string getLogos(ref DBSeason season, int imgHeight, int imgWidth) { if (season == null) return null; DBSeason inCache = !Settings.isConfig ? cache.getSeason(season[DBSeason.cSeriesID], season[DBSeason.cIndex]) : null; tmpSeason = inCache == null ? season : inCache; lastResult = getLogos(Level.Season, imgHeight, imgWidth, ref tmpSeason.cachedLogoResults); if (!lastWasCached) cache.addChangeSeason(tmpSeason); return lastResult; }