/// <summary> /// Returns latest added Pictures db. /// </summary> /// <param name="type">Type of data to fetch</param> /// <returns>Resultset of matching data</returns> private LatestsCollection GetLatestPictures() { latestPictures = new LatestsCollection(); latestPicturesFiles = new Hashtable(); if (!PictureDatabase.DbHealth) { return(latestPictures); } int x = 0; try { CurrentFacade.HasNew = false; string sqlQuery = "SELECT strFile, strDateTaken FROM picture" + (PictureDatabase.FilterPrivate ? " WHERE idPicture NOT IN (SELECT DISTINCT idPicture FROM picturekeywords WHERE strKeyword = 'Private')" : string.Empty) + " ORDER BY strDateTaken DESC LIMIT " + Utils.FacadeMaxNum + ";"; List <PictureData> pictures = PictureDatabase.GetPicturesByFilter(sqlQuery, "pictures"); if (pictures != null) { if (pictures.Count > 0) { int i0 = 1; for (int i = 0; i < pictures.Count; i++) { string filename = pictures[i].FileName; if (string.IsNullOrEmpty(filename)) { continue; } // string thumb = String.Format(@"{0}\{1}L.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename)); string thumb = MediaPortal.Util.Utils.GetPicturesLargeThumbPathname(filename); if (!File.Exists(thumb)) { // thumb = String.Format(@"{0}\{1}.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename)); thumb = MediaPortal.Util.Utils.GetPicturesThumbPathname(filename); if (!File.Exists(thumb)) { // thumb = "DefaultPictureBig.png"; thumb = filename; } } if (!File.Exists(thumb)) { continue; } bool isnew = false; isnew = (pictures[i].DateTaken > Utils.NewDateTime); if (isnew) { CurrentFacade.HasNew = true; } string title = Path.GetFileNameWithoutExtension(Utils.GetFilenameNoPath(filename)).ToUpperInvariant(); string exif = string.Empty; string exifoutline = string.Empty; if (File.Exists(filename)) { using (ExifMetadata extractor = new ExifMetadata()) { ExifMetadata.Metadata metaData = extractor.GetExifMetadata(filename); if (!metaData.IsEmpty()) { exif = metaData.ToString(); exifoutline = metaData.ToShortString(); } } } latestPictures.Add(new Latest() { DateTimeAdded = pictures[i].DateTaken, Title = title, Subtitle = exifoutline, Thumb = thumb, Fanart = filename, Classification = exif, IsNew = isnew }); latestPicturesFiles.Add(i0, filename); Utils.ThreadToSleep(); x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } } } } catch (Exception ex) { logger.Error("GetLatestPictures: " + ex.ToString()); } return(latestPictures); }
internal LatestsCollection GetTVRecordings() { UpdateSheduledTVRecordings(); if (TVHome.Connected) { LatestMediaHandler.LatestsCollection resultTmp = new LatestMediaHandler.LatestsCollection(); LatestsCollection latests = new LatestsCollection(); try { IList <TvDatabase.Recording> recordings = TvDatabase.Recording.ListAll(); int x = 0; int i0 = 1; foreach (TvDatabase.Recording rec in recordings) { if (!Utils.LatestTVRecordingsUnfinished && IsRecordingActual(rec)) { continue; } if (Utils.LatestTVRecordingsWatched && (rec.TimesWatched > 0)) { continue; } latests.Add(new Latest() { DateTimeAdded = rec.StartTime, DateTimeWatched = rec.EndTime, Thumb = "defaultTVBig.png", Title = rec.Title, Genre = rec.Genre, SeriesIndex = rec.SeriesNum, EpisodeIndex = rec.EpisodeNum, ThumbSeries = rec.EpisodeName, Summary = rec.Description, Playable = rec }); Utils.ThreadToSleep(); } // parent.CurrentFacade.Facade = Utils.GetLatestsFacade(parent.CurrentFacade.ControlID); if (parent.CurrentFacade.Facade != null) { Utils.ClearFacade(ref parent.CurrentFacade.Facade); } if (facadeCollection != null) { facadeCollection.Clear(); } // latests.Sort(new LatestAddedComparerDesc()); Utils.SortLatests(ref latests, parent.CurrentFacade.Type, parent.CurrentFacade.LeftToRight); latestTVRecordings = new Hashtable(); for (int x0 = 0; x0 < latests.Count; x0++) { string _filename = ((Recording)latests[x0].Playable).FileName; string thumbNail = string.Empty; if (LatestMediaHandlerSetup.MpVersion.CompareTo("1.03") > 0) { // MP 1.4 logger.Debug("GetTVRecordings [" + LatestMediaHandlerSetup.MpVersion + "] Thumbs method: 1.4 and above ..."); thumbNail = TVRecordingsThumbnailHandler.GetThumb(_filename); } else { // MP 1.3 or older logger.Debug("GetTVRecordings [" + LatestMediaHandlerSetup.MpVersion + "] Thumbs method: 1.3 or older ..."); thumbNail = string.Format(CultureInfo.CurrentCulture, "{0}\\{1}{2}", Thumbs.TVRecorded, Path.ChangeExtension(MediaPortal.Util.Utils.SplitFilename(_filename), null), MediaPortal.Util.Utils.GetThumbExtension()); if (File.Exists(thumbNail)) { string tmpThumbNail = MediaPortal.Util.Utils.ConvertToLargeCoverArt(thumbNail); if (File.Exists(tmpThumbNail)) { thumbNail = tmpThumbNail; } } if (!File.Exists(thumbNail)) { thumbNail = string.Format(CultureInfo.CurrentCulture, "{0}{1}", Path.ChangeExtension(_filename, null), MediaPortal.Util.Utils.GetThumbExtension()); } if (!File.Exists(thumbNail)) { thumbNail = "defaultTVBig.png"; } } latests[x0].Fanart = (Utils.FanartHandler ? UtilsFanartHandler.GetFanartForLatest(latests[x0].Title) : string.Empty); latests[x0].Directory = Utils.GetGetDirectoryName(TVUtil.GetFileNameForRecording(((Recording)latests[x0].Playable))); latests[x0].Thumb = thumbNail; resultTmp.Add(latests[x0]); if (result == null || result.Count == 0) { result = resultTmp; } latestTVRecordings.Add(i0, latests[x].Playable); AddToFilmstrip(parent.CurrentFacade.Facade, latests[x], i0); x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } Utils.UpdateFacade(ref parent.CurrentFacade.Facade, parent.CurrentFacade); if (latests != null) { latests.Clear(); } latests = null; } catch (FileNotFoundException) { //do nothing } catch (MissingMethodException) { //do nothing } catch (Exception ex) { if (latests != null) { latests.Clear(); } latests = null; logger.Error("GetTVRecordings: " + ex.ToString()); } result = resultTmp; } return(result); }
/// <summary> /// Returns latest added movie thumbs from MyVideos db. /// </summary> /// <param name="type">Type of data to fetch</param> /// <returns>Resultset of matching data</returns> private LatestsCollection GetLatestMyVideos() { latestMyVideos = new LatestsCollection(); latestMyVideosForPlay = new Hashtable(); LatestsCollection latests = new LatestsCollection(); try { CurrentFacade.HasNew = false; ArrayList movies = new ArrayList(); string orderClause = "order by movieinfo."; switch (CurrentFacade.Type) { case LatestsFacadeType.Rated: orderClause = orderClause + "fRating"; break; case LatestsFacadeType.Watched: orderClause = orderClause + "dateWatched"; break; default: orderClause = orderClause + "dateAdded"; break; } orderClause = orderClause + " DESC limit 50"; string fromClause = "movie,movieinfo,path"; string whereClause = "where movieinfo.idmovie=movie.idmovie and movie.idpath=path.idpath"; if (CurrentFacade.Type == LatestsFacadeType.Watched) { whereClause = whereClause + " and movieinfo.iswatched=1"; } else if (CurrentFacade.UnWatched) { whereClause = whereClause + " and movieinfo.iswatched=0"; } string sql = String.Format("select movieinfo.fRating,movieinfo.strCredits,movieinfo.strTagLine,movieinfo.strPlotOutline, " + "movieinfo.strPlot,movieinfo.strPlotOutline,movieinfo.strVotes,movieinfo.strCast,movieinfo.iYear,movieinfo.strGenre,movieinfo.strPictureURL, " + "movieinfo.strTitle,path.strPath,movie.discid,movieinfo.IMDBID,movieinfo.idMovie,path.cdlabel,movieinfo.mpaa,movieinfo.runtime, " + "movieinfo.iswatched, movieinfo.dateAdded,movieinfo.dateWatched from {0} {1} {2}", fromClause, whereClause, orderClause); VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false, false); int x = 0; string sTimestamp = string.Empty; foreach (IMDBMovie item in movies) { if (item.IsEmpty) { continue; } if (!CheckItem(item.Path)) { sTimestamp = item.DateAdded; string titleExt = item.Title + "{" + item.ID + "}"; string thumb = MediaPortal.Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); //item.ThumbURL; if (string.IsNullOrEmpty(thumb)) { thumb = "DefaultVideoBig.png"; // "DefaultFolderBig.png"; } bool isnew = false; try { DateTime dTmp = DateTime.Parse(sTimestamp); isnew = ((dTmp > Utils.NewDateTime) && (item.Watched <= 0)); if (isnew) { CurrentFacade.HasNew = true; } } catch { } string fbanner = string.Empty; string fclearart = string.Empty; string fclearlogo = string.Empty; string fcd = string.Empty; string aposter = string.Empty; string abg = string.Empty; if (Utils.FanartHandler) { Parallel.Invoke ( () => fbanner = UtilsFanartHandler.GetFanartTVForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesBanner), () => fclearart = UtilsFanartHandler.GetFanartTVForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesClearArt), () => fclearlogo = UtilsFanartHandler.GetFanartTVForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesClearLogo), () => fcd = UtilsFanartHandler.GetFanartTVForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesCDArt), () => aposter = UtilsFanartHandler.GetAnimatedForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.Animated.MoviesPoster), () => abg = UtilsFanartHandler.GetAnimatedForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.Animated.MoviesBackground) ); } latests.Add(new Latest(sTimestamp, thumb, GetFanart(item.Title, item.ID), item.Title, item.PlotOutline, null, null, item.Genre, item.Rating.ToString(CultureInfo.CurrentCulture), Math.Round(item.Rating, MidpointRounding.AwayFromZero).ToString(CultureInfo.CurrentCulture), item.MPARating, (item.RunTime).ToString(), item.Year.ToString(CultureInfo.CurrentCulture), null, null, null, item, item.ID.ToString(), item.Plot, null, fbanner, fclearart, fclearlogo, fcd, aposter, abg, isnew)); latests[latests.Count - 1].DateWatched = item.DateWatched; Utils.ThreadToSleep(); x++; if (x == Utils.FacadeMaxNum) { break; } } } if (movies != null) { movies.Clear(); } movies = null; Utils.SortLatests(ref latests, CurrentFacade.Type, CurrentFacade.LeftToRight); for (int x0 = 0; x0 < latests.Count; x0++) { try { DateTime dTmp = DateTime.Parse(latests[x0].DateAdded); latests[x0].DateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp); } catch { } latestMyVideos.Add(latests[x0]); latestMyVideosForPlay.Add(x0 + 1, latests[x0].Playable); } } catch (Exception ex) { logger.Error("GetLatestMyVideos: " + ex.ToString()); } if (latests != null) { latests.Clear(); } latests = null; if (latestMyVideos != null && !MainFacade) { logger.Debug("GetLatest: " + this.ToString() + ":" + CurrentFacade.ControlID + " - " + latestMyVideos.Count); } return(latestMyVideos); }