private int GetTimeStopped(string fileName) { IMDBMovie movieDetails = new IMDBMovie(); VideoDatabase.GetMovieInfo(fileName, ref movieDetails); int idFile = VideoDatabase.GetFileId(fileName); int idMovie = VideoDatabase.GetMovieId(fileName); byte[] resumeData = null; if ((idMovie >= 0) && (idFile >= 0)) { return(VideoDatabase.GetMovieStopTimeAndResumeData(idFile, out resumeData)); } return(0); }
public bool Scrobble(string filename) { StopScrobble(); // stop check if not valid player type for plugin handler if (g_Player.IsTV || g_Player.IsTVRecording || filename == "http://localhost/OnlineVideo.mp4") { return(false); } // lookup movie by filename var movie = new IMDBMovie(); int result = VideoDatabase.GetMovieInfo(filename, ref movie); if (result == -1) { return(false); } CurrentMovie = movie; LastMovie = movie; var scrobbleData = CreateScrobbleData(CurrentMovie); var scrobbleMovie = new Thread((objScrobble) => { var tScrobbleData = objScrobble as TraktScrobbleMovie; if (tScrobbleData == null) { return; } TraktLogger.Info("Sending start scrobble of movie to trakt.tv. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", tScrobbleData.Movie.Title, tScrobbleData.Movie.Year, tScrobbleData.Movie.Ids.Imdb ?? "<empty>"); var response = TraktAPI.TraktAPI.StartMovieScrobble(tScrobbleData); TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Scrobble" }; scrobbleMovie.Start(scrobbleData); return(true); }
/// <summary> /// Create playlist item from a file /// </summary> /// <param name="file">Path to file</param> /// <returns>Playlist item</returns> internal static MediaPortal.Playlists.PlayListItem CreatePlaylistItemFromVideoFile(string file) { FileInfo info = new FileInfo(file); MediaPortal.Playlists.PlayListItem item = new MediaPortal.Playlists.PlayListItem(); item.Description = info.Name; item.FileName = info.FullName; item.Type = PlayListItem.PlayListItemType.Video; //item.Duration IMDBMovie movie = new IMDBMovie(); int id = VideoDatabase.GetMovieInfo(file, ref movie); if (id > 0) { item.Duration = movie.RunTime; } return(item); }
/// <summary> /// Adds a song to a playlist /// </summary> /// <param name="type">Type of the playlist</param> /// <param name="entry">Item that gets added</param> /// <param name="index">Index where the item should be added</param> /// <param name="refresh">Should the playlist be refreshed after the item is added</param> public static void AddItemToPlaylist(String type, PlaylistEntry entry, int index, bool refresh) { PlayListType plType = GetTypeFromString(type); PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer; PlayList playList = playListPlayer.GetPlaylist(plType); PlayListItem item = null; //If it's a music item, try to find it in the db if (plType == PlayListType.PLAYLIST_MUSIC) { MusicDatabase mpMusicDb = MusicDatabase.Instance; Song song = new Song(); bool inDb = mpMusicDb.GetSongByFileName(entry.FileName, ref song); if (inDb) { item = ToPlayListItem(song); } } else if (plType == PlayListType.PLAYLIST_VIDEO) { IMDBMovie movie = new IMDBMovie(); int id = VideoDatabase.GetMovieInfo(entry.FileName, ref movie); if (id > 0) { item = ToPlayListItem(movie); } } if (item == null) { item = new PlayListItem(entry.Name, entry.FileName, entry.Duration); } playList.Insert(item, index); if (refresh) { RefreshPlaylistIfVisible(); } }
/// <summary> /// Examines the current playing movie and fills in all the #tags for the skin. /// For movies it will look in the video database for any IMDB info /// For record TV programs it will look in the TVDatabase for recording info /// </summary> /// <param name="fileName">Filename of the current playing movie</param> /// <remarks> /// Function will fill in the following tags for TV programs /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year, #Play.Current.Channel, /// /// Function will fill in the following tags for movies /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year /// #Play.Current.Director, #cast, #dvdlabel, #imdbnumber, #Play.Current.Plot, #Play.Current.PlotOutline, #rating, #tagline, #votes, #credits /// </remarks> private void SetCurrentFile(string fileName) { GUIPropertyManager.RemovePlayerProperties(); GUIPropertyManager.SetProperty("#Play.Current.Title", Util.Utils.GetFilename(fileName)); GUIPropertyManager.SetProperty("#Play.Current.File", Path.GetFileName(fileName)); GUIPropertyManager.SetProperty("#Play.Current.Thumb", ""); GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", string.Empty); if ((g_Player.IsVideo || g_Player.IsDVD) && !g_Player.IsTV && g_Player.MediaInfo != null) { GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.VideoCodec)); GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", g_Player.MediaInfo.VideoResolution); GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.AudioCodec)); GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", g_Player.MediaInfo.AudioChannelsFriendly); GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", g_Player.MediaInfo.HasSubtitles.ToString()); GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", g_Player.MediaInfo.AspectRatio); } if (g_Player.IsDVD) { // for dvd's the file is in the form c:\media\movies\the matrix\video_ts\video_ts.ifo // first strip the \video_ts\video_ts.ifo string lowPath = fileName.ToLower(); int index = lowPath.IndexOf("video_ts/"); if (index < 0) { index = lowPath.IndexOf(@"video_ts\"); } if (index >= 0) { fileName = fileName.Substring(0, index); fileName = Util.Utils.RemoveTrailingSlash(fileName); // get the name by stripping the first part : c:\media\movies string strName = fileName; int pos = fileName.LastIndexOfAny(new char[] { '\\', '/' }); if (pos >= 0 && pos + 1 < fileName.Length - 1) { strName = fileName.Substring(pos + 1); } GUIPropertyManager.SetProperty("#Play.Current.Title", strName); GUIPropertyManager.SetProperty("#Play.Current.File", strName); // construct full filename as imdb info is stored... fileName += @"\VIDEO_TS\VIDEO_TS.IFO"; } } bool isLive = g_Player.IsTimeShifting; string extension = Path.GetExtension(fileName).ToLower(); if (extension.Equals(".sbe") || extension.Equals(".dvr-ms") || (extension.Equals(".ts") && !isLive || g_Player.IsTVRecording)) { // this is a recorded movie. // check the TVDatabase for the description,genre,title,... if (g_Player.currentTitle != "") { GUIPropertyManager.SetProperty("#Play.Current.Title", g_Player.currentTitle); GUIPropertyManager.SetProperty("#Play.Current.Plot", g_Player.currentTitle + "\n" + g_Player.currentDescription); GUIPropertyManager.SetProperty("#Play.Current.PlotOutline", g_Player.currentDescription); } } /*if (fileName.Substring(0, 4) == "rtsp") * { * GUIPropertyManager.SetProperty("#Play.Current.Title", g_Player.currentTitle); * GUIPropertyManager.SetProperty("#Play.Current.Plot", g_Player.currentTitle + "\n" + g_Player.currentDescription); * GUIPropertyManager.SetProperty("#Play.Current.PlotOutline", g_Player.currentDescription); * }*/ IMDBMovie movieDetails = new IMDBMovie(); bool bMovieInfoFound = false; if (!g_Player.IsTVRecording) { if (VideoDatabase.HasMovieInfo(fileName)) { VideoDatabase.GetMovieInfo(fileName, ref movieDetails); bMovieInfoFound = true; } else if (File.Exists(Path.ChangeExtension(fileName, ".xml"))) { MatroskaTagInfo info = MatroskaTagHandler.Fetch(Path.ChangeExtension(fileName, ".xml")); movieDetails.Title = info.title; movieDetails.Plot = info.description; movieDetails.Genre = info.genre; GUIPropertyManager.SetProperty("#Play.Current.Channel", info.channelName); string logo = Util.Utils.GetCoverArt(Thumbs.TVChannel, info.channelName); if (!Util.Utils.FileExistsInCache(logo)) { logo = "defaultVideoBig.png"; } GUIPropertyManager.SetProperty("#Play.Current.Thumb", logo); _thumbLogo = logo; bMovieInfoFound = true; } if (bMovieInfoFound) { movieDetails.SetPlayProperties(); } else { GUIListItem item = new GUIListItem(); item.IsFolder = false; item.Path = fileName; Util.Utils.SetThumbnails(ref item); GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage); } } else if (g_Player.IsTV && g_Player.IsTimeShifting) { GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.View.channel")); GUIPropertyManager.SetProperty("#Play.Current.Genre", GUIPropertyManager.GetProperty("#TV.View.title")); } else { GUIListItem item = new GUIListItem(); item.IsFolder = false; item.Path = fileName; Util.Utils.SetThumbnails(ref item); GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage); } _thumbLogo = GUIPropertyManager.GetProperty("#Play.Current.Thumb"); }
private void SetIMDBThumbs(ArrayList items) { GUIListItem listItem; ArrayList movies = new ArrayList(); for (int x = 0; x < items.Count; ++x) { listItem = (GUIListItem)items[x]; if (listItem.IsFolder) { if (File.Exists(listItem.Path + @"\VIDEO_TS\VIDEO_TS.IFO")) { movies.Clear(); string pathName = listItem.Path + @"\VIDEO_TS"; VideoDatabase.GetMoviesByPath(pathName, ref movies); for (int i = 0; i < movies.Count; ++i) { IMDBMovie movieDetails = (IMDBMovie)movies[i]; string fileName = "VIDEO_TS.IFO"; if (movieDetails.File[0] == '\\' || movieDetails.File[0] == '/') { movieDetails.File = movieDetails.File.Substring(1); } if (fileName.Length > 0) { if (movieDetails.File == fileName /*|| pItem->GetLabel() == info.Title*/) { if (Util.Utils.IsDVD(listItem.Path)) { listItem.Label = String.Format("({0}:) {1}", listItem.Path.Substring(0, 1), movieDetails.Title); } string coverArtImage = Util.Utils.GetCoverArt(Thumbs.MovieTitle, movieDetails.Title + "{" + movieDetails.ID + "}"); if (Util.Utils.FileExistsInCache(coverArtImage)) { listItem.ThumbnailImage = coverArtImage; listItem.IconImageBig = coverArtImage; listItem.IconImage = coverArtImage; } // look for better thumbs coverArtImage = Util.Utils.ConvertToLargeCoverArt(coverArtImage); if (Util.Utils.FileExistsInCache(coverArtImage)) { listItem.ThumbnailImage = coverArtImage; } break; } } } } } else { // Try to fetch covers for playlist items added from database views int movieId = VideoDatabase.GetMovieId(listItem.Path); if (movieId > 0) { IMDBMovie movie = new IMDBMovie(); VideoDatabase.GetMovieInfoById(movieId, ref movie); listItem.AlbumInfoTag = movie; string cover = Util.Utils.GetCoverArt(Thumbs.MovieTitle, movie.Title + "{" + movieId + "}"); if (Util.Utils.FileExistsInCache(cover)) { listItem.ThumbnailImage = cover; listItem.IconImageBig = cover; listItem.IconImage = cover; } // look for better thumbs cover = Util.Utils.ConvertToLargeCoverArt(cover); if (Util.Utils.FileExistsInCache(cover)) { listItem.ThumbnailImage = cover; } } } } movies.Clear(); VideoDatabase.GetMoviesByPath(currentFolder, ref movies); for (int x = 0; x < items.Count; ++x) { listItem = (GUIListItem)items[x]; if (!listItem.IsFolder) { IMDBMovie movieDetails = new IMDBMovie(); int idMovie = VideoDatabase.GetMovieInfo(listItem.Path, ref movieDetails); if (idMovie >= 0) { string coverArtImage = Util.Utils.GetCoverArt(Thumbs.MovieTitle, movieDetails.Title); if (Util.Utils.FileExistsInCache(coverArtImage)) { listItem.ThumbnailImage = coverArtImage; listItem.IconImageBig = coverArtImage; listItem.IconImage = coverArtImage; } // look for better thumbs coverArtImage = Util.Utils.ConvertToLargeCoverArt(coverArtImage); if (Util.Utils.FileExistsInCache(coverArtImage)) { listItem.ThumbnailImage = coverArtImage; } } else { Util.Utils.SetThumbnails(ref listItem); } } } }
public bool OnPlayDVD(String drive, int parentId) { Log.Info("SelectDVDHandler: OnPlayDVD() playing DVD {0}", drive); if (g_Player.Playing && g_Player.IsDVD) { if (g_Player.CurrentFile.Equals(drive + @"\VIDEO_TS\VIDEO_TS.IFO")) { return(true); } } if (Util.Utils.getDriveType(drive) == 5) //cd or dvd drive { string driverLetter = drive.Substring(0, 1); string fileName = String.Format(@"{0}:\VIDEO_TS\VIDEO_TS.IFO", driverLetter); if (!VirtualDirectories.Instance.Movies.RequestPin(fileName)) { return(false); } if (File.Exists(fileName)) { IMDBMovie movieDetails = new IMDBMovie(); VideoDatabase.GetMovieInfo(fileName, ref movieDetails); int idFile = VideoDatabase.GetFileId(fileName); int idMovie = VideoDatabase.GetMovieId(fileName); int timeMovieStopped = 0; byte[] resumeData = null; if ((idMovie >= 0) && (idFile >= 0)) { timeMovieStopped = VideoDatabase.GetMovieStopTimeAndResumeData(idFile, out resumeData); //Log.Info("GUIVideoFiles: OnPlayBackStopped for DVD - idFile={0} timeMovieStopped={1} resumeData={2}", idFile, timeMovieStopped, resumeData); if (timeMovieStopped > 0) { string title = Path.GetFileName(fileName); VideoDatabase.GetMovieInfoById(idMovie, ref movieDetails); if (movieDetails.Title != string.Empty) { title = movieDetails.Title; } GUIResumeDialog.Result result = GUIResumeDialog.ShowResumeDialog(title, timeMovieStopped, GUIResumeDialog.MediaType.DVD); if (result == GUIResumeDialog.Result.Abort) { return(false); } if (result == GUIResumeDialog.Result.PlayFromBeginning) { timeMovieStopped = 0; } } } if (g_Player.Playing) { g_Player.Stop(); } g_Player.PlayDVD(drive + @"\VIDEO_TS\VIDEO_TS.IFO"); g_Player.ShowFullScreenWindow(); if (g_Player.Playing && timeMovieStopped > 0) { if (g_Player.IsDVD) { g_Player.Player.SetResumeState(resumeData); } else { Log.Debug("SelectDVDHandler.OnPlayDVD - skipping"); g_Player.SeekAbsolute(timeMovieStopped); } } return(true); } } //no disc in drive... GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(3); //my videos Log.Error("SelectDVDHandler: OnPlayDVD() Plz Insert Disk (ShowSelectDriveDialog)"); dlgOk.SetLine(1, 219); //no disc dlgOk.DoModal(parentId); return(false); }
/// <summary> /// Examines the current playing movie and fills in all the properties for the skin. /// For movies it will look in the video database for any IMDB info /// For record TV programs it will look in the TVDatabase for recording info /// </summary> /// <param name="fileName">Filename of the current playing movie</param> /// <remarks> /// Function will fill in the following properties for TV programs /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year, #Play.Current.Channel, /// /// Function will fill in the following properties for movies /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year /// #Play.Current.Director, #cast, #dvdlabel, #imdbnumber, #Play.Current.Plot, #Play.Current.PlotOutline, #rating, #tagline, #votes, #credits /// </remarks> private void SetCurrentFile(string fileName) { // Clear all player properties and the audio / video properties GUIPropertyManager.RemovePlayerProperties(); GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", string.Empty); // Preset title and file GUIPropertyManager.SetProperty("#Play.Current.Title", Util.Utils.GetFilename(fileName)); GUIPropertyManager.SetProperty("#Play.Current.File", Util.Utils.GetFileNameWithExtension(fileName)); // Set audio / video properties if ((g_Player.IsVideo || g_Player.IsDVD) && !g_Player.IsTV && g_Player.MediaInfo != null) { GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.VideoCodec)); GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", g_Player.MediaInfo.VideoResolution); GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.AudioCodec)); GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", g_Player.MediaInfo.AudioChannelsFriendly); GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", g_Player.MediaInfo.HasSubtitles.ToString()); GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", g_Player.MediaInfo.AspectRatio); } // Set the properties and thumb path for movies played with the tv plugin if (g_Player.IsTVRecording) { // Set the thumb path to the tv recorded thumbs cache or to the channel logo string thumb = string.Format("{0}\\{1}{2}", Thumbs.TVRecorded, Path.ChangeExtension(Util.Utils.SplitFilename(g_Player.currentFileName), null), Util.Utils.GetThumbExtension()); if (!Util.Utils.FileExistsInCache(thumb)) { thumb = Util.Utils.GetCoverArt(Thumbs.TVChannel, GUIPropertyManager.GetProperty("#TV.RecordedTV.Channel")); } GUIPropertyManager.SetProperty("#Play.Current.Thumb", thumb); // Set the properties to the #TV.Recorded properties GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.RecordedTV.Title")); GUIPropertyManager.SetProperty("#Play.Current.Plot", GUIPropertyManager.GetProperty("#TV.RecordedTV.Description")); GUIPropertyManager.SetProperty("#Play.Current.Genre", GUIPropertyManager.GetProperty("#TV.RecordedTV.Genre")); GUIPropertyManager.SetProperty("#Play.Current.Channel", GUIPropertyManager.GetProperty("#TV.RecordedTV.Channel")); return; } // Set title and file for DVD if (g_Player.IsDVD) { // for dvd's the file is in the form c:\media\movies\the matrix\video_ts\video_ts.ifo // first strip the \video_ts\video_ts.ifo string lowPath = fileName.ToLowerInvariant(); int index = lowPath.IndexOf("video_ts/"); if (index < 0) { index = lowPath.IndexOf(@"video_ts\"); } if (index >= 0) { fileName = fileName.Substring(0, index); fileName = Util.Utils.RemoveTrailingSlash(fileName); // get the name by stripping the first part : c:\media\movies string strName = fileName; int pos = fileName.LastIndexOfAny(new char[] { '\\', '/' }); if (pos >= 0 && pos + 1 < fileName.Length - 1) { strName = fileName.Substring(pos + 1); } // get the name when play DVD directly from Drive letter List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt(); for (int i = rootDrives.Count - 1; i >= 0; i--) { GUIListItem itemDVDroot = (GUIListItem)rootDrives[i]; string itemDVD = Path.GetPathRoot(itemDVDroot.Path); itemDVD = Util.Utils.RemoveTrailingSlash(itemDVD); if (itemDVD == strName && !String.IsNullOrEmpty(itemDVDroot.DVDLabel)) //cd or dvd drive { strName = itemDVDroot.DVDLabel; } } GUIPropertyManager.SetProperty("#Play.Current.Title", strName); GUIPropertyManager.SetProperty("#Play.Current.File", strName); // construct full filename as imdb info is stored... fileName += @"\VIDEO_TS\VIDEO_TS.IFO"; } } // Get the BD handler ISelectBDHandler selectBdHandler; if (GlobalServiceProvider.IsRegistered <ISelectBDHandler>()) { selectBdHandler = GlobalServiceProvider.Get <ISelectBDHandler>(); } else { selectBdHandler = new SelectBDHandler(); GlobalServiceProvider.Add <ISelectBDHandler>(selectBdHandler); } // Adapt filename for image files if (Util.Utils.IsISOImage(fileName)) { fileName = DaemonTools.MountedIsoFile; } // ------------------------------------------------------- // Try to set the properties and the thumb path in 5 steps bool movieInfoFound = false; bool thumbInfoFound = false; // Step 1 ------------------------------- ------------------------- // Try to set the properties and thumb path from the video database IMDBMovie movie = new IMDBMovie(); string name = fileName; if (fileName.ToLowerInvariant().Contains(".mpls")) // BD folder title check (playlist) { int index = fileName.ToLowerInvariant().LastIndexOf(@"\playlist"); name = fileName.Remove(index) + @"\index.bdmv"; } if (VideoDatabase.HasMovieInfo(name)) { // Set the properties (incuding cover thumb) from the movie info VideoDatabase.GetMovieInfo(name, ref movie); if (movie.ThumbURL.ToLowerInvariant().StartsWith("file://")) { movie.ThumbURL = movie.ThumbURL.Substring(7); } movie.SetPlayProperties(true); movieInfoFound = true; if (!string.IsNullOrEmpty(movie.ThumbURL)) { thumbInfoFound = true; return; } } // Step 2 -------------------------------------------------------- // Try to set the properties and the thumb path from the .nfo file string path = string.Empty; int pathIndex = 0; if (fileName.ToUpperInvariant().Contains(@"\BDMV")) { pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\BDMV"); path = fileName.Remove(pathIndex); } else if (fileName.ToUpperInvariant().Contains(@"\VIDEO_TS\")) { pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\VIDEO_TS\"); path = fileName.Remove(pathIndex); } else if (!String.IsNullOrEmpty(fileName)) { path = Path.GetDirectoryName(fileName); } IMDBMovie.FetchMovieNfo(path, fileName, ref movie); if (!movie.IsEmpty) { // Set the properties (incuding cover thumb) from the .nfo file movie.SetPlayProperties(true); movieInfoFound = true; if (!string.IsNullOrEmpty(movie.ThumbURL)) { thumbInfoFound = true; return; } } // Step 3 ------------------------------------- // Try to set the properties from the .xml file if (File.Exists(Path.ChangeExtension(fileName, ".xml"))) { MatroskaTagInfo info = MatroskaTagHandler.Fetch(Path.ChangeExtension(fileName, ".xml")); if (info != null) { // Set properties from the .xml file movieInfoFound = true; movie.Title = info.Title; movie.Plot = info.Description; movie.Genre = info.Genre; if (thumbInfoFound) { // take previously found thumb movie.ThumbURL = GUIPropertyManager.GetProperty("#Play.Current.Thumb"); } else { // take channel logo (better than nothing, but do not set thumbInfoFound) movie.ThumbURL = Util.Utils.GetCoverArt(Thumbs.TVChannel, info.ChannelName); } movie.SetPlayProperties(true); GUIPropertyManager.SetProperty("#Play.Current.Channel", info.ChannelName); } } // Step 4 ------------------------------------------------------------ // If nothing else helps, try to set the thumb path from the file name if (!thumbInfoFound) { GUIListItem item = new GUIListItem(); item.IsFolder = false; item.Path = fileName; Util.Utils.SetThumbnails(ref item); if (!string.IsNullOrEmpty(item.ThumbnailImage)) { GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage); } } // Step 5 -------------------------------- // All is done if the movie info was found if (movieInfoFound) { return; } // Fallback ---------------------------------------------- // If no movie info could be found, set at least the title if (!movieInfoFound && g_Player.IsTV && g_Player.IsTimeShifting) { // Set the title for live TV GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.View.title")); return; } if (!movieInfoFound && VirtualDirectory.IsImageFile(Path.GetExtension(fileName))) { // Set the title for images string title = Util.Utils.GetFilename(fileName, true); GUIPropertyManager.SetProperty("#Play.Current.Title", title); return; } if (fileName.ToLowerInvariant().Contains("index.bdmv")) { // Set the title for BDs string title = selectBdHandler.GetDiscTitle(fileName); if (String.IsNullOrEmpty(title)) { // get the name when play BD directly from Drive letter List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt(); title = Path.GetPathRoot(fileName); title = Util.Utils.RemoveTrailingSlash(title); for (int i = rootDrives.Count - 1; i >= 0; i--) { GUIListItem itemBDroot = (GUIListItem)rootDrives[i]; string itemBD = Path.GetPathRoot(itemBDroot.Path); itemBD = Util.Utils.RemoveTrailingSlash(itemBD); if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel)) { title = itemBDroot.DVDLabel; } } } GUIPropertyManager.SetProperty("#Play.Current.Title", title); } else if (fileName.ToLowerInvariant().Contains(".mpls")) { // Set the title for BD playlist string title = selectBdHandler.GetDiscTitle(fileName); if (String.IsNullOrEmpty(title)) { // get the name when play BD directly from Drive letter List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt(); title = Path.GetPathRoot(fileName); title = Util.Utils.RemoveTrailingSlash(title); for (int i = rootDrives.Count - 1; i >= 0; i--) { GUIListItem itemBDroot = (GUIListItem)rootDrives[i]; string itemBD = Path.GetPathRoot(itemBDroot.Path); itemBD = Util.Utils.RemoveTrailingSlash(itemBD); if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel)) { title = itemBDroot.DVDLabel; } } } GUIPropertyManager.SetProperty("#Play.Current.Title", title); } }
public bool Scrobble(string filename) { StopScrobble(); // stop check if not valid player type for plugin handler if (g_Player.IsTV || g_Player.IsTVRecording) { return(false); } // lookup movie by filename IMDBMovie movie = new IMDBMovie(); int result = VideoDatabase.GetMovieInfo(filename, ref movie); if (result == -1) { return(false); } CurrentMovie = movie; // create timer 15 minute timer to send watching status #region scrobble timer TraktTimer = new Timer(new TimerCallback((stateInfo) => { Thread.CurrentThread.Name = "Scrobble"; IMDBMovie currentMovie = stateInfo as IMDBMovie; TraktLogger.Info("Scrobbling Movie {0}", currentMovie.Title); // get online runtime if local one unavailable to be retrieved double duration = g_Player.Duration == 0.0 ? currentMovie.RunTime * 60.0 : g_Player.Duration; double progress = 0.0; // get current progress of player (in seconds) to work out percent complete if (duration > 0.0) { progress = (g_Player.CurrentPosition / duration) * 100.0; } TraktLogger.Debug(string.Format("Percentage of {0} is {1}%", currentMovie.Title, progress.ToString("N2"))); // create Scrobbling Data TraktMovieScrobble scrobbleData = CreateScrobbleData(currentMovie); if (scrobbleData == null) { return; } // set duration/progress in scrobble data scrobbleData.Duration = Convert.ToInt32(duration / 60).ToString(); scrobbleData.Progress = Convert.ToInt32(progress).ToString(); // set watching status on trakt TraktResponse response = TraktAPI.TraktAPI.ScrobbleMovieState(scrobbleData, TraktScrobbleStates.watching); TraktLogger.LogTraktResponse(response); }), movie, 3000, 900000); #endregion return(true); }
/// <summary> /// Examines the current playing movie and fills in all the #tags for the skin. /// For movies it will look in the video database for any IMDB info /// For record TV programs it will look in the TVDatabase for recording info /// </summary> /// <param name="fileName">Filename of the current playing movie</param> /// <remarks> /// Function will fill in the following tags for TV programs /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year, #Play.Current.Channel, /// /// Function will fill in the following tags for movies /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year /// #Play.Current.Director, #cast, #dvdlabel, #imdbnumber, #Play.Current.Plot, #Play.Current.PlotOutline, #rating, #tagline, #votes, #credits /// </remarks> private void SetCurrentFile(string fileName) { GUIPropertyManager.RemovePlayerProperties(); GUIPropertyManager.SetProperty("#Play.Current.Title", Util.Utils.GetFilename(fileName)); GUIPropertyManager.SetProperty("#Play.Current.File", Util.Utils.GetFileNameWithExtension(fileName)); GUIPropertyManager.SetProperty("#Play.Current.Thumb", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", string.Empty); GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", string.Empty); if ((g_Player.IsVideo || g_Player.IsDVD) && !g_Player.IsTV && g_Player.MediaInfo != null) { GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.VideoCodec)); GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", g_Player.MediaInfo.VideoResolution); GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.AudioCodec)); GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", g_Player.MediaInfo.AudioChannelsFriendly); GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", g_Player.MediaInfo.HasSubtitles.ToString()); GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", g_Player.MediaInfo.AspectRatio); } if (g_Player.IsDVD) { // for dvd's the file is in the form c:\media\movies\the matrix\video_ts\video_ts.ifo // first strip the \video_ts\video_ts.ifo string lowPath = fileName.ToLowerInvariant(); int index = lowPath.IndexOf("video_ts/"); if (index < 0) { index = lowPath.IndexOf(@"video_ts\"); } if (index >= 0) { fileName = fileName.Substring(0, index); fileName = Util.Utils.RemoveTrailingSlash(fileName); // get the name by stripping the first part : c:\media\movies string strName = fileName; int pos = fileName.LastIndexOfAny(new char[] { '\\', '/' }); if (pos >= 0 && pos + 1 < fileName.Length - 1) { strName = fileName.Substring(pos + 1); } // get the name when play DVD directly from Drive letter List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt(); for (int i = rootDrives.Count - 1; i >= 0; i--) { GUIListItem itemDVDroot = (GUIListItem)rootDrives[i]; string itemDVD = Path.GetPathRoot(itemDVDroot.Path); itemDVD = Util.Utils.RemoveTrailingSlash(itemDVD); if (itemDVD == strName && !String.IsNullOrEmpty(itemDVDroot.DVDLabel)) //cd or dvd drive { strName = itemDVDroot.DVDLabel; } } GUIPropertyManager.SetProperty("#Play.Current.Title", strName); GUIPropertyManager.SetProperty("#Play.Current.File", strName); // construct full filename as imdb info is stored... fileName += @"\VIDEO_TS\VIDEO_TS.IFO"; } } bool isLive = g_Player.IsTimeShifting; string extension = Util.Utils.GetFileExtension(fileName).ToLowerInvariant(); if (extension.Equals(".sbe") || extension.Equals(".dvr-ms") || (extension.Equals(".ts") && !isLive || g_Player.IsTVRecording)) { // this is a recorded movie. // check the TVDatabase for the description,genre,title,... if (g_Player.currentTitle != "") { GUIPropertyManager.SetProperty("#Play.Current.Title", g_Player.currentTitle); GUIPropertyManager.SetProperty("#Play.Current.Plot", g_Player.currentTitle + "\n" + g_Player.currentDescription); GUIPropertyManager.SetProperty("#Play.Current.PlotOutline", g_Player.currentDescription); } } /*if (fileName.Substring(0, 4) == "rtsp") * { * GUIPropertyManager.SetProperty("#Play.Current.Title", g_Player.currentTitle); * GUIPropertyManager.SetProperty("#Play.Current.Plot", g_Player.currentTitle + "\n" + g_Player.currentDescription); * GUIPropertyManager.SetProperty("#Play.Current.PlotOutline", g_Player.currentDescription); * }*/ IMDBMovie movieDetails = new IMDBMovie(); bool bMovieInfoFound = false; ISelectBDHandler selectBdHandler; if (GlobalServiceProvider.IsRegistered <ISelectBDHandler>()) { selectBdHandler = GlobalServiceProvider.Get <ISelectBDHandler>(); } else { selectBdHandler = new SelectBDHandler(); GlobalServiceProvider.Add <ISelectBDHandler>(selectBdHandler); } bool playingRemoteUrl = Util.Utils.IsRemoteUrl(fileName); if (!g_Player.IsTVRecording && !playingRemoteUrl) { // Check if we play image file to search db with the proper filename if (Util.Utils.IsISOImage(fileName)) { fileName = DaemonTools.MountedIsoFile; } if (VideoDatabase.HasMovieInfo(fileName)) { VideoDatabase.GetMovieInfo(fileName, ref movieDetails); bMovieInfoFound = true; } else if (File.Exists(Path.ChangeExtension(fileName, ".xml"))) { MatroskaTagInfo info = MatroskaTagHandler.Fetch(Path.ChangeExtension(fileName, ".xml")); movieDetails.Title = info.title; movieDetails.Plot = info.description; movieDetails.Genre = info.genre; GUIPropertyManager.SetProperty("#Play.Current.Channel", info.channelName); string logo = Util.Utils.GetCoverArt(Thumbs.TVChannel, info.channelName); if (!Util.Utils.FileExistsInCache(logo)) { logo = "defaultVideoBig.png"; } GUIPropertyManager.SetProperty("#Play.Current.Thumb", logo); _thumbLogo = logo; bMovieInfoFound = true; } else // Nfo support { string path = string.Empty; int pathIndex = 0; if (fileName.ToUpperInvariant().Contains(@"\BDMV")) { pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\BDMV"); path = fileName.Remove(pathIndex); } else if (fileName.ToUpperInvariant().Contains(@"\VIDEO_TS\")) { pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\VIDEO_TS\"); path = fileName.Remove(pathIndex); } else if (!String.IsNullOrEmpty(fileName)) { path = Path.GetDirectoryName(fileName); } IMDBMovie.FetchMovieNfo(path, fileName, ref movieDetails); if (!movieDetails.IsEmpty) { bMovieInfoFound = true; } } if (bMovieInfoFound) { movieDetails.SetPlayProperties(true); } else { GUIListItem item = new GUIListItem(); item.IsFolder = false; item.Path = fileName; Util.Utils.SetThumbnails(ref item); GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage); // Image file check to set title for OSD (non db) if (VirtualDirectory.IsImageFile(Path.GetExtension(fileName))) { string title = Util.Utils.GetFilename(fileName, true); GUIPropertyManager.SetProperty("#Play.Current.Title", title); } else if (fileName.ToLowerInvariant().Contains("index.bdmv")) // BD folder title check { string title = selectBdHandler.GetDiscTitle(fileName); // get the name when play BD directly from Drive letter if (String.IsNullOrEmpty(title)) { List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt(); title = Path.GetPathRoot(fileName); title = Util.Utils.RemoveTrailingSlash(title); for (int i = rootDrives.Count - 1; i >= 0; i--) { GUIListItem itemBDroot = (GUIListItem)rootDrives[i]; string itemBD = Path.GetPathRoot(itemBDroot.Path); itemBD = Util.Utils.RemoveTrailingSlash(itemBD); if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel)) //cd or dvd drive { title = itemBDroot.DVDLabel; } } } GUIPropertyManager.SetProperty("#Play.Current.Title", title); } else if (fileName.ToLowerInvariant().Contains(".mpls")) // BD folder title check (playlist) { // Check if index.bdmv is in the VDB int index = fileName.ToLowerInvariant().LastIndexOf(@"\playlist"); string name = fileName.Remove(index); name = name + @"\index.bdmv"; if (VideoDatabase.HasMovieInfo(name)) { VideoDatabase.GetMovieInfo(name, ref movieDetails); movieDetails.SetPlayProperties(); } else { string title = selectBdHandler.GetDiscTitle(fileName); // get the name when play BD directly from Drive letter if (String.IsNullOrEmpty(title)) { List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt(); title = Path.GetPathRoot(fileName); title = Util.Utils.RemoveTrailingSlash(title); for (int i = rootDrives.Count - 1; i >= 0; i--) { GUIListItem itemBDroot = (GUIListItem)rootDrives[i]; string itemBD = Path.GetPathRoot(itemBDroot.Path); itemBD = Util.Utils.RemoveTrailingSlash(itemBD); if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel)) //cd or dvd drive { title = itemBDroot.DVDLabel; } } } GUIPropertyManager.SetProperty("#Play.Current.Title", title); } } } } else if (g_Player.IsTV && g_Player.IsTimeShifting) { GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.View.channel")); GUIPropertyManager.SetProperty("#Play.Current.Genre", GUIPropertyManager.GetProperty("#TV.View.title")); } else { GUIListItem item = new GUIListItem(); item.IsFolder = false; item.Path = fileName; Util.Utils.SetThumbnails(ref item); GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage); } _thumbLogo = GUIPropertyManager.GetProperty("#Play.Current.Thumb"); }
// Changed - cover for movies with the same name public void SetIMDBThumbs(IList items, bool markWatchedFiles, bool eachMovieHasDedicatedFolder) { GUIListItem pItem; IMDBMovie movieDetails = new IMDBMovie(); for (int x = 0; x < items.Count; x++) { string strThumb = string.Empty; pItem = (GUIListItem)items[x]; string file = string.Empty; bool isFolderPinProtected = (pItem.IsFolder && IsFolderPinProtected(pItem.Path)); // Skip DVD backup folder if (pItem.IsFolder && !IsDvdDirectory(pItem.Path)) { if (pItem.Label == "..") { continue; } if (isFolderPinProtected) { // hide maybe rated content Util.Utils.SetDefaultIcons(pItem); continue; } // If this is enabled you'll see the thumb of the first movie in that dir - but if you put serveral movies into that dir you'll be irritated... else { if (eachMovieHasDedicatedFolder) { file = GetFolderVideoFile(pItem.Path); } } } // If folder is DVD backup folder then take it for watched status else if (pItem.IsFolder && IsDvdDirectory(pItem.Path)) { file = GetFolderVideoFile(pItem.Path); } else if (!pItem.IsFolder || (pItem.IsFolder && VirtualDirectory.IsImageFile(Path.GetExtension(pItem.Path).ToLower()))) { file = pItem.Path; } else { continue; } if (!string.IsNullOrEmpty(file)) { int fileId = VideoDatabase.GetFileId(file); int id = VideoDatabase.GetMovieInfo(file, ref movieDetails); bool foundWatched = false; // Set thumb for movies if (id >= 0) { if (Util.Utils.IsDVD(pItem.Path)) { pItem.Label = String.Format("({0}:) {1}", pItem.Path.Substring(0, 1), movieDetails.Title); } string titleExt = movieDetails.Title + "{" + movieDetails.ID + "}"; strThumb = Util.Utils.GetCoverArt(Thumbs.MovieTitle, titleExt); } // Find watched status for videos if (fileId >= 0 && markWatchedFiles) { if (VideoDatabase.GetmovieWatchedStatus(VideoDatabase.GetMovieId(file))) { foundWatched = true; } } // Set watched status for list item if (!pItem.IsFolder || (IsDvdDirectory(pItem.Path) && foundWatched)) { pItem.IsPlayed = foundWatched; } if (!Util.Utils.FileExistsInCache(strThumb) || string.IsNullOrEmpty(strThumb)) { strThumb = string.Format(@"{0}\{1}", Thumbs.MovieTitle, Util.Utils.MakeFileName(Util.Utils.SplitFilename(Path.ChangeExtension(file, ".jpg")))); if (!Util.Utils.FileExistsInCache(strThumb)) { continue; } } pItem.ThumbnailImage = strThumb; pItem.IconImageBig = strThumb; pItem.IconImage = strThumb; strThumb = Util.Utils.ConvertToLargeCoverArt(strThumb); if (Util.Utils.FileExistsInCache(strThumb)) { pItem.ThumbnailImage = strThumb; } } // <-- file == empty } // of for (int x = 0; x < items.Count; ++x) }