Beispiel #1
0
        protected override void OnPageDestroy(int newWindowId)
        {
            if ((_scanThread != null) && (_scanThread.IsAlive))
            {
                _scanThread.Abort();
                _scanThread = null;
            }

            // Refresh actor info
            if (_currentActor != null)
            {
                _currentActor = VideoDatabase.GetActorInfo(_currentActor.ID);
                SaveState();
                //Clean properties
                _currentActor.ResetProperties();
            }

            ReleaseResources();
            base.OnPageDestroy(newWindowId);
        }
        private void OnItemSelected(GUIListItem item, GUIControl parent)
        {
            if (item.Label == "..")
            {
                IMDBMovie notMovie = new IMDBMovie();
                notMovie.SetProperties(true, string.Empty);
                IMDBActor notActor = new IMDBActor();
                notActor.SetProperties();
                return;
            }
            IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;

            if (movie == null)
            {
                movie = new IMDBMovie();
            }

            ArrayList files = new ArrayList();

            VideoDatabase.GetFilesForMovie(movie.ID, ref files);

            if (files.Count > 0)
            {
                movie.SetProperties(false, (string)files[0]);
            }
            else
            {
                movie.SetProperties(false, string.Empty);
            }

            if (movie.ID >= 0)
            {
                string titleExt      = movie.Title + "{" + movie.ID + "}";
                string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);

                if (Util.Utils.FileExistsInCache(coverArtImage))
                {
                    facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
                }
            }
        }
Beispiel #3
0
        public static bool FindMovieID(string title, int year, string imdbid, ref IMDBMovie imdbMovie)
        {
            // get all movies
            ArrayList myvideos = new ArrayList();

            VideoDatabase.GetMovies(ref myvideos);

            // get all movies in local database
            List <IMDBMovie> movies = (from IMDBMovie m in myvideos select m).ToList();

            // try find a match
            IMDBMovie movie = movies.Find(m => BasicHandler.GetProperMovieImdbId(m.IMDBNumber) == imdbid || (string.Compare(m.Title, title, true) == 0 && m.Year == year));

            if (movie == null)
            {
                return(false);
            }

            imdbMovie = movie;
            return(true);
        }
Beispiel #4
0
        internal void PlayMovie(int index)
        {
            GUIVideoFiles.Reset(); // reset pincode
            ArrayList files = new ArrayList();

            IMDBMovie movie = (IMDBMovie)latestMyVideosForPlay[index];

            VideoDatabase.GetFilesForMovie(movie.ID, ref files);

            if (files.Count > 1)
            {
                GUIVideoFiles.StackedMovieFiles = files;
                GUIVideoFiles.IsStacked         = true;
            }
            else
            {
                GUIVideoFiles.IsStacked = false;
            }

            GUIVideoFiles.MovieDuration(files, false);
            GUIVideoFiles.PlayMovie(movie.ID, false);
        }
Beispiel #5
0
        public static LatestMediaHandler.MQTTItem CheckDB(string SearchFile)
        {
            LatestMediaHandler.MQTTItem item = new LatestMediaHandler.MQTTItem();
            if (MQTTPlugin.DebugMode)
            {
                Logger.Debug("Check to see if video is in MyVideos database.");
            }

            if (MQTTPlugin.DebugMode)
            {
                Logger.Debug("MyVideo found, searching Database for: " + SearchFile);
            }
            try
            {
                IMDBMovie movie   = new IMDBMovie();
                int       movieID = VideoDatabase.GetMovieId(SearchFile);
                VideoDatabase.GetMovieInfoById(movieID, ref movie);
                if (movie.ID > 0)
                {
                    if (MQTTPlugin.DebugMode)
                    {
                        Logger.Debug("Video is in MyVideos database.");
                    }
                    item.Id       = movie.IMDBNumber;
                    item.Title    = movie.Title + " (" + movie.Year + ")";
                    item.Filename = SearchFile;
                    item.Genres   = movie.Genre;
                    item.GetArtwork("movie");
                }
            }
            catch (Exception e)
            {
                Logger.Error("Error getting info from MyVideo Database: " + e.Message);
            }

            return(item);
        }
Beispiel #6
0
        protected override void OnShowContextMenu()
        {
            GUIListItem item   = facadeLayout.SelectedListItem;
            int         itemNo = facadeLayout.SelectedListItemIndex;

            if (item == null)
            {
                return;
            }

            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;

            if (movie == null)
            {
                Dialog_ProtectedContent(dlg);
                return;
            }

            // Actor group view
            if (handler.CurrentLevelWhere == "actor")
            {
                dlg.Reset();
                dlg.SetHeading(498); // menu

                IMDBActor actor = VideoDatabase.GetActorInfo(movie.ActorID);

                if (actor != null)
                {
                    dlg.AddLocalizedString(368); //IMDB
                }

                if (protectedShares.Count > 0)
                {
                    if (ageConfirmed)
                    {
                        dlg.AddLocalizedString(1240); //Lock content
                    }
                    else
                    {
                        dlg.AddLocalizedString(1241); //Unlock content
                    }
                }

                dlg.DoModal(GetID);

                if (dlg.SelectedId == -1)
                {
                    return;
                }

                switch (dlg.SelectedId)
                {
                case 368: // IMDB
                    OnVideoArtistInfo(actor);
                    break;

                case 1240: // Protected content
                case 1241: // Protected content
                    OnContentLock();
                    break;
                }
                return;
            }
            // Context menu on folders (Group names)
            if (movie.ID < 0)
            {
                Dialog_ProtectedContent(dlg);
                return;
            }
            // Context menu on movie title
            dlg.Reset();
            dlg.SetHeading(498); // menu

            if (handler.CurrentLevelWhere == "title")
            {
                dlg.AddLocalizedString(368); //IMDB
                dlg.AddLocalizedString(208); //play
                dlg.AddLocalizedString(926); //add to playlist
                dlg.AddLocalizedString(925); //delete
            }

            if (protectedShares.Count > 0)
            {
                if (ageConfirmed)
                {
                    dlg.AddLocalizedString(1240); //Lock content
                }
                else
                {
                    dlg.AddLocalizedString(1241); //Unlock content
                }
            }

            dlg.DoModal(GetID);
            if (dlg.SelectedId == -1)
            {
                return;
            }
            switch (dlg.SelectedId)
            {
            case 925: // Delete
                OnDeleteItem(item);
                break;

            case 368: // IMDB
                OnInfo(itemNo);
                break;

            case 208: // play
                OnClick(itemNo);
                break;

            case 926: //add to playlist
                OnQueueItem(itemNo);
                break;

            case 1240: //Lock content
            case 1241: //Unlock content
                OnContentLock();
                break;
            }
        }
Beispiel #7
0
        private void SetNewproperties()
        {
            _currentActor.SortActorMoviesByYear();

            for (int i = 0; i < _currentActor.Count; ++i)
            {
                string line = String.Format("{0}. {1} ({2})",
                                            _currentActor[i].Year,
                                            _currentActor[i].MovieTitle,
                                            _currentActor[i].Role);
                //List view
                var item = new GUIListItem();
                item.ItemId = i;
                item.Label  = line.Replace("()", string.Empty).Trim(); // Year+Title+Role (visible on screen item)

                if (_currentActor[i].MoviePlot == "-" || _currentActor[i].MoviePlot == Strings.Unknown)
                {
                    _currentActor[i].MoviePlot = string.Empty; // Plot
                }
                item.AlbumInfoTag = Actor[i];

                string filenameL = string.Empty;
                string path      = string.Empty;
                // Find image
                if (VideoDatabase.CheckMovieImdbId(_currentActor[i].MovieImdbID))
                {
                    string ttFolder   = Regex.Replace(_currentActor[i].MovieImdbID, "(tt(0*))", string.Empty);
                    int    i_ttFolder = 0;
                    int.TryParse(ttFolder, out i_ttFolder);
                    i_ttFolder = i_ttFolder / 25000; // 25000 thumbs in one folder
                    ttFolder   = i_ttFolder.ToString();
                    path       = string.Format(@"{0}\Videos\Actors\ActorsMovies\{1}\", Config.GetFolder(Config.Dir.Thumbs), ttFolder);
                    filenameL  = _currentActor[i].MovieImdbID + ".jpg";

                    if (File.Exists(path + filenameL))
                    {
                        filenameL      = path + filenameL; // Movie cover file
                        item.IconImage = filenameL;
                    }
                    else
                    {
                        filenameL      = string.Empty; // Movie cover file
                        item.IconImage = string.Empty;
                    }
                }

                // Show in list if user have that movie in collection (played property = true)
                ArrayList movies = new ArrayList();
                string    sql    = string.Format("SELECT * FROM movieinfo WHERE IMDBID = '{0}'", _currentActor[i].MovieImdbID);
                VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false, false, false);

                if (movies.Count > 0) // We have a movie, color normal or color played for watched
                {
                    IMDBMovie movie = new IMDBMovie();
                    movie         = (IMDBMovie)movies[0];
                    item.DVDLabel = movie.ID.ToString(); // DVD label holds videodatabase movieID
                    item.IsPlayed = true;
                }

                item.ThumbnailImage  = filenameL;
                item.OnItemSelected += OnItemSelected;
                listActorMovies.Add(item);
            }


            if (listActorMovies.ListItems.Count == 0)
            {
                GUIListItem item = new GUIListItem();
                item.Label = GUILocalizeStrings.Get(284);
                IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
                movie             = new IMDBMovie();
                item.AlbumInfoTag = movie;
                listActorMovies.Add(item);
            }

            _currentSelectedItem = 0;
            string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieActors, _currentActor.ID.ToString());

            if (imgCoverArt != null)
            {
                imgCoverArt.Dispose();
                imgCoverArt.SetFileName(largeCoverArtImage);
                imgCoverArt.AllocResources();
            }

            // Update skin controls visibility
            Update();

            // Restore screen from last session if needed
            LoadState();
        }
        protected virtual void SetLabels()
        {
            bool isShareView = false;

            if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS)
            {
                isShareView = true;
            }

            for (int i = 0; i < facadeLayout.Count; ++i)
            {
                GUIListItem item  = facadeLayout[i];
                IMDBMovie   movie = item.AlbumInfoTag as IMDBMovie;

                if (movie != null && movie.ID > 0 && !isShareView &&
                    (!item.IsFolder || CurrentSortMethod == VideoSort.SortMethod.NameAll))
                {
                    if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll)
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            // Show real movie duration (from video file)
                            int mDuration = VideoDatabase.GetMovieDuration(movie.ID);

                            if (mDuration <= 0)
                            {
                                ArrayList mFiles = new ArrayList();
                                VideoDatabase.GetFilesForMovie(movie.ID, ref mFiles);
                                mDuration = GUIVideoFiles.MovieDuration(mFiles, true);

                                if (mDuration <= 0)
                                {
                                    item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60);
                                }
                                else
                                {
                                    item.Label2 = Util.Utils.SecondsToHMString(mDuration);
                                }
                            }
                            else
                            {
                                item.Label2 = Util.Utils.SecondsToHMString(mDuration);
                            }
                        }
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Year)
                    {
                        item.Label2 = movie.Year.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Rating)
                    {
                        item.Label2 = movie.Rating.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Label)
                    {
                        item.Label2 = movie.DVDLabel.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Size)
                    {
                        if (item.FileInfo != null)
                        {
                            item.Label2 = Util.Utils.GetSize(item.FileInfo.Length);
                        }
                        else
                        {
                            item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60);
                        }
                    }
                }
                else
                {
                    string strSize1 = string.Empty, strDate = string.Empty;

                    if (item.FileInfo != null && !item.IsFolder)
                    {
                        strSize1 = Util.Utils.GetSize(item.FileInfo.Length);
                    }
                    if (item.FileInfo != null && !item.IsFolder)
                    {
                        if (CurrentSortMethod == VideoSort.SortMethod.Modified)
                        {
                            strDate = item.FileInfo.ModificationTime.ToShortDateString() + " " +
                                      item.FileInfo.ModificationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                        }
                        else
                        {
                            strDate = item.FileInfo.CreationTime.ToShortDateString() + " " +
                                      item.FileInfo.CreationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                        }
                    }
                    if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll)
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            item.Label2 = strSize1;
                        }
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Created || CurrentSortMethod == VideoSort.SortMethod.Date || CurrentSortMethod == VideoSort.SortMethod.Modified)
                    {
                        item.Label2 = strDate;
                    }
                    else
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            item.Label2 = strSize1;
                        }
                    }
                }
            }
        }
Beispiel #9
0
        public void SyncProgress()
        {
            if (!TraktSettings.SyncPlayback || SyncPlaybackInProgress)
            {
                return;
            }

            SyncPlaybackInProgress = true;

            TraktLogger.Info("My Videos Starting Playback Sync");

            // get playback data from trakt
            string lastPausedAtMovie;
            var    playbackData = TraktCache.GetPausedMovies(out lastPausedAtMovie);

            if (playbackData == null)
            {
                TraktLogger.Warning("Failed to get resume data from trakt.tv");
                SyncPlaybackInProgress = false;
                return;
            }

            DateTime lastPausedItemProcessed;

            DateTime.TryParse(lastPausedAtMovie, out lastPausedItemProcessed);
            TraktLogger.Info("Found {0} movies on trakt.tv with resume data, processing paused movies after {1}", playbackData.Where(p => p.Type == "movie").Count(), lastPausedAtMovie);

            foreach (var item in playbackData.Where(p => p.Type == "movie"))
            {
                DateTime itemPausedAt;
                if (DateTime.TryParse(item.PausedAt, out itemPausedAt))
                {
                    // check if we need to process
                    if (itemPausedAt <= lastPausedItemProcessed)
                    {
                        continue;
                    }
                }

                // get movie from local database if it exists
                var movie = GetMovies().FirstOrDefault(m => ((m.IMDBNumber == item.Movie.Ids.Imdb) && !string.IsNullOrEmpty(item.Movie.Ids.Imdb) ||
                                                             m.Title.ToLowerInvariant() == item.Movie.Title.ToLowerInvariant() && m.Year == item.Movie.Year));

                if (movie == null)
                {
                    continue;
                }

                // if the local playtime is not known then skip
                if (movie.Duration <= 0)
                {
                    TraktLogger.Warning("Skipping item with invalid runtime in database, Title = '{0}', Year = '{1}', IMDb ID = '{2}'", item.Movie.Title, item.Movie.Year, item.Movie.Ids.Imdb);
                    continue;
                }

                // update the stop time based on percentage watched
                // the video database stores duration in seconds (runtime in minutes if duration not available) and stopTime in secs
                var resumeData = Convert.ToInt32(movie.Duration * (item.Progress / 100.0)) - TraktSettings.SyncResumeDelta;
                if (resumeData < 0)
                {
                    resumeData = 0;
                }

                if (string.IsNullOrEmpty(movie.VideoFileName))
                {
                    TraktLogger.Warning("Skipping item with invalid filename in database, Title = '{0}', Year = '{1}', IMDb ID = '{2}'", item.Movie.Title, item.Movie.Year, item.Movie.Ids.Imdb);
                    continue;
                }

                // if we are syncing on plugin entry we could possibly still be sending paused data to trakt
                // after stopping video (stopping video == re-entry to plugin), prevent possibly reverting stale resumed data
                // we already have updated resume data when stopping video in real-time
                if (TraktSettings.SyncPlaybackOnEnterPlugin && LastMovie != null && LastMovie.VideoFileName == movie.VideoFileName)
                {
                    continue;
                }

                // check if movie is restricted
                if (TraktSettings.BlockedFilenames.Any(f => f == movie.VideoFileName) || TraktSettings.BlockedFolders.Any(f => f == Path.GetDirectoryName(movie.VideoFileName)))
                {
                    TraktLogger.Info("Ignoring resume data sync for movie, filename/folder is ignored by user. Title = '{0}', Year = '{1}', IMDb ID = '{2}', Filename = '{3}'", item.Movie.Title, item.Movie.Year, item.Movie.Ids.Imdb, movie.VideoFileName);
                    continue;
                }

                // Get FileId from filename
                int fileId = VideoDatabase.GetMovieId(movie.VideoFileName);

                // get current stop time for movie
                int currentResumeData = VideoDatabase.GetMovieStopTime(fileId);

                if (currentResumeData != resumeData)
                {
                    // Note: will need to be a bit smarter for multi-part files (who the heck still does that!)
                    TraktLogger.Info("Setting resume time '{0}' for movie, Title = '{1}', Year = '{2}', IMDb ID = '{3}'", new TimeSpan(0, 0, 0, resumeData), item.Movie.Title, item.Movie.Year, item.Movie.Ids.Imdb);

                    VideoDatabase.SetMovieStopTime(fileId, resumeData);
                }
            }

            TraktLogger.Info("My Videos Playback Sync Completed");
            SyncPlaybackInProgress = false;
            return;
        }
        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);
        }
        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);
                    }
                }
            }
        }
        private void BuildSelect(FilterDefinition filter, ref string whereClause, ref string fromClause)
        {
            if (whereClause != "")
            {
                whereClause += " AND ";
            }

            string cleanValue = DatabaseUtility.RemoveInvalidChars(filter.SelectedValue);

            if (filter.Where == "actorindex" || filter.Where == "directorindex" || filter.Where == "titleindex")
            {
                if (cleanValue == "#")
                {
                    string nWordChar = VideoDatabase.NonwordCharacters();

                    if (filter.Where == "actorindex" || filter.Where == "directorindex")
                    {
                        whereClause += @" SUBSTR(strActor,1,1) IN (" + nWordChar + ")";
                    }
                    else
                    {
                        whereClause += @" SUBSTR(strTitle,1,1) IN (" + nWordChar + ")";
                    }
                }
                else
                {
                    whereClause += String.Format(" {0}='{1}'", GetFieldId(filter.Where), cleanValue);
                }
            }
            else
            {
                whereClause += String.Format(" {0}='{1}'", GetFieldId(filter.Where), cleanValue);
            }

            bool   useMovieInfoTable  = false;
            bool   useAlbumTable      = false;
            bool   useActorsTable     = false;
            bool   useGenreTable      = false;
            bool   useUserGroupsTable = false;
            string table = GetTable(filter.Where, ref useMovieInfoTable, ref useAlbumTable, ref useActorsTable,
                                    ref useGenreTable, ref useUserGroupsTable);

            if (useGenreTable)
            {
                fromClause  += String.Format(",genre,genrelinkmovie");
                whereClause += " AND genre.idGenre=genrelinkMovie.idGenre AND genrelinkMovie.idMovie=movieinfo.idMovie";
                return;
            }

            if (useUserGroupsTable)
            {
                fromClause  += String.Format(",usergroup,usergrouplinkmovie");
                whereClause += " AND usergroup.idGroup=usergrouplinkmovie.idGroup AND usergrouplinkMovie.idMovie=movieinfo.idMovie";
                return;
            }

            if (useActorsTable)
            {
                if (CurrentLevel == MaxLevels - 1 && filter.Where == "actor")
                {
                    fromClause  += String.Format(",actors ,actorlinkmovie");
                    whereClause += " AND actors.idActor=actorlinkmovie.idActor AND actorlinkmovie.idMovie=movieinfo.idMovie";
                }
                return;
            }
        }
Beispiel #13
0
        /// <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,movieinfo.studios from {0} {1} {2}",
                                           fromClause, whereClause, orderClause);

                VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false, false);

                int x = 0;
                foreach (IMDBMovie item in movies)
                {
                    if (item.IsEmpty)
                    {
                        continue;
                    }

                    if (!CheckItem(item.Path))
                    {
                        DateTime dTmp     = DateTime.MinValue;
                        DateTime dwTmp    = DateTime.MinValue;
                        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
                        {
                            dTmp  = DateTime.Parse(item.DateAdded);
                            isnew = ((dTmp > Utils.NewDateTime) && (item.Watched <= 0));
                            if (isnew)
                            {
                                CurrentFacade.HasNew = true;
                            }
                        }
                        catch
                        {
                            isnew = false;
                        }
                        try
                        {
                            dwTmp = DateTime.Parse(item.DateWatched);
                        }
                        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()
                        {
                            DateTimeAdded   = dTmp,
                            DateTimeWatched = dwTmp,
                            Title           = item.Title,
                            Subtitle        = item.PlotOutline,
                            Genre           = item.Genre,
                            Thumb           = thumb,
                            Fanart          = GetFanart(item.Title, item.ID),
                            Rating          = item.Rating.ToString(CultureInfo.CurrentCulture),
                            Classification  = item.MPARating,
                            Runtime         = item.RunTime.ToString(),
                            Year            = item.Year.ToString(),
                            Summary         = item.Plot,
                            Studios         = item.Studios,
                            Banner          = fbanner,
                            ClearArt        = fclearart,
                            ClearLogo       = fclearlogo,
                            CD                 = fcd,
                            AnimatedPoster     = aposter,
                            AnimatedBackground = abg,
                            Playable           = item,
                            Id                 = item.ID.ToString(),
                            DBId               = item.IMDBNumber,
                            IsNew              = isnew
                        });

                        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++)
                {
                    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);
        }
 public VideoLibrary(VideoDatabase database, IMediaScanner mediaScanner)
 {
     this.database  = database;
     libraryUpdater = new LibraryUpdater(database, mediaScanner);
 }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        public ArrayList Execute()
        {
            //build the query
            ArrayList movies      = new ArrayList();
            string    whereClause = string.Empty;
            string    orderClause = string.Empty;
            string    fromClause  = string.Empty;

            string defViewFields = VideoDatabase.DefaultVideoViewFields;

            for (int i = 0; i < CurrentLevel; ++i)
            {
                BuildSelect((FilterDefinition)currentView.Filters[i], ref whereClause, ref fromClause);
            }

            BuildWhere((FilterDefinition)currentView.Filters[CurrentLevel], ref whereClause);
            BuildRestriction((FilterDefinition)currentView.Filters[CurrentLevel], ref whereClause);
            BuildOrder((FilterDefinition)currentView.Filters[CurrentLevel], ref orderClause);

            _parentWhere = whereClause;

            //execute the query
            string sql;

            if ((CurrentLevel >= 0) && (CurrentLevel < MaxLevels))
            {
                bool   useMovieInfoTable       = false;
                bool   useAlbumTable           = false;
                bool   useActorsTable          = false;
                bool   useGenreTable           = false;
                bool   useUserGroupsTable      = false;
                bool   useMovieCollectionTable = false;
                string join   = string.Empty;
                string fields = defViewFields;

                FilterDefinition defCurrent = (FilterDefinition)currentView.Filters[CurrentLevel];
                string           view       = defCurrent.Where;

                // Actor, Director, Title Index
                if ((view == "actorindex") || (view == "directorindex") || (view == "titleindex"))
                {
                    sql = String.Format("SELECT {0} AS IX, COUNT ({1}) " +
                                        "FROM movieView " +
                                        "WHERE {1} <> 'unknown' AND {1} IS NOT NULL {2} GROUP BY IX ",
                                        GetFieldId(view), GetFieldName(view), (!string.IsNullOrEmpty(whereClause) ? "AND " + whereClause : ""));
                    VideoDatabase.GetIndexByFilter(sql, true, out movies);
                    return(movies);
                }

                // Year
                if (view == "year")
                {
                    sql = String.Format("SELECT DISTINCT {0} FROM movieView {1}",
                                        GetFieldId(view), (!string.IsNullOrEmpty(whereClause) ? "WHERE " + whereClause : ""));
                    SQLiteResultSet results = VideoDatabase.GetResults(sql);

                    for (int i = 0; i < results.Rows.Count; i++)
                    {
                        IMDBMovie movie = new IMDBMovie();
                        movie.Year = DatabaseUtility.GetAsInt(results, i, "iYear");
                        movies.Add(movie);
                    }
                    return(movies);
                }

                string table = GetTable(view, ref useMovieInfoTable, ref useAlbumTable, ref useActorsTable,
                                        ref useGenreTable, ref useUserGroupsTable, ref useMovieCollectionTable);

                // Recently added, Recently watched
                if ((view == "recently added") || (view == "recently watched"))
                {
                    try
                    {
                        if (string.IsNullOrEmpty(defCurrent.Restriction))
                        {
                            defCurrent.Restriction = "7";
                        }

                        TimeSpan ts         = new TimeSpan(Convert.ToInt32(defCurrent.Restriction), 0, 0, 0);
                        DateTime searchDate = DateTime.Today - ts;

                        whereClause = String.Format("WHERE {0} >= '{1}'",
                                                    GetFieldName(view),
                                                    searchDate.ToString("yyyy-MM-dd" + " 00:00:00"));
                        useMovieInfoTable = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Error("GUIVideoSelectDVDHandler: Execute {0}", ex.Message);
                    }
                }
                // Director
                else if (view == "director")
                {
                    fields      = "idActorDirector, strActorDirector, strIMDBActorDirectorID";
                    whereClause = "WHERE strActorDirector <> 'unknown' AND strActorDirector IS NOT NULL";
                }
                // Actor
                else if (view == "actor")
                {
                    fields      = "idActor, strActor, imdbActorId";
                    whereClause = "WHERE strActor <> 'unknown' AND strActor IS NOT NULL";
                }
                // Genre
                else if (view == "genre")
                {
                    fields      = "idSingleGenre, strSingleGenre";
                    whereClause = "WHERE strSingleGenre IS NOT NULL";
                }
                // User groups
                else if (view == "user groups" || view == "user groups only")
                {
                    fields      = "idGroup, strGroup";
                    whereClause = "WHERE strGroup IS NOT NULL";
                }
                // Collections
                else if (view == "movie collections" || view == "movie collections only")
                {
                    fields      = "idCollection, strCollection, strCollectionDescription";
                    whereClause = "WHERE strCollection IS NOT NULL";
                }
                // Title
                else
                {
                    fields            = defViewFields;
                    whereClause       = string.Empty; // Already storred in ParentWhere
                    useMovieInfoTable = true;
                }

                table = "movieView"; // MP1-4775
                if (!string.IsNullOrEmpty(ParentWhere))
                {
                    if (!string.IsNullOrEmpty(whereClause))
                    {
                        whereClause = whereClause + " AND " + ParentWhere;
                    }
                    else
                    {
                        whereClause = "WHERE " + ParentWhere;
                    }
                }

                sql = String.Format("SELECT DISTINCT {0} FROM {1} {2} {3} {4}",
                                    fields, table, join, whereClause, orderClause);
                VideoDatabase.GetMoviesByFilter(sql, out movies, useActorsTable, useMovieInfoTable, useGenreTable, useUserGroupsTable, useMovieCollectionTable);

                if ((view == "user groups") || (view == "movie collections"))
                {
                    ArrayList moviesExt = new ArrayList();
                    sql = String.Format("SELECT DISTINCT {0} FROM {1} WHERE {2} IS NULL {3} ORDER BY strTitle",
                                        defViewFields, table, GetFieldId(view), (!string.IsNullOrEmpty(ParentWhere) ? "AND " + ParentWhere : ""));
                    VideoDatabase.GetMoviesByFilter(sql, out moviesExt, false, true, false, false, false);
                    movies.AddRange(moviesExt);
                }
            }
            return(movies);
        }
Beispiel #17
0
        /// <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");
        }
Beispiel #18
0
        public void SyncLibrary()
        {
            TraktLogger.Info("My Videos Starting Library Sync");

            #region Get online data from cache

            #region Get unwatched / watched movies from trakt.tv
            IEnumerable <TraktMovieWatched> traktWatchedMovies = null;

            var traktUnWatchedMovies = TraktCache.GetUnWatchedMoviesFromTrakt();
            if (traktUnWatchedMovies == null)
            {
                TraktLogger.Error("Error getting unwatched movies from trakt server, unwatched and watched sync will be skipped");
            }
            else
            {
                TraktLogger.Info("There are {0} unwatched movies since the last sync with trakt.tv", traktUnWatchedMovies.Count());

                traktWatchedMovies = TraktCache.GetWatchedMoviesFromTrakt();
                if (traktWatchedMovies == null)
                {
                    TraktLogger.Error("Error getting watched movies from trakt server, watched sync will be skipped");
                }
                else
                {
                    TraktLogger.Info("There are {0} watched movies in trakt.tv library", traktWatchedMovies.Count());
                }
            }
            #endregion

            #region Get collected movies from trakt.tv
            var traktCollectedMovies = TraktCache.GetCollectedMoviesFromTrakt();
            if (traktCollectedMovies == null)
            {
                TraktLogger.Error("Error getting collected movies from trakt server");
            }
            else
            {
                TraktLogger.Info("There are {0} collected movies in trakt.tv library", traktCollectedMovies.Count());
            }
            #endregion

            #endregion

            // optionally do library sync
            if (TraktSettings.SyncLibrary)
            {
                var collectedMovies = GetMovies();

                #region Remove Blocked Movies
                collectedMovies.RemoveAll(m => TraktSettings.BlockedFolders.Any(f => m.Path.ToLowerInvariant().Contains(f.ToLowerInvariant())));

                List <int> blockedMovieIds = new List <int>();
                foreach (string file in TraktSettings.BlockedFilenames)
                {
                    int pathId  = 0;
                    int movieId = 0;

                    // get a list of ids for blocked filenames
                    // filename seems to always be empty for an IMDBMovie object!
                    if (VideoDatabase.GetFile(file, out pathId, out movieId, false) > 0)
                    {
                        blockedMovieIds.Add(movieId);
                    }
                }
                collectedMovies.RemoveAll(m => blockedMovieIds.Contains(m.ID));
                #endregion

                #region Remove Movies with No IDs
                // Remove any movies that don't have any valid online ID's e.g. IMDb ID or TMDb ID.
                if (TraktSettings.SkipMoviesWithNoIdsOnSync)
                {
                    TraktLogger.Info("Removing movies that contain no valid online ID from sync movie list");
                    collectedMovies.RemoveAll(m => !BasicHandler.IsValidImdb(m.IMDBNumber));
                }
                #endregion

                #region Skipped Movies Check
                // Remove Skipped Movies from previous Sync
                //TODO
                //if (TraktSettings.SkippedMovies != null)
                //{
                //    // allow movies to re-sync again after 7-days in the case user has addressed issue ie. edited movie or added to themoviedb.org
                //    if (TraktSettings.SkippedMovies.LastSkippedSync.FromEpoch() > DateTime.UtcNow.Subtract(new TimeSpan(7, 0, 0, 0)))
                //    {
                //        if (TraktSettings.SkippedMovies.Movies != null && TraktSettings.SkippedMovies.Movies.Count > 0)
                //        {
                //            TraktLogger.Info("Skipping {0} movies due to invalid data or movies don't exist on http://themoviedb.org. Next check will be {1}.", TraktSettings.SkippedMovies.Movies.Count, TraktSettings.SkippedMovies.LastSkippedSync.FromEpoch().Add(new TimeSpan(7, 0, 0, 0)));
                //            foreach (var movie in TraktSettings.SkippedMovies.Movies)
                //            {
                //                TraktLogger.Info("Skipping movie, Title: {0}, Year: {1}, IMDb: {2}", movie.Title, movie.Year, movie.IMDBID);
                //                MovieList.RemoveAll(m => (m.Title == movie.Title) && (m.Year.ToString() == movie.Year) && (m.IMDBNumber == movie.IMDBID));
                //            }
                //        }
                //    }
                //    else
                //    {
                //        if (TraktSettings.SkippedMovies.Movies != null) TraktSettings.SkippedMovies.Movies.Clear();
                //        TraktSettings.SkippedMovies.LastSkippedSync = DateTime.UtcNow.ToEpoch();
                //    }
                //}
                #endregion

                #region Already Exists Movie Check
                // Remove Already-Exists Movies, these are typically movies that are using aka names and no IMDb/TMDb set
                // When we compare our local collection with trakt collection we have english only titles, so if no imdb/tmdb exists
                // we need to fallback to title matching. When we sync aka names are sometimes accepted if defined on themoviedb.org so we need to
                // do this to revent syncing these movies every sync interval.
                //TODO
                //if (TraktSettings.AlreadyExistMovies != null && TraktSettings.AlreadyExistMovies.Movies != null && TraktSettings.AlreadyExistMovies.Movies.Count > 0)
                //{
                //    TraktLogger.Debug("Skipping {0} movies as they already exist in trakt library but failed local match previously.", TraktSettings.AlreadyExistMovies.Movies.Count.ToString());
                //    var movies = new List<TraktMovieSync.Movie>(TraktSettings.AlreadyExistMovies.Movies);
                //    foreach (var movie in movies)
                //    {
                //        Predicate<IMDBMovie> criteria = m => (m.Title == movie.Title) && (m.Year.ToString() == movie.Year) && (m.IMDBNumber == movie.IMDBID);
                //        if (MovieList.Exists(criteria))
                //        {
                //            TraktLogger.Debug("Skipping movie, Title: {0}, Year: {1}, IMDb: {2}", movie.Title, movie.Year, movie.IMDBID);
                //            MovieList.RemoveAll(criteria);
                //        }
                //        else
                //        {
                //            // remove as we have now removed from our local collection or updated movie signature
                //            if (TraktSettings.MoviePluginCount == 1)
                //            {
                //                TraktLogger.Debug("Removing 'AlreadyExists' movie, Title: {0}, Year: {1}, IMDb: {2}", movie.Title, movie.Year, movie.IMDBID);
                //                TraktSettings.AlreadyExistMovies.Movies.Remove(movie);
                //            }
                //        }
                //    }
                //}
                #endregion

                TraktLogger.Info("Found {0} movies available to sync in My Videos database", collectedMovies.Count);

                // get the movies that we have watched
                var watchedMovies = collectedMovies.Where(m => m.Watched > 0).ToList();

                TraktLogger.Info("Found {0} watched movies available to sync in My Videos database", watchedMovies.Count);

                #region Mark movies as unwatched in local database
                if (traktUnWatchedMovies != null && traktUnWatchedMovies.Count() > 0)
                {
                    foreach (var movie in traktUnWatchedMovies)
                    {
                        var localMovie = watchedMovies.FirstOrDefault(m => MovieMatch(m, movie));
                        if (localMovie == null)
                        {
                            continue;
                        }

                        TraktLogger.Info("Marking movie as unwatched in local database, movie is not watched on trakt.tv. Title = '{0}', Year = '{1}', IMDb ID = '{2}', TMDb ID = '{3}'",
                                         movie.Title, movie.Year.HasValue ? movie.Year.ToString() : "<empty>", movie.Ids.Imdb ?? "<empty>", movie.Ids.Tmdb.HasValue ? movie.Ids.Tmdb.ToString() : "<empty>");

                        localMovie.Watched = 0;
                        IMDBMovie details = localMovie;
                        VideoDatabase.SetMovieInfoById(localMovie.ID, ref details);
                        VideoDatabase.SetMovieWatchedStatus(localMovie.ID, false, 0);
                    }

                    // update watched set
                    watchedMovies = collectedMovies.Where(m => m.Watched > 0).ToList();
                }
                #endregion

                #region Mark movies as watched in local database
                if (traktWatchedMovies != null && traktWatchedMovies.Count() > 0)
                {
                    foreach (var twm in traktWatchedMovies)
                    {
                        var localMovie = collectedMovies.FirstOrDefault(m => MovieMatch(m, twm.Movie));
                        if (localMovie == null)
                        {
                            continue;
                        }

                        int  iPercent;
                        int  iWatchedCount;
                        bool localIsWatched = VideoDatabase.GetmovieWatchedStatus(localMovie.ID, out iPercent, out iWatchedCount);

                        if (!localIsWatched || iWatchedCount < twm.Plays)
                        {
                            TraktLogger.Info("Updating local movie watched state / play count to match trakt.tv. Plays = '{0}', Title = '{1}', Year = '{2}', IMDb ID = '{3}', TMDb ID = '{4}'",
                                             twm.Plays, twm.Movie.Title, twm.Movie.Year.HasValue ? twm.Movie.Year.ToString() : "<empty>", twm.Movie.Ids.Imdb ?? "<empty>", twm.Movie.Ids.Tmdb.HasValue ? twm.Movie.Ids.Tmdb.ToString() : "<empty>");

                            if (localMovie.DateWatched == "0001-01-01 00:00:00")
                            {
                                DateTime dateWatched;
                                if (DateTime.TryParse(twm.LastWatchedAt, out dateWatched))
                                {
                                    localMovie.DateWatched = dateWatched.ToString("yyyy-MM-dd HH:mm:ss");
                                }
                            }

                            localMovie.Watched        = 1;
                            localMovie.WatchedCount   = twm.Plays;
                            localMovie.WatchedPercent = iPercent;

                            VideoDatabase.SetMovieWatchedCount(localMovie.ID, twm.Plays);
                            VideoDatabase.SetMovieWatchedStatus(localMovie.ID, true, iPercent);

                            IMDBMovie details = localMovie;
                            VideoDatabase.SetMovieInfoById(localMovie.ID, ref details);
                        }
                    }
                }
                #endregion

                #region Add movies to watched history at trakt.tv
                if (traktWatchedMovies != null)
                {
                    var syncWatchedMovies = new List <TraktSyncMovieWatched>();
                    TraktLogger.Info("Finding movies to add to trakt.tv watched history");

                    syncWatchedMovies = (from movie in watchedMovies
                                         where !traktWatchedMovies.ToList().Exists(c => MovieMatch(movie, c.Movie))
                                         select new TraktSyncMovieWatched
                    {
                        Ids = new TraktMovieId {
                            Imdb = movie.IMDBNumber.ToNullIfEmpty()
                        },
                        Title = movie.Title,
                        Year = movie.Year,
                        WatchedAt = GetLastDateWatched(movie),
                    }).ToList();

                    TraktLogger.Info("Adding {0} movies to trakt.tv watched history", syncWatchedMovies.Count);

                    if (syncWatchedMovies.Count > 0)
                    {
                        // update local cache
                        TraktCache.AddMoviesToWatchHistory(syncWatchedMovies);

                        int pageSize = TraktSettings.SyncBatchSize;
                        int pages    = (int)Math.Ceiling((double)syncWatchedMovies.Count / pageSize);
                        for (int i = 0; i < pages; i++)
                        {
                            TraktLogger.Info("Adding movies [{0}/{1}] to trakt.tv watched history", i + 1, pages);

                            var pagedMovies = syncWatchedMovies.Skip(i * pageSize).Take(pageSize).ToList();

                            pagedMovies.ForEach(s => TraktLogger.Info("Adding movie to trakt.tv watched history. Title = '{0}', Year = '{1}', IMDb ID = '{2}', TMDb ID = '{3}', Date Watched = '{4}'",
                                                                      s.Title, s.Year.HasValue ? s.Year.ToString() : "<empty>", s.Ids.Imdb ?? "<empty>", s.Ids.Tmdb.HasValue ? s.Ids.Tmdb.ToString() : "<empty>", s.WatchedAt));

                            // remove title/year such that match against online ID only
                            if (TraktSettings.SkipMoviesWithNoIdsOnSync)
                            {
                                pagedMovies.ForEach(m => { m.Title = null; m.Year = null; });
                            }

                            var response = TraktAPI.TraktAPI.AddMoviesToWatchedHistory(new TraktSyncMoviesWatched {
                                Movies = pagedMovies
                            });
                            TraktLogger.LogTraktResponse <TraktSyncResponse>(response);

                            // remove movies from cache which didn't succeed
                            if (response != null && response.NotFound != null && response.NotFound.Movies.Count > 0)
                            {
                                TraktCache.RemoveMoviesFromWatchHistory(response.NotFound.Movies);
                            }
                        }
                    }
                }
                #endregion

                #region Add movies to collection at trakt.tv
                if (traktCollectedMovies != null)
                {
                    var syncCollectedMovies = new List <TraktSyncMovieCollected>();
                    TraktLogger.Info("Finding movies to add to trakt.tv collection");

                    syncCollectedMovies = (from movie in collectedMovies
                                           where !traktCollectedMovies.ToList().Exists(c => MovieMatch(movie, c.Movie))
                                           select new TraktSyncMovieCollected
                    {
                        Ids = new TraktMovieId {
                            Imdb = movie.IMDBNumber.ToNullIfEmpty()
                        },
                        Title = movie.Title,
                        Year = movie.Year,
                        CollectedAt = movie.DateAdded.ToISO8601(),
                        MediaType = GetMovieMediaType(movie),
                        Resolution = GetMovieResolution(movie),
                        AudioCodec = GetMovieAudioCodec(movie),
                        AudioChannels = GetMovieAudioChannels(movie),
                        Is3D = IsMovie3D(movie)
                    }).ToList();

                    TraktLogger.Info("Adding {0} movies to trakt.tv collection", syncCollectedMovies.Count);

                    if (syncCollectedMovies.Count > 0)
                    {
                        // update internal cache
                        TraktCache.AddMoviesToCollection(syncCollectedMovies);

                        int pageSize = TraktSettings.SyncBatchSize;
                        int pages    = (int)Math.Ceiling((double)syncCollectedMovies.Count / pageSize);
                        for (int i = 0; i < pages; i++)
                        {
                            TraktLogger.Info("Adding movies [{0}/{1}] to trakt.tv collection", i + 1, pages);

                            var pagedMovies = syncCollectedMovies.Skip(i * pageSize).Take(pageSize).ToList();

                            pagedMovies.ForEach(s => TraktLogger.Info("Adding movie to trakt.tv collection. Title = '{0}', Year = '{1}', IMDb ID = '{2}', TMDb ID = '{3}', Date Added = '{4}', MediaType = '{5}', Resolution = '{6}', Audio Codec = '{7}', Audio Channels = '{8}'",
                                                                      s.Title, s.Year.HasValue ? s.Year.ToString() : "<empty>", s.Ids.Imdb ?? "<empty>", s.Ids.Tmdb.HasValue ? s.Ids.Tmdb.ToString() : "<empty>",
                                                                      s.CollectedAt, s.MediaType ?? "<empty>", s.Resolution ?? "<empty>", s.AudioCodec ?? "<empty>", s.AudioChannels ?? "<empty>"));

                            // remove title/year such that match against online ID only
                            if (TraktSettings.SkipMoviesWithNoIdsOnSync)
                            {
                                pagedMovies.ForEach(m => { m.Title = null; m.Year = null; });
                            }

                            var response = TraktAPI.TraktAPI.AddMoviesToCollecton(new TraktSyncMoviesCollected {
                                Movies = pagedMovies
                            });
                            TraktLogger.LogTraktResponse(response);

                            // remove movies from cache which didn't succeed
                            if (response != null && response.NotFound != null && response.NotFound.Movies.Count > 0)
                            {
                                TraktCache.RemoveMoviesFromCollection(response.NotFound.Movies);
                            }
                        }
                    }
                }
                #endregion

                #region Remove movies no longer in collection from trakt.tv
                if (TraktSettings.KeepTraktLibraryClean && TraktSettings.MoviePluginCount == 1 && traktCollectedMovies != null)
                {
                    var syncUnCollectedMovies = new List <TraktMovie>();
                    TraktLogger.Info("Finding movies to remove from trakt.tv collection");

                    // workout what movies that are in trakt collection that are not in local collection
                    syncUnCollectedMovies = (from tcm in traktCollectedMovies
                                             where !collectedMovies.Exists(c => MovieMatch(c, tcm.Movie))
                                             select new TraktMovie
                    {
                        Ids = tcm.Movie.Ids,
                        Title = tcm.Movie.Title,
                        Year = tcm.Movie.Year
                    }).ToList();

                    TraktLogger.Info("Removing {0} movies from trakt.tv collection", syncUnCollectedMovies.Count);

                    if (syncUnCollectedMovies.Count > 0)
                    {
                        // update local cache
                        TraktCache.RemoveMoviesFromCollection(syncUnCollectedMovies);

                        int pageSize = TraktSettings.SyncBatchSize;
                        int pages    = (int)Math.Ceiling((double)syncUnCollectedMovies.Count / pageSize);
                        for (int i = 0; i < pages; i++)
                        {
                            TraktLogger.Info("Removing movies [{0}/{1}] from trakt.tv collection", i + 1, pages);

                            var pagedMovies = syncUnCollectedMovies.Skip(i * pageSize).Take(pageSize).ToList();

                            pagedMovies.ForEach(s => TraktLogger.Info("Removing movie from trakt.tv collection, movie no longer exists locally. Title = '{0}', Year = '{1}', IMDb ID = '{2}', TMDb ID = '{3}'",
                                                                      s.Title, s.Year.HasValue ? s.Year.ToString() : "<empty>", s.Ids.Imdb ?? "<empty>", s.Ids.Tmdb.HasValue ? s.Ids.Tmdb.ToString() : "<empty>"));

                            // remove title/year such that match against online ID only
                            if (TraktSettings.SkipMoviesWithNoIdsOnSync)
                            {
                                pagedMovies.ForEach(m => { m.Title = null; m.Year = null; });
                            }

                            var response = TraktAPI.TraktAPI.RemoveMoviesFromCollecton(new TraktSyncMovies {
                                Movies = pagedMovies
                            });
                            TraktLogger.LogTraktResponse(response);
                        }
                    }
                }
                #endregion
            }

            TraktLogger.Info("My Videos Library Sync Completed");
        }
Beispiel #19
0
 public LibraryUpdater(VideoDatabase database, IMediaScanner mediaScanner)
 {
     this.database     = database;
     this.mediaScanner = mediaScanner;
     semaphore         = new SemaphoreSlim(1, 1);
 }
Beispiel #20
0
        public void SyncLibrary()
        {
            TraktLogger.Info("My Videos Starting Sync");

            if (TraktSettings.SyncLibrary)
            {
                // get all movies
                ArrayList myvideos = new ArrayList();
                VideoDatabase.GetMovies(ref myvideos);

                List <IMDBMovie> MovieList = (from IMDBMovie movie in myvideos select movie).ToList();

                #region Remove Blocked Movies
                MovieList.RemoveAll(m => TraktSettings.BlockedFolders.Any(f => m.Path.ToLowerInvariant().Contains(f.ToLowerInvariant())));

                List <int> blockedMovieIds = new List <int>();
                foreach (string file in TraktSettings.BlockedFilenames)
                {
                    int pathId  = 0;
                    int movieId = 0;

                    // get a list of ids for blocked filenames
                    // filename seems to always be empty for an IMDBMovie object!
                    if (VideoDatabase.GetFile(file, out pathId, out movieId, false) > 0)
                    {
                        blockedMovieIds.Add(movieId);
                    }
                }
                MovieList.RemoveAll(m => blockedMovieIds.Contains(m.ID));
                #endregion

                #region Skipped Movies Check
                // Remove Skipped Movies from previous Sync
                if (TraktSettings.SkippedMovies != null)
                {
                    // allow movies to re-sync again after 7-days in the case user has addressed issue ie. edited movie or added to themoviedb.org
                    if (TraktSettings.SkippedMovies.LastSkippedSync.FromEpoch() > DateTime.UtcNow.Subtract(new TimeSpan(7, 0, 0, 0)))
                    {
                        if (TraktSettings.SkippedMovies.Movies != null && TraktSettings.SkippedMovies.Movies.Count > 0)
                        {
                            TraktLogger.Info("Skipping {0} movies due to invalid data or movies don't exist on http://themoviedb.org. Next check will be {1}.", TraktSettings.SkippedMovies.Movies.Count, TraktSettings.SkippedMovies.LastSkippedSync.FromEpoch().Add(new TimeSpan(7, 0, 0, 0)));
                            foreach (var movie in TraktSettings.SkippedMovies.Movies)
                            {
                                TraktLogger.Info("Skipping movie, Title: {0}, Year: {1}, IMDb: {2}", movie.Title, movie.Year, movie.IMDBID);
                                MovieList.RemoveAll(m => (m.Title == movie.Title) && (m.Year.ToString() == movie.Year) && (m.IMDBNumber == movie.IMDBID));
                            }
                        }
                    }
                    else
                    {
                        if (TraktSettings.SkippedMovies.Movies != null)
                        {
                            TraktSettings.SkippedMovies.Movies.Clear();
                        }
                        TraktSettings.SkippedMovies.LastSkippedSync = DateTime.UtcNow.ToEpoch();
                    }
                }
                #endregion

                #region Already Exists Movie Check
                // Remove Already-Exists Movies, these are typically movies that are using aka names and no IMDb/TMDb set
                // When we compare our local collection with trakt collection we have english only titles, so if no imdb/tmdb exists
                // we need to fallback to title matching. When we sync aka names are sometimes accepted if defined on themoviedb.org so we need to
                // do this to revent syncing these movies every sync interval.
                if (TraktSettings.AlreadyExistMovies != null && TraktSettings.AlreadyExistMovies.Movies != null && TraktSettings.AlreadyExistMovies.Movies.Count > 0)
                {
                    TraktLogger.Debug("Skipping {0} movies as they already exist in trakt library but failed local match previously.", TraktSettings.AlreadyExistMovies.Movies.Count.ToString());
                    var movies = new List <TraktMovieSync.Movie>(TraktSettings.AlreadyExistMovies.Movies);
                    foreach (var movie in movies)
                    {
                        Predicate <IMDBMovie> criteria = m => (m.Title == movie.Title) && (m.Year.ToString() == movie.Year) && (m.IMDBNumber == movie.IMDBID);
                        if (MovieList.Exists(criteria))
                        {
                            TraktLogger.Debug("Skipping movie, Title: {0}, Year: {1}, IMDb: {2}", movie.Title, movie.Year, movie.IMDBID);
                            MovieList.RemoveAll(criteria);
                        }
                        else
                        {
                            // remove as we have now removed from our local collection or updated movie signature
                            if (TraktSettings.MoviePluginCount == 1)
                            {
                                TraktLogger.Debug("Removing 'AlreadyExists' movie, Title: {0}, Year: {1}, IMDb: {2}", movie.Title, movie.Year, movie.IMDBID);
                                TraktSettings.AlreadyExistMovies.Movies.Remove(movie);
                            }
                        }
                    }
                }
                #endregion

                TraktLogger.Info("{0} movies available to sync in My Videos database", MovieList.Count.ToString());

                // get the movies that we have watched
                List <IMDBMovie> SeenList = MovieList.Where(m => m.Watched > 0).ToList();

                TraktLogger.Info("{0} watched movies available to sync in My Videos database", SeenList.Count.ToString());

                // get the movies that we have yet to watch
                TraktLogger.Info("Getting user {0}'s movies from trakt", TraktSettings.Username);
                IEnumerable <TraktLibraryMovies> traktMoviesAll = TraktAPI.TraktAPI.GetAllMoviesForUser(TraktSettings.Username);
                if (traktMoviesAll == null)
                {
                    TraktLogger.Error("Error getting movies from trakt server, cancelling sync.");
                    return;
                }
                TraktLogger.Info("{0} movies in trakt library", traktMoviesAll.Count().ToString());

                #region Movies to Sync to Collection
                List <IMDBMovie>          moviesToSync            = new List <IMDBMovie>(MovieList);
                List <TraktLibraryMovies> NoLongerInOurCollection = new List <TraktLibraryMovies>();
                //Filter out a list of movies we have already sync'd in our collection
                foreach (TraktLibraryMovies tlm in traktMoviesAll)
                {
                    bool notInLocalCollection = true;
                    // if it is in both libraries
                    foreach (IMDBMovie libraryMovie in MovieList.Where(m => MovieMatch(m, tlm)))
                    {
                        // If the users IMDb Id is empty/invalid and we have matched one then set it
                        if (BasicHandler.IsValidImdb(tlm.IMDBID) && !BasicHandler.IsValidImdb(libraryMovie.IMDBNumber))
                        {
                            TraktLogger.Info("Movie '{0}' inserted IMDb Id '{1}'", libraryMovie.Title, tlm.IMDBID);
                            libraryMovie.IMDBNumber = tlm.IMDBID;
                            IMDBMovie details = libraryMovie;
                            VideoDatabase.SetMovieInfoById(libraryMovie.ID, ref details);
                        }

                        // if it is watched in Trakt but not My Videos update
                        // skip if movie is watched but user wishes to have synced as unseen locally
                        if (tlm.Plays > 0 && !tlm.UnSeen && libraryMovie.Watched == 0)
                        {
                            TraktLogger.Info("Movie '{0}' is watched on Trakt updating Database", libraryMovie.Title);
                            libraryMovie.Watched = 1;
                            if (libraryMovie.DateWatched == "0001-01-01 00:00:00")
                            {
                                libraryMovie.DateWatched = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            }
                            IMDBMovie details = libraryMovie;
                            VideoDatabase.SetMovieInfoById(libraryMovie.ID, ref details);

                            if (libraryMovie.WatchedCount == 0)
                            {
                                VideoDatabase.SetMovieWatchedCount(libraryMovie.ID, tlm.Plays);
                                VideoDatabase.SetMovieWatchedStatus(libraryMovie.ID, true, 0);
                            }
                        }

                        // mark movies as unseen if watched locally
                        if (tlm.UnSeen && libraryMovie.Watched > 0)
                        {
                            TraktLogger.Info("Movie '{0}' is unseen on Trakt, updating database", libraryMovie.Title);
                            libraryMovie.Watched = 0;
                            IMDBMovie details = libraryMovie;
                            VideoDatabase.SetMovieInfoById(libraryMovie.ID, ref details);
                            VideoDatabase.SetMovieWatchedStatus(libraryMovie.ID, false, 0);
                        }

                        notInLocalCollection = false;

                        //filter out if its already in collection
                        if (tlm.InCollection)
                        {
                            moviesToSync.RemoveAll(m => MovieMatch(m, tlm));
                        }
                        break;
                    }

                    if (notInLocalCollection && tlm.InCollection)
                    {
                        NoLongerInOurCollection.Add(tlm);
                    }
                }
                #endregion

                #region Movies to Sync to Seen Collection
                // filter out a list of movies already marked as watched on trakt
                // also filter out movie marked as unseen so we dont reset the unseen cache online
                List <IMDBMovie> watchedMoviesToSync = new List <IMDBMovie>(SeenList);
                foreach (TraktLibraryMovies tlm in traktMoviesAll.Where(t => t.Plays > 0 || t.UnSeen))
                {
                    foreach (IMDBMovie watchedMovie in SeenList.Where(m => MovieMatch(m, tlm)))
                    {
                        //filter out
                        watchedMoviesToSync.Remove(watchedMovie);
                    }
                }
                #endregion

                #region Sync Collection to trakt
                //Send Library/Collection
                TraktLogger.Info("{0} movies need to be added to Library", moviesToSync.Count.ToString());
                foreach (IMDBMovie m in moviesToSync)
                {
                    TraktLogger.Info("Sending movie to trakt library, Title: {0}, Year: {1}, IMDb: {2}", m.Title, m.Year.ToString(), m.IMDBNumber);
                }

                if (moviesToSync.Count > 0)
                {
                    TraktSyncResponse response = TraktAPI.TraktAPI.SyncMovieLibrary(CreateSyncData(moviesToSync), TraktSyncModes.library);
                    BasicHandler.InsertSkippedMovies(response);
                    BasicHandler.InsertAlreadyExistMovies(response);
                    TraktLogger.LogTraktResponse(response);
                }
                #endregion

                #region Sync Seen to trakt
                //Send Seen
                TraktLogger.Info("{0} movies need to be added to SeenList", watchedMoviesToSync.Count.ToString());
                foreach (IMDBMovie m in watchedMoviesToSync)
                {
                    TraktLogger.Info("Sending movie to trakt as seen, Title: {0}, Year: {1}, IMDb: {2}", m.Title, m.Year.ToString(), m.IMDBNumber);
                }

                if (watchedMoviesToSync.Count > 0)
                {
                    TraktSyncResponse response = TraktAPI.TraktAPI.SyncMovieLibrary(CreateSyncData(watchedMoviesToSync), TraktSyncModes.seen);
                    BasicHandler.InsertSkippedMovies(response);
                    BasicHandler.InsertAlreadyExistMovies(response);
                    TraktLogger.LogTraktResponse(response);
                }
                #endregion

                #region Clean Library
                //Dont clean library if more than one movie plugin installed
                if (TraktSettings.KeepTraktLibraryClean && TraktSettings.MoviePluginCount == 1)
                {
                    //Remove movies we no longer have in our local database from Trakt
                    foreach (var m in NoLongerInOurCollection)
                    {
                        TraktLogger.Info("Removing from Trakt Collection {0}", m.Title);
                    }

                    TraktLogger.Info("{0} movies need to be removed from Trakt Collection", NoLongerInOurCollection.Count.ToString());

                    if (NoLongerInOurCollection.Count > 0)
                    {
                        if (TraktSettings.AlreadyExistMovies != null && TraktSettings.AlreadyExistMovies.Movies != null && TraktSettings.AlreadyExistMovies.Movies.Count > 0)
                        {
                            TraktLogger.Warning("DISABLING CLEAN LIBRARY!!!, there are trakt library movies that can't be determined to be local in collection.");
                            TraktLogger.Warning("To fix this, check the 'already exist' entries in log, then check movies in local collection against this list and ensure IMDb id is set then run sync again.");
                        }
                        else
                        {
                            //Then remove from library
                            TraktSyncResponse response = TraktAPI.TraktAPI.SyncMovieLibrary(BasicHandler.CreateMovieSyncData(NoLongerInOurCollection), TraktSyncModes.unlibrary);
                            TraktLogger.LogTraktResponse(response);
                        }
                    }
                }
                #endregion
            }

            TraktLogger.Info("My Videos Sync Completed");
        }
        // 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)
        }
Beispiel #22
0
        private void MovieSelect_Load(object sender, EventArgs e)
        {
            //If MovingPictures is selected
            if (TraktSettings.MovingPictures > -1 && File.Exists(Path.Combine(Config.GetFolder(Config.Dir.Plugins), @"Windows\MovingPictures.dll")))
            {
                //Load the Movies from Moving Pictures
                try
                {
                    LoadMoviesFromMovingPictures();
                }
                catch (Exception)
                {
                    TraktLogger.Info("Tried to load MovingPictures but failed, check minimum requirements are met!");
                }
            }

            //If MyVideos is selected, always installed
            if (TraktSettings.MyVideos > -1)
            {
                string sql = "SELECT movieinfo.strTitle, path.strPath, files.strFilename " +
                             "FROM movieInfo " +
                             "LEFT JOIN files " +
                             "ON movieInfo.idMovie=files.idMovie " +
                             "LEFT JOIN path " +
                             "ON files.idPath=path.idPath " +
                             "ORDER BY strTitle";

                SQLiteResultSet results = VideoDatabase.GetResults(sql);

                for (int row = 0; row < results.Rows.Count; row++)
                {
                    string title    = DatabaseUtility.Get(results, row, 0);
                    string filename = string.Concat(DatabaseUtility.Get(results, row, 1), DatabaseUtility.Get(results, row, 2));
                    if (string.IsNullOrEmpty(filename))
                    {
                        continue;
                    }

                    if (!_blockedFilenames.Contains(filename))
                    {
                        unCheckedMovies.Add(new MovieSelectItem {
                            MovieTitle = title, Filename = new List <string> {
                                filename
                            }
                        });
                    }
                    else
                    {
                        checkedMovies.Add(new MovieSelectItem {
                            MovieTitle = title, Filename = new List <string> {
                                filename
                            }
                        });
                    }
                }
            }

            //If MyFilms is selected
            if (TraktSettings.MyFilms > -1 && File.Exists(Path.Combine(Config.GetFolder(Config.Dir.Plugins), @"Windows\MyFilms.dll")))
            {
                //Load the Movies from MyFilms
                try
                {
                    LoadMoviesFromMyFilms();
                }
                catch (Exception)
                {
                    TraktLogger.Info("Tried to load My Films but failed, check minimum requirements are met!");
                }
            }

            foreach (MovieSelectItem movie in checkedMovies)
            {
                if (!checkedListBoxMovies.Items.Contains(movie))
                {
                    checkedListBoxMovies.Items.Add(movie, true);
                }
            }

            foreach (MovieSelectItem movie in unCheckedMovies)
            {
                if (!checkedListBoxMovies.Items.Contains(movie))
                {
                    checkedListBoxMovies.Items.Add(movie, false);
                }
            }

            checkedListBoxMovies.ItemCheck += new ItemCheckEventHandler(checkedListBoxMovies_ItemCheck);
        }
Beispiel #23
0
        // Image play method
        public bool OnPlayBD(String drive, int parentId)
        {
            Log.Info("SelectBDHandler: OnPlayBD() playing BD {0}", drive);

            string currentFile = g_Player.CurrentFile;

            if (g_Player.Playing && Util.Utils.IsISOImage(currentFile) && IsBDPlayList(ref currentFile))
            //if (g_Player.Playing && IsBDPlayList(ref currentFile))
            {
                return(true);
            }

            if (Util.Utils.getDriveType(drive) == 5) //cd or dvd drive
            {
                string driverLetter = drive.Substring(0, 1);
                string fileName     = String.Format(@"{0}:\BDMV\index.bdmv", driverLetter);

                if (File.Exists(fileName))
                {
                    IMDBMovie movieDetails = new IMDBMovie();

                    //string name = DaemonTools._MountedIsoFile;

                    int idFileImg  = VideoDatabase.GetFileId(fileName);
                    int idMovieImg = VideoDatabase.GetMovieId(fileName);

                    ///*
                    int    timeMovieStopped = 0;
                    byte[] resumeData       = null;

                    if ((idMovieImg >= 0) && (idFileImg >= 0))
                    {
                        timeMovieStopped = VideoDatabase.GetMovieStopTimeAndResumeData(idFileImg, out resumeData, g_Player.SetResumeBDTitleState);

                        if (timeMovieStopped > 0)
                        {
                            string title = Path.GetFileName(fileName);
                            VideoDatabase.GetMovieInfoById(idMovieImg, 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.PlayBD(drive + @"\BDMV\index.bdmv");
                    g_Player.ShowFullScreenWindow();

                    ///*
                    if (g_Player.Playing && timeMovieStopped > 0)
                    {
                        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("SelectBDHandler: OnPlayBD() Plz Insert Disk");
            dlgOk.SetLine(1, 219); //no disc
            dlgOk.DoModal(parentId);
            return(true);
        }
        // Changed - covers and the same movie name
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);
            if (control == btnRefresh)
            {
                // Check Internet connection
                if (!Win32API.IsConnectedToInternet())
                {
                    GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    dlgOk.SetHeading(257);
                    dlgOk.SetLine(1, GUILocalizeStrings.Get(703));
                    dlgOk.DoModal(GUIWindowManager.ActiveWindow);
                    return;
                }
                string title = currentMovie.Title;
                int    id    = currentMovie.ID;
                string file  = currentMovie.Path + "\\" + currentMovie.File;
                // Delete covers
                FanArt.DeleteCovers(title, id);
                //Delete fanarts
                FanArt.DeleteFanarts(file, title);

                if (IMDBFetcher.RefreshIMDB(this, ref currentMovie, false, false, true))
                {
                    if ((imageSearchThread != null) && (imageSearchThread.IsAlive))
                    {
                        imageSearchThread.Abort();
                        imageSearchThread = null;
                    }

                    imdbCoverArtUrl = currentMovie.ThumbURL;
                    coverArtUrls    = new string[1];
                    coverArtUrls[0] = imdbCoverArtUrl;

                    ResetSpinControl();

                    Refresh(false);
                    Update();
                    // Start images search thread
                    SearchImages();
                }
                return;
            }

            if (control == spinImages)
            {
                int item = spinImages.Value - 1;
                if (item < 0 || item >= coverArtUrls.Length)
                {
                    item = 0;
                }
                if (currentMovie.ThumbURL == coverArtUrls[item])
                {
                    return;
                }

                currentMovie.ThumbURL = coverArtUrls[item];
                // Title suffix for problem with covers and movie with the same name
                string titleExt           = currentMovie.Title + "{" + currentMovie.ID + "}";
                string coverArtImage      = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);
                string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                Util.Utils.FileDelete(coverArtImage);
                //
                // 07.11.2010 Deda: Cache entry Flag change for cover thumb file
                //
                Util.Utils.DoInsertNonExistingFileIntoCache(coverArtImage);
                //
                Util.Utils.FileDelete(largeCoverArtImage);
                Refresh(false);
                Update();
                int idMovie = currentMovie.ID;
                if (idMovie >= 0)
                {
                    VideoDatabase.SetThumbURL(idMovie, currentMovie.ThumbURL);
                }
                return;
            }

            if (control == btnCast)
            {
                viewmode = ViewMode.Cast;
                Update();
            }

            if (control == btnPlot)
            {
                viewmode = ViewMode.Plot;
                Update();
            }

            if (control == btnReview)
            {
                viewmode = ViewMode.Review;
                Update();
            }

            if (control == btnWatched)
            {
                if (currentMovie.Watched > 0)
                {
                    GUIPropertyManager.SetProperty("#iswatched", "no");
                    currentMovie.Watched = 0;
                    VideoDatabase.SetMovieWatchedStatus(currentMovie.ID, false);
                    ArrayList files = new ArrayList();
                    VideoDatabase.GetFiles(currentMovie.ID, ref files);

                    foreach (string file in files)
                    {
                        int fileId = VideoDatabase.GetFileId(file);
                        VideoDatabase.DeleteMovieStopTime(fileId);
                    }
                }
                else
                {
                    GUIPropertyManager.SetProperty("#iswatched", "yes");
                    currentMovie.Watched = 1;
                    VideoDatabase.SetMovieWatchedStatus(currentMovie.ID, true);
                }
                VideoDatabase.SetWatched(currentMovie);
            }

            if (control == spinDisc)
            {
                string selectedItem = spinDisc.GetLabel();
                int    idMovie      = currentMovie.ID;
                if (idMovie > 0)
                {
                    if (selectedItem != "HD" && selectedItem != "share")
                    {
                        VideoDatabase.SetDVDLabel(idMovie, selectedItem);
                    }
                    else
                    {
                        VideoDatabase.SetDVDLabel(idMovie, "HD");
                    }
                }
            }

            if (control == btnPlay)
            {
                int id = currentMovie.ID;

                ArrayList files = new ArrayList();
                VideoDatabase.GetFiles(id, ref files);

                if (files.Count > 1)
                {
                    GUIVideoFiles._stackedMovieFiles = files;
                    GUIVideoFiles._isStacked         = true;
                    GUIVideoFiles.MovieDuration(files);
                }

                GUIVideoFiles.PlayMovie(id, false);
                return;
            }
        }
Beispiel #25
0
        protected virtual void SetLabels()
        {
            bool isShareView = false;

            if (GUIWindowManager.ActiveWindow == (int)Window.WINDOW_VIDEOS)
            {
                isShareView = true;
            }

            bool _stackedFolder = true;

            if (isShareView)
            {
                _currentFolder = GUIVideoFiles.GetCurrentFolder;
                object o;
                MediaPortal.Database.FolderSettings.GetFolderSetting(_currentFolder, "VideoFiles", typeof(GUIVideoFiles.MapSettings), out o);

                if (o != null)
                {
                    GUIVideoFiles.MapSettings mapSettings = o as GUIVideoFiles.MapSettings;

                    _stackedFolder = mapSettings.Stack;
                }
            }
            else
            {
                _currentFolder = GUIVideoTitle.GetCurrentView;
                object o;
                // MediaPortal.Database.FolderSettings.GetFolderSetting(_currentFolder, "VideoViews", typeof(GUIVideoTitle.MapSettings), out o);
                MediaPortal.Database.FolderSettings.GetViewSetting(_currentFolder, "VideoViews", typeof(GUIVideoTitle.MapSettings), out o);
                if (o != null)
                {
                    GUIVideoTitle.MapSettings mapSettings = o as GUIVideoTitle.MapSettings;
                    if (mapSettings != null)
                    {
                        CurrentSortMethod = (VideoSort.SortMethod)mapSettings.SortBy;
                        CurrentSortAsc    = mapSettings.SortAscending;
                    }
                }
            }

            for (int i = 0; i < facadeLayout.Count; ++i)
            {
                GUIListItem item  = facadeLayout[i];
                IMDBMovie   movie = item.AlbumInfoTag as IMDBMovie;

                if (movie != null && movie.ID > 0 && !isShareView &&
                    (!item.IsFolder || CurrentSortMethod == VideoSort.SortMethod.NameAll))
                {
                    if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll ||
                        CurrentSortMethod == VideoSort.SortMethod.Name_With_Duration)
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            // Show real movie duration (from video file)
                            int mDuration = VideoDatabase.GetMovieDuration(movie.ID);

                            if (mDuration <= 0)
                            {
                                ArrayList mFiles = new ArrayList();
                                VideoDatabase.GetFilesForMovie(movie.ID, ref mFiles);
                                mDuration = GUIVideoFiles.MovieDuration(mFiles, true);

                                if (mDuration <= 0)
                                {
                                    item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60);
                                }
                                else
                                {
                                    item.Label2 = Util.Utils.SecondsToHMString(mDuration);
                                }
                            }
                            else
                            {
                                item.Label2 = Util.Utils.SecondsToHMString(mDuration);
                            }
                        }
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Year)
                    {
                        item.Label2 = movie.Year.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Rating)
                    {
                        item.Label2 = movie.Rating.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Label)
                    {
                        item.Label2 = movie.DVDLabel.ToString();
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Size)
                    {
                        if (item.FileInfo != null)
                        {
                            item.Label2 = Util.Utils.GetSize(item.FileInfo.Length);
                        }
                        else
                        {
                            item.Label2 = Util.Utils.SecondsToHMString(movie.RunTime * 60);
                        }
                    }
                    else if (!isShareView && CurrentSortMethod == VideoSort.SortMethod.Date)
                    {
                        string strDate = string.Empty;

                        if (!item.IsFolder && movie != null)
                        {
                            if (movie.DateAdded != "0001-01-01 00:00:00")
                            {
                                strDate = movie.DateAdded;
                            }
                            else
                            {
                                strDate = movie.LastUpdate;
                            }
                        }
                        item.Label2 = strDate;
                    }
                }
                else
                {
                    string strSize1 = string.Empty, strDate = string.Empty;

                    if (item.FileInfo != null && !item.IsFolder)
                    {
                        strSize1 = Util.Utils.GetSize(item.FileInfo.Length);
                    }

                    if (item.FileInfo != null && !item.IsFolder)
                    {
                        if (CurrentSortMethod == VideoSort.SortMethod.Modified)
                        {
                            strDate = item.FileInfo.ModificationTime.ToShortDateString() + " " +
                                      item.FileInfo.ModificationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                        }
                        else
                        {
                            strDate = item.FileInfo.CreationTime.ToShortDateString() + " " +
                                      item.FileInfo.CreationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                        }
                    }

                    if (CurrentSortMethod == VideoSort.SortMethod.Name || CurrentSortMethod == VideoSort.SortMethod.NameAll)
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            item.Label2 = strSize1;
                        }
                    }

                    if (CurrentSortMethod == VideoSort.SortMethod.Name_With_Duration && !item.IsFolder && item.Label != "..")
                    {
                        if (_stackedFolder)
                        {
                            int newMovieId = VideoDatabase.GetMovieId(item.Path);
                            item.Duration = VideoDatabase.GetMovieDuration(newMovieId);
                        }
                        else
                        {
                            int fileID = VideoDatabase.GetFileId(item.Path);
                            item.Duration = VideoDatabase.GetVideoDuration(fileID);
                        }

                        if (item.Duration > 0)
                        {
                            item.Label2 = Util.Utils.SecondsToShortHMSString(item.Duration);
                        }
                        else
                        {
                            item.Label2 = string.Empty;
                        }
                    }
                    else if (CurrentSortMethod == VideoSort.SortMethod.Created || CurrentSortMethod == VideoSort.SortMethod.Date || CurrentSortMethod == VideoSort.SortMethod.Modified)
                    {
                        if (!isShareView && CurrentSortMethod == VideoSort.SortMethod.Date && string.IsNullOrWhiteSpace(strDate))
                        {
                            if (!item.IsFolder && movie != null)
                            {
                                if (movie.DateAdded != "0001-01-01 00:00:00")
                                {
                                    strDate = movie.DateAdded;
                                }
                                else
                                {
                                    strDate = movie.LastUpdate;
                                }
                            }
                        }
                        item.Label2 = strDate;
                    }
                    else
                    {
                        if (item.IsFolder)
                        {
                            item.Label2 = string.Empty;
                        }
                        else
                        {
                            item.Label2 = strSize1;
                        }
                    }
                }
            }
        }
Beispiel #26
0
        /// <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);
            }
        }
        //Changed - covers and same movie names
        private void Refresh(bool forceFolderThumb)
        {
            string coverArtImage      = string.Empty;
            string largeCoverArtImage = string.Empty; //added by BoelShit

            try
            {
                string imageUrl = currentMovie.ThumbURL;
                if (imageUrl.Length > 0)
                {
                    string titleExt = currentMovie.Title + "{" + currentMovie.ID + "}";
                    coverArtImage      = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);
                    largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                    //added by BoelShit
                    string largeCoverArtImageConvert = Util.Utils.ConvertToLargeCoverArt(coverArtImage); //edited by Boelshit

                    if (!Util.Utils.FileExistsInCache(coverArtImage))
                    {
                        string imageExtension;
                        imageExtension = Path.GetExtension(imageUrl);
                        if (imageExtension.Length > 0)
                        {
                            string temporaryFilename = Path.GetTempFileName();
                            string tmpFile           = temporaryFilename;
                            temporaryFilename += imageExtension;
                            string temporaryFilenameLarge = Util.Utils.ConvertToLargeCoverArt(temporaryFilename);
                            temporaryFilenameLarge += imageExtension;
                            Util.Utils.FileDelete(tmpFile);
                            Util.Utils.FileDelete(temporaryFilenameLarge);
                            if (imageUrl.Length > 7 && imageUrl.Substring(0, 7).Equals("file://"))
                            {
                                // Local image, don't download, just copy
                                File.Copy(imageUrl.Substring(7), temporaryFilename);
                            }
                            else
                            {
                                Util.Utils.DownLoadAndCacheImage(imageUrl, temporaryFilename);
                            }
                            if (File.Exists(temporaryFilename))
                            // Reverted from mantis : 3126 (unwanted TMP folder scan and cache entry)
                            {
                                Util.Picture.CreateThumbnail(temporaryFilename, coverArtImage, (int)Thumbs.ThumbResolution,
                                                             (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsSmall);

                                if (File.Exists(temporaryFilenameLarge))
                                // Reverted from mantis : 3126 (unwanted TMP folder scan and cache entry)
                                {
                                    Util.Picture.CreateThumbnail(temporaryFilenameLarge, largeCoverArtImageConvert,
                                                                 (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, 0,
                                                                 Thumbs.SpeedThumbsLarge); //edited by Boelshit
                                }
                                else
                                {
                                    Util.Picture.CreateThumbnail(temporaryFilename, largeCoverArtImageConvert,
                                                                 (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, 0,
                                                                 Thumbs.SpeedThumbsLarge); //edited by Boelshit
                                }
                            }
                            Util.Utils.FileDelete(temporaryFilename);
                        } //if ( strExtension.Length>0)
                        else
                        {
                            Log.Info("image has no extension:{0}", imageUrl);
                        }
                    }
                    if (!Util.Utils.FileExistsInCache(coverArtImage))
                    {
                        int idMovie = currentMovie.ID;
                        System.Collections.ArrayList movies = new System.Collections.ArrayList();
                        VideoDatabase.GetFiles(idMovie, ref movies);
                        if (movies.Count > 0)
                        {
                            for (int i = 0; i < movies.Count; i++)
                            {
                                string thumbFile = Util.Utils.EncryptLine((string)movies[i]);
                                coverArtImage      = Util.Utils.GetCoverArtName(Thumbs.Videos, thumbFile);
                                largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.Videos, thumbFile);
                                if (Util.Utils.FileExistsInCache(largeCoverArtImage))
                                {
                                    currentMovie.ThumbURL = "file://" + largeCoverArtImage;
                                    Refresh(forceFolderThumb);
                                    break;
                                }
                            }
                        }
                    }

                    if (((Util.Utils.FileExistsInCache(largeCoverArtImage)) && (FolderForThumbs != string.Empty)) ||
                        forceFolderThumb)
                    //edited by BoelShit
                    {
                        // copy icon to folder also;
                        string strFolderImage = string.Empty;
                        if (forceFolderThumb)
                        {
                            strFolderImage = Path.GetFullPath(currentMovie.Path);
                        }
                        else
                        {
                            strFolderImage = Path.GetFullPath(FolderForThumbs);
                        }

                        strFolderImage += "\\folder.jpg"; //TODO
                        try
                        {
                            Util.Utils.FileDelete(strFolderImage);
                            if (forceFolderThumb)
                            {
                                if (Util.Utils.FileExistsInCache(largeCoverArtImage))
                                {
                                    File.Copy(largeCoverArtImage, strFolderImage, true);
                                }

                                else if (Util.Utils.FileExistsInCache(largeCoverArtImageConvert)) //edited by BoelShit
                                {
                                    File.Copy(largeCoverArtImageConvert, strFolderImage, true);   //edited by BoelShit
                                }
                                else //edited by BoelShit
                                {
                                    File.Copy(coverArtImage, strFolderImage, true); //edited by BoelShit
                                }
                            }
                            else
                            {
                                File.Copy(largeCoverArtImage, strFolderImage, false); //edited by BoelShit
                            }
                            File.Copy(coverArtImage, strFolderImage, false);          //edited by BoelShit
                        }
                        catch (Exception ex1)
                        {
                            Log.Error("GUIVideoInfo: Error creating folder thumb {0}", ex1.Message);
                        }
                    }
                }
            }
            catch (Exception ex2)
            {
                Log.Error("GUIVideoInfo: Error creating new thumbs for {0} - {1}", currentMovie.ThumbURL, ex2.Message);
            }
            currentMovie.SetProperties(false);
        }
Beispiel #28
0
        public ArrayList Execute()
        {
            //build the query
            ArrayList movies      = new ArrayList();
            string    whereClause = string.Empty;
            string    orderClause = string.Empty;
            string    fromClause  = "actors,movie,movieinfo,path";

            if (CurrentLevel > 0)
            {
                whereClause =
                    "where actors.idactor=movieinfo.idDirector and movieinfo.idmovie=movie.idmovie and movie.idpath=path.idpath";
            }

            for (int i = 0; i < CurrentLevel; ++i)
            {
                BuildSelect((FilterDefinition)currentView.Filters[i], ref whereClause, ref fromClause);
            }
            BuildWhere((FilterDefinition)currentView.Filters[CurrentLevel], ref whereClause);
            BuildRestriction((FilterDefinition)currentView.Filters[CurrentLevel], ref whereClause);
            BuildOrder((FilterDefinition)currentView.Filters[CurrentLevel], ref orderClause);

            //execute the query
            string sql;

            if (CurrentLevel == 0)
            {
                bool             useMovieInfoTable = false;
                bool             useAlbumTable     = false;
                bool             useActorsTable    = false;
                bool             useGenreTable     = false;
                FilterDefinition defRoot           = (FilterDefinition)currentView.Filters[0];
                string           table             = GetTable(defRoot.Where, ref useMovieInfoTable, ref useAlbumTable, ref useActorsTable,
                                                              ref useGenreTable);

                if (table == "actors")
                {
                    sql = String.Format("select * from actors ");
                    if (whereClause != string.Empty)
                    {
                        sql += "where " + whereClause;
                    }
                    if (orderClause != string.Empty)
                    {
                        sql += orderClause;
                    }
                    VideoDatabase.GetMoviesByFilter(sql, out movies, true, false, false);
                }
                else if (table == "genre")
                {
                    sql = String.Format("select * from genre ");
                    if (whereClause != string.Empty)
                    {
                        sql += "where " + whereClause;
                    }
                    if (orderClause != string.Empty)
                    {
                        sql += orderClause;
                    }
                    VideoDatabase.GetMoviesByFilter(sql, out movies, false, false, true);
                }
                else if (defRoot.Where == "year")
                {
                    movies = new ArrayList();
                    sql    = String.Format("select distinct iYear from movieinfo ");
                    SQLiteResultSet results = VideoDatabase.GetResults(sql);
                    for (int i = 0; i < results.Rows.Count; i++)
                    {
                        IMDBMovie movie = new IMDBMovie();
                        movie.Year = (int)Math.Floor(0.5d + Double.Parse(DatabaseUtility.Get(results, i, "iYear")));
                        movies.Add(movie);
                    }
                }
                else
                {
                    whereClause =
                        "where actors.idActor=movieinfo.idDirector and movieinfo.idmovie=movie.idmovie and movie.idpath=path.idpath";
                    BuildRestriction(defRoot, ref whereClause);
                    sql = String.Format("select * from {0} {1} {2}",
                                        fromClause, whereClause, orderClause);
                    VideoDatabase.GetMoviesByFilter(sql, out movies, true, true, true);
                }
            }
            else if (CurrentLevel < MaxLevels - 1)
            {
                bool             useMovieInfoTable = false;
                bool             useAlbumTable     = false;
                bool             useActorsTable    = false;
                bool             useGenreTable     = false;
                FilterDefinition defCurrent        = (FilterDefinition)currentView.Filters[CurrentLevel];
                string           table             = GetTable(defCurrent.Where, ref useMovieInfoTable, ref useAlbumTable, ref useActorsTable,
                                                              ref useGenreTable);
                sql = String.Format("select distinct {0}.* {1} {2} {3}",
                                    table, fromClause, whereClause, orderClause);
                VideoDatabase.GetMoviesByFilter(sql, out movies, useActorsTable, useMovieInfoTable, useGenreTable);
            }
            else
            {
                sql =
                    String.Format(
                        "select movieinfo.fRating,actors.strActor,movieinfo.strCredits,movieinfo.strTagLine,movieinfo.strPlotOutline,movieinfo.strPlot,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.strUserReview from {0} {1} {2}",
                        fromClause, whereClause, orderClause);
                VideoDatabase.GetMoviesByFilter(sql, out movies, true, true, true);
            }
            return(movies);
        }
Beispiel #29
0
        /// <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");
        }
        public ArrayList Execute()
        {
            //build the query
            ArrayList movies      = new ArrayList();
            string    whereClause = string.Empty;
            string    orderClause = string.Empty;
            string    fromClause  = string.Empty;

            if (CurrentLevel == MaxLevels - 1)
            {
                whereClause = "WHERE movieinfo.idmovie=movie.idmovie AND movie.idpath=path.idpath";
                fromClause  = "movie,movieinfo,path";
            }

            for (int i = 0; i < CurrentLevel; ++i)
            {
                BuildSelect((FilterDefinition)currentView.Filters[i], ref whereClause, ref fromClause);
            }

            BuildWhere((FilterDefinition)currentView.Filters[CurrentLevel], ref whereClause);
            BuildRestriction((FilterDefinition)currentView.Filters[CurrentLevel], ref whereClause);
            BuildOrder((FilterDefinition)currentView.Filters[CurrentLevel], ref orderClause);

            //execute the query
            string sql;

            if (CurrentLevel == 0)
            {
                bool             useMovieInfoTable  = false;
                bool             useAlbumTable      = false;
                bool             useActorsTable     = false;
                bool             useGenreTable      = false;
                bool             useUserGroupsTable = false;
                FilterDefinition defRoot            = (FilterDefinition)currentView.Filters[0];
                string           table = GetTable(defRoot.Where, ref useMovieInfoTable, ref useAlbumTable, ref useActorsTable,
                                                  ref useGenreTable, ref useUserGroupsTable);

                if (string.IsNullOrEmpty(table) && defRoot.Where == "actorindex")
                {
                    sql = String.Format("SELECT UPPER(SUBSTR(strActor,1,1)) AS IX, COUNT (strActor) FROM actors WHERE idActor NOT IN (SELECT DISTINCT idDirector FROM movieinfo WHERE strDirector <> 'unknown') AND strActor <> 'unknown' GROUP BY IX ");
                    VideoDatabase.GetIndexByFilter(sql, true, out movies);
                }
                else if (string.IsNullOrEmpty(table) && defRoot.Where == "directorindex")
                {
                    sql = String.Format("SELECT UPPER(SUBSTR(strActor,1,1)) AS IX, COUNT (strActor) FROM actors WHERE idActor IN (SELECT DISTINCT idDirector FROM movieinfo WHERE strDirector <> 'unknown') GROUP BY IX ");
                    VideoDatabase.GetIndexByFilter(sql, true, out movies);
                }
                else if (string.IsNullOrEmpty(table) && defRoot.Where == "titleindex")
                {
                    sql = String.Format("SELECT UPPER(SUBSTR(strTitle,1,1)) AS IX, COUNT (strTitle) FROM movieinfo GROUP BY IX ");
                    VideoDatabase.GetIndexByFilter(sql, true, out movies);
                }
                else if (table == "actors")
                {
                    if (defRoot.Where == "director")
                    {
                        sql = String.Format("SELECT idActor, strActor, imdbActorId FROM actors WHERE idActor IN (SELECT DISTINCT idDirector FROM movieinfo WHERE strDirector <> 'unknown') AND strActor <> 'unknown' ");
                    }
                    else
                    {
                        sql = String.Format("SELECT * FROM actors WHERE strActor <> 'unknown' ");
                    }

                    if (whereClause != string.Empty && defRoot.Where == "director")
                    {
                        sql += "WHERE " + whereClause;
                    }

                    if (whereClause != string.Empty && defRoot.Where == "actor")
                    {
                        sql += "AND " + whereClause;
                    }

                    if (orderClause != string.Empty)
                    {
                        sql += orderClause;
                    }
                    VideoDatabase.GetMoviesByFilter(sql, out movies, true, false, false, false);
                }
                else if (table == "genre")
                {
                    sql = String.Format("SELECT * FROM genre ");
                    if (whereClause != string.Empty)
                    {
                        sql += "WHERE " + whereClause;
                    }

                    if (orderClause != string.Empty)
                    {
                        sql += orderClause;
                    }
                    VideoDatabase.GetMoviesByFilter(sql, out movies, false, false, true, false);
                }
                else if (table == "usergroup")
                {
                    sql = String.Format("SELECT * FROM usergroup ");

                    if (whereClause != string.Empty)
                    {
                        sql += "WHERE " + whereClause;
                    }

                    if (orderClause != string.Empty)
                    {
                        sql += orderClause;
                    }
                    VideoDatabase.GetMoviesByFilter(sql, out movies, false, false, false, true);

                    ArrayList moviesExt = new ArrayList();
                    sql = String.Format("SELECT * FROM movieinfo WHERE idMovie NOT IN (SELECT DISTINCT idMovie FROM usergrouplinkmovie) ORDER BY strTitle");
                    VideoDatabase.GetMoviesByFilter(sql, out moviesExt, false, true, false, false);
                    movies.AddRange(moviesExt);
                }
                else if (defRoot.Where == "year")
                {
                    movies = new ArrayList();
                    sql    = String.Format("SELECT DISTINCT iYear FROM movieinfo ");

                    SQLiteResultSet results = VideoDatabase.GetResults(sql);

                    for (int i = 0; i < results.Rows.Count; i++)
                    {
                        IMDBMovie movie = new IMDBMovie();
                        movie.Year = (int)Math.Floor(0.5d + Double.Parse(DatabaseUtility.Get(results, i, "iYear")));
                        movies.Add(movie);
                    }
                }
                // Recently added
                else if (defRoot.Where == "recently added")
                {
                    try
                    {
                        if (string.IsNullOrEmpty(defRoot.Restriction))
                        {
                            defRoot.Restriction = "7";
                        }

                        TimeSpan ts         = new TimeSpan(Convert.ToInt32(defRoot.Restriction), 0, 0, 0);
                        DateTime searchDate = DateTime.Today - ts;

                        whereClause = String.Format("WHERE movieinfo.dateAdded >= '{0}'",
                                                    searchDate.ToString("yyyy-MM-dd" + " 00:00:00"));
                        sql = String.Format("SELECT * FROM movieinfo {0} {1}", whereClause, orderClause);

                        VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false, false);
                    }
                    catch (Exception) { }
                }
                // Recently watched
                else if (defRoot.Where == "recently watched")
                {
                    try
                    {
                        if (string.IsNullOrEmpty(defRoot.Restriction))
                        {
                            defRoot.Restriction = "7";
                        }

                        TimeSpan ts         = new TimeSpan(Convert.ToInt32(defRoot.Restriction), 0, 0, 0);
                        DateTime searchDate = DateTime.Today - ts;

                        whereClause = String.Format("WHERE movieinfo.dateWatched >= '{0}'",
                                                    searchDate.ToString("yyyy-MM-dd" + " 00:00:00"));

                        sql = String.Format("SELECT * FROM movieinfo {0} {1}", whereClause, orderClause);

                        VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false, false);
                    }
                    catch (Exception) { }
                }
                else
                {
                    whereClause =
                        "WHERE movieinfo.idmovie=movie.idmovie AND movie.idpath=path.idpath";

                    BuildRestriction(defRoot, ref whereClause);

                    sql = String.Format("SELECT * FROM {0} {1} {2}",
                                        fromClause, whereClause, orderClause);

                    VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, true, true);
                }
            }
            else if (CurrentLevel < MaxLevels - 1)
            {
                bool   useMovieInfoTable  = false;
                bool   useAlbumTable      = false;
                bool   useActorsTable     = false;
                bool   useGenreTable      = false;
                bool   useUserGroupsTable = false;
                string join   = string.Empty;
                string fields = "*";

                FilterDefinition defCurrent = (FilterDefinition)currentView.Filters[CurrentLevel];

                string table = GetTable(defCurrent.Where, ref useMovieInfoTable, ref useAlbumTable, ref useActorsTable,
                                        ref useGenreTable, ref useUserGroupsTable);

                if (defCurrent.Where == "director")
                {
                    fields = "idActor, strActor, imdbActorId";
                    join   = "INNER JOIN movieinfo ON movieinfo.idDirector = actors.idActor";
                }

                if (whereClause != string.Empty)
                {
                    if (!whereClause.ToUpperInvariant().Trim().StartsWith("WHERE"))
                    {
                        whereClause = "WHERE" + whereClause;
                    }
                }

                if (defCurrent.Where == "actor")
                {
                    if (whereClause != string.Empty)
                    {
                        whereClause = whereClause + " AND idActor NOT IN (SELECT idDirector FROM movieinfo)";
                    }
                    else
                    {
                        whereClause = " WHERE idActor NOT IN (SELECT idDirector FROM movieinfo)";
                    }
                }

                sql = String.Format("SELECT DISTINCT {0} FROM {1} {2} {3} {4}",
                                    fields, table, join, whereClause, orderClause);
                VideoDatabase.GetMoviesByFilter(sql, out movies, useActorsTable, useMovieInfoTable, useGenreTable, useUserGroupsTable);
            }
            else
            {
                sql =
                    String.Format(
                        "SELECT DISTINCT movieinfo.idMovie, " +
                        "movieinfo.idDirector, " +
                        "movieinfo.strDirector, " +
                        "movieinfo.strPlotOutline, " +
                        "movieinfo.strPlot, " +
                        "movieinfo.strTagLine, " +
                        "movieinfo.strVotes, " +
                        "movieinfo.fRating, " +
                        "movieinfo.strCast, " +
                        "movieinfo.strCredits, " +
                        "movieinfo.iYear, " +
                        "movieinfo.strGenre, " +
                        "movieinfo.strPictureURL, " +
                        "movieinfo.strTitle, " +
                        "movieinfo.IMDBID, " +
                        "movieinfo.mpaa, " +
                        "movieinfo.runtime, " +
                        "movieinfo.iswatched, " +
                        "movieinfo.strUserReview, " +
                        "movieinfo.strFanartURL, " +
                        "movieinfo.dateAdded, " +
                        "movieinfo.dateWatched, " +
                        "movieinfo.studios, " +
                        "movieinfo.country, " +
                        "movieinfo.language, " +
                        "movieinfo.lastupdate, " +
                        "movieinfo.strSortTitle, " +
                        "path.strPath, " +
                        "movie.discid, " +
                        "path.cdlabel " +
                        "FROM {0} {1} {2}",
                        fromClause, whereClause, orderClause);

                VideoDatabase.GetMoviesByFilter(sql, out movies, true, true, true, true);
            }
            return(movies);
        }