/// <summary>
        /// In database view the file info isn't set.
        /// This function trys to get the files from database and then creates the file info for it.
        /// </summary>
        /// <param name="item">Item to store the file info</param>
        /// <returns>True if FileInformation was created otherwise false</returns>
        private bool TryGetFileInfo(ref GUIListItem item)
        {
            if (item == null)
            {
                return(false);
            }

            try
            {
                IMDBMovie movie1 = item.AlbumInfoTag as IMDBMovie;
                if (movie1 != null && movie1.ID > 0)
                {
                    ArrayList movies1 = new ArrayList();

                    VideoDatabase.GetFiles(movie1.ID, ref movies1);

                    if (movies1.Count > 0)
                    {
                        item.FileInfo = new Util.FileInformation(movies1[0] as string, false);
                    }
                }
            }
            catch (Exception exp)
            {
                Log.Error("VideoSort::TryGetFileInfo -> Exception: {0}", exp.Message);
            }

            return(item.FileInfo != null);
        }
示例#2
0
        protected override void OnClick(int itemIndex)
        {
            GUIListItem item = facadeLayout.SelectedListItem;

            if (item == null)
            {
                return;
            }
            if (item.IsFolder)
            {
                currentSelectedItem = -1;
                if (item.Label == "..")
                {
                    handler.CurrentLevel--;
                }
                else
                {
                    IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
                    ((VideoViewHandler)handler).Select(movie);
                }
                LoadDirectory(item.Path);
            }
            else
            {
                IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
                if (movie == null)
                {
                    return;
                }
                if (movie.ID < 0)
                {
                    return;
                }
                GUIVideoFiles.Reset(); // reset pincode

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

                if (files.Count > 1)
                {
                    GUIVideoFiles._stackedMovieFiles = files;
                    GUIVideoFiles._isStacked         = true;
                    GUIVideoFiles.MovieDuration(files);
                }
                else
                {
                    GUIVideoFiles._isStacked = false;
                }
                GUIVideoFiles.PlayMovie(movie.ID, false);
            }
        }
示例#3
0
        protected override void OnQueueItem(int itemIndex)
        {
            // add item 2 playlist
            GUIListItem listItem = facadeLayout[itemIndex];
            ArrayList   files    = new ArrayList();

            if (handler.CurrentLevel < handler.MaxLevels - 1)
            {
                //queue
                ((VideoViewHandler)handler).Select(listItem.AlbumInfoTag as IMDBMovie);
                ArrayList movies = ((VideoViewHandler)handler).Execute();
                handler.CurrentLevel--;
                foreach (IMDBMovie movie in movies)
                {
                    if (movie.ID > 0)
                    {
                        GUIListItem item = new GUIListItem();
                        item.Path     = movie.File;
                        item.Label    = movie.Title;
                        item.Duration = movie.RunTime * 60;
                        item.IsFolder = false;
                        VideoDatabase.GetFiles(movie.ID, ref files);
                        foreach (string file in files)
                        {
                            item.AlbumInfoTag = movie;
                            item.Path         = file;
                            AddItemToPlayList(item);
                        }
                    }
                }
            }
            else
            {
                IMDBMovie movie = listItem.AlbumInfoTag as IMDBMovie;
                VideoDatabase.GetFiles(movie.ID, ref files);
                foreach (string file in files)
                {
                    listItem.Path = file;
                    AddItemToPlayList(listItem);
                }
            }
            //move to next item
            GUIControl.SelectItemControl(GetID, facadeLayout.GetID, itemIndex + 1);
        }
        //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);
        }
        // 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;
            }
        }