Inheritance: MovingPicturesDBTable, IComparable, IAttributeOwner
 public RenamableFile(DBMovieInfo movie, DBLocalMedia localMedia)
 {
     _movie = movie;
     _localMedia = localMedia;
     _originalName = localMedia.FullPath;
     _originalFile = localMedia.File;
 }
        public static bool GetCurrentMediaItem(out MediaItem currentMediaItem, out bool isDetailsView)
        {
            FileLog.Info("Getting selected movie information from MovingPictures.");

            currentMediaItem = new MediaItem();
            browser = MovingPicturesCore.Browser;
            isDetailsView = browser.CurrentView.ToString().Equals("DETAILS");

            selectedMovie = browser.SelectedMovie;

            currentMediaItem.Title = selectedMovie.Title;
            currentMediaItem.Year = selectedMovie.Year;
            currentMediaItem.Plot = selectedMovie.Summary;
            currentMediaItem.Poster = selectedMovie.CoverFullPath;

            // Get local file information
            currentMediaItem.FullPath = selectedMovie.LocalMedia.First().FullPath;

            // Check if TMDb ID is available
            string tmdbid = GetTmdbID(selectedMovie);
            if (!string.IsNullOrEmpty(tmdbid)) currentMediaItem.TMDb = tmdbid;

            // Next best ID to use
            string imdbid = selectedMovie.ImdbID;
            if (!string.IsNullOrEmpty(imdbid) && imdbid.Length == 9) currentMediaItem.IMDb = imdbid;

            return true;
        }
        // retrieves info from Moving Pictures
        protected override bool GrabFileDetails()
        {
            try {
                browser = MovingPicturesCore.Browser;
                selectedMovie = browser.SelectedMovie;
                List<DBLocalMedia> localMedia = selectedMovie.LocalMedia;

                _mediaDetail = new BasicMediaDetail();

                _mediaDetail.Title = selectedMovie.Title;
                _mediaDetail.Year = selectedMovie.Year;
                _mediaDetail.ImdbID = selectedMovie.ImdbID;

                _mediaDetail.Thumb = selectedMovie.CoverThumbFullPath;
                _mediaDetail.FanArt = selectedMovie.BackdropFullPath;
                _mediaDetail.Files = new List<FileInfo>();
                foreach (DBLocalMedia localMediaItem in localMedia) {
                    _mediaDetail.Files.Add(new FileInfo(localMediaItem.FullPath));
                }

                return true;
            }
            catch (Exception e) {
                logger.ErrorException(string.Format("Unexpected error when pulling data from Moving Pictures{0}", Environment.NewLine), e);
                return false;
            }
        }
        public static DBSourceMovieInfo Get(DBMovieInfo movie, DBSourceInfo source)
        {
            foreach (DBSourceMovieInfo currInfo in movie.SourceMovieInfo)
                if (currInfo.Source == source)
                    return currInfo;

            return null;
        }
Esempio n. 5
0
        /// <summary>
        /// Play a movie with MovingPictures.
        ///
        /// Taken from Trakt-for-MediaPortal:
        /// https://github.com/Technicolour/Trakt-for-Mediaportal/blob/master/TraktPlugin/TraktHandlers/MovingPictures.cs
        /// </summary>
        /// <param name="movie">Movie to play</param>
        /// <param name="resume">Ask to resume movie?</param>
        public static void PlayMovie(DBMovieInfo movie, bool resume, int startPosition = 0)
        {
            if (movie == null) return;

            // Play on a new thread
            ThreadStart ts = delegate() { DoPlayMovie(movie, resume, startPosition); };
            Thread playMovieAsync = new Thread(ts);
            playMovieAsync.Start();
        }
        public static void AddWatchedHistory(DBMovieInfo movie, DBUser user)
        {
            DBWatchedHistory history = new DBWatchedHistory();
            history.DateWatched = DateTime.Now;
            history.Movie = movie;
            history.User = user;

            movie.WatchedHistory.Add(history);
            history.Commit();
            movie.Commit();
        }
        private static string DetermineGroupName(DBMovieInfo movie)
        {
            switch (Browser.CurrentSortField) {
                case SortingFields.Title:
                    // Either the first character of the title, or the word "Numeric"
                    // should we have a category for special characters like numeric has?
                    string groupName = "";
                    if (movie.SortBy.Trim().Length > 0)
                        groupName = movie.SortBy.Trim().Substring(0, 1).ToUpper();

                    // group all non-word characters together
                    if (!Regex.Match(groupName, @"\w").Success)
                        groupName = "#";

                    // numeric group
                    int iTemp;
                    if (int.TryParse(groupName, out iTemp))
                        groupName = "0-9";

                    return groupName;

                case SortingFields.DateAdded:
                    return GetDateGroupName(movie.DateAdded.Date);
                case SortingFields.ReleaseDate:
                    return Translation.GetByName("MonthName" + movie.ReleaseDate.Month.ToString()) + ", " + movie.ReleaseDate.Year.ToString();
                case SortingFields.Year:
                    return movie.Year.ToString();
                case SortingFields.Certification:
                    return movie.Certification.Trim().ToUpper();
                case SortingFields.Language:
                    return movie.Language.Trim().ToUpper();
                case SortingFields.Score:
                    return Math.Round(movie.Score).ToString();
                case SortingFields.Runtime:
                    return "";
                case SortingFields.FileSize:
                    string size = movie.LocalMedia[0].FileSize.ToFormattedByteString();
                    // split the string to get size and unit
                    string[] splits = size.Split(' ');
                    // round the size to the nearest unit
                    int roundedSize = (int)Math.Round(double.Parse(splits[0]), MidpointRounding.ToEven);
                    // group by rounded size
                    return roundedSize.ToString() + " " + splits[1];
                case SortingFields.FilePath:
                    if (movie.LocalMedia.Count > 0)
                        return movie.LocalMedia[0].File.Directory.ToString();
                    else
                        return "";
                default:
                    return "";
            }
        }
        public bool GetArtwork(DBMovieInfo movie)
        {
            string myVideoCoversFolder = Config.GetFolder(Config.Dir.Thumbs) + "\\Videos\\Title";

            Regex cleaner = new Regex("[\\\\/:*?\"<>|]");
            string cleanTitle = cleaner.Replace(movie.Title, "_");
            string id = movie.GetSourceMovieInfo(SourceInfo).Identifier;
            string filename = myVideoCoversFolder + "\\" + cleanTitle + "{" + id + "}L.jpg";

            if (System.IO.File.Exists(filename))
                return movie.AddCoverFromFile(filename);

            return false;
        }
        private static string DetermineGroupName(DBMovieInfo movie)
        {
            switch (Browser.CurrentSortField) {
                case SortingFields.Title:
                    // Either the first character of the title, or the word "Numeric"
                    // should we have a category for special characters like numeric has?
                    string groupName = "";
                    if (movie.SortBy.Trim().Length > 0)
                        groupName = movie.SortBy.Trim().Substring(0, 1).ToUpper();

                    // group all non-word characters together
                    if (!Regex.Match(groupName, @"\w").Success)
                        groupName = "#";

                    // numeric group
                    int iTemp;
                    if (int.TryParse(groupName, out iTemp))
                        groupName = "0-9";

                    return groupName;

                case SortingFields.DateAdded:
                    return GetDateGroupName(movie.DateAdded.Date);
                case SortingFields.Year:
                    return movie.Year.ToString();
                case SortingFields.Certification:
                    return movie.Certification.Trim().ToUpper();
                case SortingFields.Language:
                    return movie.Language.Trim().ToUpper();
                case SortingFields.Score:
                    return Math.Round(movie.Score).ToString();
                case SortingFields.Runtime:
                    return "";
                case SortingFields.FilePath:
                    if (movie.LocalMedia.Count > 0)
                        return movie.LocalMedia[0].File.Directory.ToString();
                    else
                        return "";
                default:
                    return "";
            }
        }
        // Returns a list of files and directories ready to be renamed, based on this movie.
        // To perform a rename on this list call list.RenameApprovedItems();
        public List<Renamable> GetRenameActionList(DBMovieInfo movie)
        {
            List<Renamable> renamableList = new List<Renamable>();

            // if this is a disk or a ripped disk, we dont want to rename any files
            if (movie.LocalMedia[0].ImportPath.IsOpticalDrive ||
                movie.LocalMedia[0].IsBluray ||
                movie.LocalMedia[0].IsDVD ||
                movie.LocalMedia[0].IsHDDVD) {

                return renamableList;
            }

            foreach (DBLocalMedia currFile in movie.LocalMedia) {
                string primaryExtension = Path.GetExtension(currFile.FullPath);
                string path = Path.GetDirectoryName(currFile.FullPath);
                string newFileName = GetNewFileName(currFile);

                // generate primary renamable file for the current video file
                if (MovingPicturesCore.Settings.RenameFiles) {
                    RenamableFile primaryRenamable = new RenamableFile(movie, currFile);
                    primaryRenamable.NewName = path + @"\" + newFileName + primaryExtension;
                    renamableList.Add(primaryRenamable);
                }

                // generate secondary renamable files for subtitles, etc
                if (MovingPicturesCore.Settings.RenameSecondaryFiles) {
                    renamableList.AddRange(GetSecondaryFiles(currFile));
                }
            }

            // generate a renamable object for the directory as needed
            if (MovingPicturesCore.Settings.RenameFolders) {
                RenamableDirectory renamableDir = GetDirectoryRenamable(movie);
                if (renamableDir != null) renamableList.Add(renamableDir);
            }

            renamableList.UpdateFinalFilenames();
            return renamableList;
        }
Esempio n. 11
0
        public static Backdrop FromUrl(DBMovieInfo movie, string url, bool ignoreRestrictions, out ImageLoadResults status)
        {
            ImageSize minSize = null;
            ImageSize maxSize = new ImageSize();

            if (!ignoreRestrictions) {
                minSize = new ImageSize();
                minSize.Width = MovingPicturesCore.Settings.MinimumBackdropWidth;
                minSize.Height = MovingPicturesCore.Settings.MinimumBackdropHeight;
            }

            maxSize.Width = MovingPicturesCore.Settings.MaximumBackdropWidth;
            maxSize.Height = MovingPicturesCore.Settings.MaximumBackdropHeight;

            bool redownload = MovingPicturesCore.Settings.RedownloadBackdrops;

            Backdrop newBackdrop = new Backdrop();
            newBackdrop.Filename = GenerateFilename(movie, url);
            status = newBackdrop.FromUrl(url, ignoreRestrictions, minSize, maxSize, redownload);

            switch (status) {
                case ImageLoadResults.SUCCESS:
                    logger.Info("Added backdrop for \"{0}\" from: {1}", movie.Title, url);
                    break;
                case ImageLoadResults.SUCCESS_REDUCED_SIZE:
                    logger.Info("Added resized backdrop for \"{0}\" from: {1}", movie.Title, url);
                    break;
                case ImageLoadResults.FAILED_ALREADY_LOADED:
                    logger.Debug("Backdrop for \"{0}\" from the following URL is already loaded: {1}", movie.Title, url);
                    return null;
                case ImageLoadResults.FAILED_TOO_SMALL:
                    logger.Debug("Downloaded backdrop for \"{0}\" failed minimum resolution requirements: {1}", movie.Title, url);
                    return null;
                case ImageLoadResults.FAILED:
                    logger.Error("Failed downloading backdrop for \"{0}\": {1}", movie.Title, url);
                    return null;
            }

            return newBackdrop;
        }
Esempio n. 12
0
 public void Play(DBMovieInfo movie)
 {
     Play(movie, 1);
 }
        private void onMovieStopped(DBMovieInfo movie)
        {
            // reset player
            resetPlayer();

            if (MovingPicturesCore.Settings.FollwitEnabled)
                MovingPicturesCore.Follwit.CurrentlyWatching(movie, false);

            // invoke event
            if (MovieStopped != null)
                MovieStopped(movie);
        }
        private bool PromptUserToResume(DBMovieInfo movie)
        {
            if (movie.UserSettings == null || movie.UserSettings.Count == 0 || (movie.ActiveUserSettings.ResumePart < 2 && movie.ActiveUserSettings.ResumeTime <= 30))
                return false;

            logger.Debug("Resume Prompt: Movie='{0}', ResumePart={1}, ResumeTime={2}", movie.Title, movie.ActiveUserSettings.ResumePart, movie.ActiveUserSettings.ResumeTime);

            // figure out the resume time to display to the user
            int displayTime = movie.ActiveUserSettings.ResumeTime;
            if (movie.LocalMedia.Count > 1) {
                for (int i = 0; i < movie.ActiveUserSettings.ResumePart - 1; i++) {
                    if (movie.LocalMedia[i].Duration > 0)
                        displayTime += (movie.LocalMedia[i].Duration / 1000); // convert milliseconds to seconds
                }
            }

            string sbody = movie.Title + "\n" + Translation.ResumeFrom + " " + Util.Utils.SecondsToHMSString(displayTime);
            bool bResume = _gui.ShowCustomYesNo(Translation.ResumeFromLast, sbody, null, null, true);

            if (bResume)
                return true;

            return false;
        }
        public bool GetArtwork(DBMovieInfo movie)
        {
            if (movie == null)
                return false;

            // do we have an id?
            string movieId = getMovieId(movie);
            if (string.IsNullOrEmpty(movieId))
                return false;

            string url = apiMovieArtwork;
            if (!string.IsNullOrEmpty(MovingPicturesCore.Settings.FanartTVClientKey))
                url = url + "&client_key=" + MovingPicturesCore.Settings.FanartTVClientKey;

            // try to get movie artwork
            string response = getJson(string.Format(apiMovieArtwork, movieId));
            if (response == null)
                return false;

            // de-serialize json response
            var movieImages = response.FromJson<Artwork>();
            if (movieImages == null)
                return false;

            // check if we have any posters
            if (movieImages.movieposter == null || movieImages.movieposter.Count == 0)
                return false;

            // filter posters by language
            var langPosters = movieImages.movieposter.Where(p => p.lang == MovingPicturesCore.Settings.DataProviderLanguageCode);

            // if no localised posters available use all posters
            if (langPosters.Count() == 0) {
                langPosters = movieImages.movieposter;
            }

            // sort by highest rated / most popular
            langPosters = langPosters.OrderByDescending(p => p.likes);

            // grab coverart loading settings
            int maxCovers = MovingPicturesCore.Settings.MaxCoversPerMovie;
            int maxCoversInSession = MovingPicturesCore.Settings.MaxCoversPerSession;
            int coversAdded = 0;

            // download posters
            foreach (var poster in langPosters) {
                // if we have hit our limit quit
                if (movie.AlternateCovers.Count >= maxCovers || coversAdded >= maxCoversInSession)
                    return true;

                // get url for cover and load it via the movie object
                string coverPath = poster.url;
                if (coverPath.Trim() != string.Empty) {
                    if (movie.AddCoverFromURL(coverPath) == ImageLoadResults.SUCCESS)
                        coversAdded++;
                }
            }

            if (coversAdded > 0) {
                // Update source info
                movie.GetSourceMovieInfo(SourceInfo).Identifier = movieId;
                return true;
            }

            return false;
        }
        private void onMovieEnded(DBMovieInfo movie)
        {
            // update watched counter
            updateMovieWatchedCounter(movie);

            // clear resume state
            clearMovieResumeState(movie);

            // reset player
            resetPlayer();

            if (MovingPicturesCore.Settings.FollwitEnabled)
                MovingPicturesCore.Follwit.CurrentlyWatching(movie, false);

            // invoke event
            if (MovieEnded != null)
                MovieEnded(movie);
        }
        /// <summary>
        /// returns the imdbid or tmdbid of the movie
        /// </summary>
        private string getMovieId(DBMovieInfo movie)
        {
            if (movie == null)
                return null;

            // check for imdb id
            if (movie.ImdbID != null && movie.ImdbID.Trim().Length == 9)
                return movie.ImdbID.Trim();

            // check for tmdb id
            string tmdbId = getTmdbId(movie);
            if (!string.IsNullOrEmpty(tmdbId))
                return tmdbId;

            // fanart.tv lookup can only be done on imdb/tmdb ids
            return null;
        }
        /// <summary>
        /// returns the tmdb id for a movie if its exists
        /// </summary>
        private string getTmdbId(DBMovieInfo movie)
        {
            // get source info, maybe already have it from poster or movieinfo
            var tmdbSource = DBSourceInfo.GetAll().Find(s => s.ToString() == "themoviedb.org");
            if (tmdbSource == null)
                return null;

            string id = movie.GetSourceMovieInfo(tmdbSource).Identifier;
            if (id == null || id.Trim() == string.Empty)
                return null;

            return id;
        }
Esempio n. 19
0
 public static DBSourceMovieInfo Get(DBMovieInfo movie, int scriptID)
 {
     return(Get(movie, DBSourceInfo.GetFromScriptID(scriptID)));
 }
Esempio n. 20
0
        private void updateMovieResumeState(DBMovieInfo movie, int part, int timePlayed, byte[] resumeData, int titleBD)
        {
            if (movie.UserSettings.Count == 0)
                return;

            // get the user settings for the default profile (for now)
            DBUserMovieSettings userSetting = movie.ActiveUserSettings;

            if (timePlayed > 0 && g_Player.SetResumeBDTitleState >= 0) {
                // set part and time data
                userSetting.ResumePart = part;
                userSetting.ResumeTime = timePlayed;
                userSetting.ResumeData = new ByteArray(resumeData);
                userSetting.ResumeTitleBD = titleBD;
                logger.Debug("Updating movie resume state.");
            }
            else {
                // clear the resume settings
                userSetting.ResumePart = 0;
                userSetting.ResumeTime = 0;
                userSetting.ResumeData = null;
                userSetting.ResumeTitleBD = 1000;
                g_Player.SetResumeBDTitleState = userSetting.ResumeTitleBD;
                logger.Debug("Clearing movie resume state.");
            }
            // save the changes to the user setting for this movie
            userSetting.Commit();
        }
Esempio n. 21
0
        private void playMovie(DBMovieInfo movie, int requestedPart)
        {
            logger.Debug("playMovie()");
            _playerState = MoviePlayerState.Processing;

            if (movie == null || requestedPart > movie.LocalMedia.Count || requestedPart < 1) {
                resetPlayer();
                return;
            }

            logger.Debug("Request: Movie='{0}', Part={1}", movie.Title, requestedPart);
            for (int i = 0; i < movie.LocalMedia.Count; i++) {
                logger.Debug("LocalMedia[{0}] = {1}, Duration = {2}", i, movie.LocalMedia[i].FullPath, movie.LocalMedia[i].Duration);
            }

            int part = requestedPart;

            // if this is a request to start the movie from the beginning, check if we should resume
            // or prompt the user for disk selection
            if (requestedPart == 1) {
                // check if we should be resuming, and if not, clear resume data
                switch (PromptUserToResume(movie))
                {
                  case ResumeDialogResult.Resume: _resumeActive = true; part = movie.ActiveUserSettings.ResumePart; break;
                  case ResumeDialogResult.FromBeginning: _resumeActive = false; clearMovieResumeState(movie); break;
                  case ResumeDialogResult.Cancel:return;
                }

                // if we have a multi-part movie composed of disk images and we are not resuming
                // ask which part the user wants to play
                if (!_resumeActive && movie.LocalMedia.Count > 1 && (movie.LocalMedia[0].IsImageFile || movie.LocalMedia[0].IsVideoDisc)) {
                    GUIDialogFileStacking dlg = (GUIDialogFileStacking)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_FILESTACKING);
                    if (null != dlg) {
                        dlg.SetNumberOfFiles(movie.LocalMedia.Count);
                        dlg.DoModal(GUIWindowManager.ActiveWindow);
                        part = dlg.SelectedFile;
                        if (part < 1) {
                            resetPlayer();
                            return;
                        }
                    }
                }
            }

            DBLocalMedia mediaToPlay = movie.LocalMedia[part - 1];
            MediaState mediaState = mediaToPlay.State;
            while (mediaState != MediaState.Online) {
                switch (mediaState) {
                    case MediaState.Removed:
                        _gui.ShowMessage("Error", Translation.MediaIsMissing);
                        resetPlayer();
                        return;
                    case MediaState.Offline:
                        string bodyString = String.Format(Translation.MediaNotAvailableBody, mediaToPlay.MediaLabel);
                        // Special debug line to troubleshoot availability issues
                        logger.Debug("Media not available: Path={0}, DriveType={1}, Serial={2}, ExpectedSerial={3}",
                            mediaToPlay.FullPath, mediaToPlay.ImportPath.GetDriveType().ToString(),
                            mediaToPlay.ImportPath.GetVolumeSerial(), mediaToPlay.VolumeSerial);

                        // Prompt user to enter media
                        if (!_gui.ShowCustomYesNo(Translation.MediaNotAvailableHeader, bodyString, Translation.Retry, Translation.Cancel, true)) {
                            // user cancelled so exit
                            resetPlayer();
                            return;
                        }
                        break;
                    case MediaState.NotMounted:
                        // Mount this media
                        MountResult result = mediaToPlay.Mount();
                        while (result == MountResult.Pending) {
                            if (_gui.ShowCustomYesNo(Translation.VirtualDriveHeader, Translation.VirtualDriveMessage, Translation.Retry, Translation.Cancel, true)) {
                                // User has chosen to retry
                                // We stay in the mount loop
                                result = mediaToPlay.Mount();
                            }
                            else {
                                // Exit the player
                                resetPlayer();
                                return;
                            }
                        }

                        // If the mounting failed (can not be solved within the loop) show error and return
                        if (result == MountResult.Failed) {
                            _gui.ShowMessage(Translation.Error, Translation.FailedMountingImage);
                            // Exit the player
                            resetPlayer();
                            return;
                        }

                        // Mounting was succesfull, break the mount loop
                        break;
                }

                // Check mediaState again
                mediaState = mediaToPlay.State;
            }

            // Get the path to the playable video.
            string videoPath = mediaToPlay.GetVideoPath();

            // If the media is an image, it will be mounted by this point so
            // we flag the mounted playback variable
            mountedPlayback = mediaToPlay.IsImageFile;

            // if we do not have MediaInfo but have the AutoRetrieveMediaInfo setting toggled
            // get the media info
            if (!mediaToPlay.HasMediaInfo && MovingPicturesCore.Settings.AutoRetrieveMediaInfo) {
                mediaToPlay.UpdateMediaInfo();
                mediaToPlay.Commit();
            }

            // store the current media object so we can request it later
            queuedMedia = mediaToPlay;

            // start playback

            if (_resumeActive && movie.LocalMedia[0].IsBluray) {
                _forcePlay = true;
                g_Player.SetResumeBDTitleState = movie.ActiveUserSettings.ResumeTitleBD;

            }
            logger.Info("Playing: Movie='{0}' FullPath='{1}', VideoPath='{2}', Mounted='{3}'", movie.Title, mediaToPlay.FullPath, videoPath, mountedPlayback.ToString());
            playFile(videoPath, mediaToPlay.VideoFormat);
        }
Esempio n. 22
0
        private void onMovieEnded(DBMovieInfo movie)
        {
            // update watched counter
            updateMovieWatchedCounter(movie);

            // clear resume state
            clearMovieResumeState(movie);

            // reset player
            resetPlayer();

            // invoke event
            if (MovieEnded != null)
                MovieEnded(movie);
        }
Esempio n. 23
0
        public void Play(DBMovieInfo movie, int part)
        {
            // stop the mediainfo background process if it is running
            MovingPicturesCore.ProcessManager.CancelProcess(typeof(MediaInfoUpdateProcess));

            // stop the internal player if it's running
            if (g_Player.Playing)
                g_Player.Stop();

            // set player state working
            _playerState = MoviePlayerState.Processing;

            // queue the local media object in case we first need to play the custom intro
            // we can get back to it later.
            queuedMedia = movie.LocalMedia[part-1];

            // try playing our custom intro (if present). If successful quit, as we need to
            // wait for the intro to finish.
            bool success = playCustomIntro();
            if (success) return;

            // Start movie
            playMovie(movie, part);
        }
Esempio n. 24
0
 private void clearMovieResumeState(DBMovieInfo movie)
 {
     updateMovieResumeState(movie, 0, 0, null, 0);
 }
        public bool CurrentlyWatching(DBMovieInfo movie, bool isWatching)
        {
            if (!MovingPicturesCore.Settings.FollwitEnabled) {
                logger.Warn("Attempt to call follw.it made when service is disabled.");
                return false;
            }

            if (!IsOnline) {
                logger.Warn("Can not send movie watched count to follw.it because service is offline");
                return false;
            }

            try {
                if (MovingPicturesCore.Settings.RestrictSynchronizedMovies) {
                    var filtered = MovingPicturesCore.Settings.FollwitSyncFilter.Filter(new List<DBMovieInfo>() {movie});
                    if (filtered.Count == 0)
                        return false;
                }

                FollwitBackgroundProcess bgProc = new FollwitBackgroundProcess();
                bgProc.Action = isWatching ? FitActions.BeginWatching : FitActions.EndWatching;
                bgProc.Movies.Add(movie);
                MovingPicturesCore.ProcessManager.StartProcess(bgProc);
            }
            catch (Exception ex) {
                logger.ErrorException("Unexpected error sending 'now watching' information to follw.it!", ex);
                _follwitAPI = null;
                MovingPicturesCore.Follwit.Status = FollwitConnector.StatusEnum.INTERNAL_ERROR;
                return false;
            }

            return true;
        }
Esempio n. 26
0
        private void onMovieStopped(DBMovieInfo movie)
        {
            // reset player
            resetPlayer();

            // invoke event
            if (MovieStopped != null)
                MovieStopped(movie);
        }
        public bool WatchMovie(DBMovieInfo movie, bool includeInStream)
        {
            if (currentlySyncingMovies.Contains(movie))
                return true;

            if (!MovingPicturesCore.Settings.FollwitEnabled) {
                logger.Warn("Attempt to call follw.it made when service is disabled.");
                return false;
            }

            if (!IsOnline) {
                logger.Warn("Can not send movie watched count to follw.it because service is offline");
                return false;
            }

            try {
                FollwitBackgroundProcess bgProc = new FollwitBackgroundProcess();
                bgProc.Action = includeInStream ? FitActions.WatchMovie : FitActions.WatchMovieIgnoreStream;
                bgProc.Movies.Add(movie);
                MovingPicturesCore.ProcessManager.StartProcess(bgProc);
            }
            catch (Exception ex) {
                logger.ErrorException("Unexpected error sending 'movie watched' information to follw.it!", ex);
                _follwitAPI = null;
                MovingPicturesCore.Follwit.Status = FollwitConnector.StatusEnum.INTERNAL_ERROR;
                return false;
            }

            return true;
        }
Esempio n. 28
0
        private ResumeDialogResult PromptUserToResume(DBMovieInfo movie)
        {
            if (movie.UserSettings == null || movie.UserSettings.Count == 0 || (movie.ActiveUserSettings.ResumePart < 2 && movie.ActiveUserSettings.ResumeTime <= 30))
                return ResumeDialogResult.FromBeginning;

            logger.Debug("Resume Prompt: Movie='{0}', ResumePart={1}, ResumeTime={2}", movie.Title, movie.ActiveUserSettings.ResumePart, movie.ActiveUserSettings.ResumeTime);

            // figure out the resume time to display to the user
            int displayTime = movie.ActiveUserSettings.ResumeTime;
            if (movie.LocalMedia.Count > 1) {
                for (int i = 0; i < movie.ActiveUserSettings.ResumePart - 1; i++) {
                    if (movie.LocalMedia[i].Duration > 0)
                        displayTime += (movie.LocalMedia[i].Duration / 1000); // convert milliseconds to seconds
                }
            }

            string sbody = movie.Title + "\n" + Translation.ResumeFrom + " " + Util.Utils.SecondsToHMSString(displayTime);
            GUIResumeDialog.Result result = GUIResumeDialog.ShowResumeDialog(Translation.ResumeFromLast, displayTime,
                                                     GUIResumeDialog.MediaType.Video);
            switch (result)
            {
              case GUIResumeDialog.Result.PlayFromBeginning: return ResumeDialogResult.FromBeginning;
              case GUIResumeDialog.Result.PlayFromLastStopTime: return ResumeDialogResult.Resume;
              default: return ResumeDialogResult.Cancel;
            }
        }
        public bool GetBackdrop(DBMovieInfo movie)
        {
            if (movie == null)
                return false;

            // if we already have a backdrop move on for now
            if (movie.BackdropFullPath.Trim().Length > 0)
                return true;

            // do we have an id?
            string movieId = getMovieId(movie);
            if (string.IsNullOrEmpty(movieId))
                return false;

            string url = apiMovieArtwork;
            if (!string.IsNullOrWhiteSpace(MovingPicturesCore.Settings.FanartTVClientKey))
                url = url + "&client_key=" + MovingPicturesCore.Settings.FanartTVClientKey;

            string response = getJson(string.Format(url, movieId));
            if (response == null)
                return false;

            // de-serialize json response
            var movieImages = response.FromJson<Artwork>();
            if (movieImages == null)
                return false;

            // check if we have any backdrops
            if (movieImages.moviebackground == null || movieImages.moviebackground.Count == 0)
                return false;

            // get the 1st (highest rated) movie backdrop
            // only single backdrops are currently supported
            string backdropUrl = movieImages.moviebackground.First().url;
            if (backdropUrl.Trim().Length > 0) {
                if (movie.AddBackdropFromURL(backdropUrl) == ImageLoadResults.SUCCESS) {
                    // store either the imdb id or tmdb id of movie for identifier
                    // there is no per movie id from fanart.tv, only per image id
                    movie.GetSourceMovieInfo(SourceInfo).Identifier = movieId;
                    return true;
                }
            }

            // if we get here we didn't manage to find a proper backdrop
            return false;
        }
Esempio n. 30
0
        private void updateMovieWatchedCounter(DBMovieInfo movie)
        {
            if (movie == null)
                return;

            // get the user settings for the default profile (for now)
            DBUserMovieSettings userSetting = movie.ActiveUserSettings;
            userSetting.WatchedCount++; // increment watch counter
            userSetting.Commit();
            DBWatchedHistory.AddWatchedHistory(movie, userSetting.User);
        }
 public UpdateResults Update(DBMovieInfo movie)
 {
     return UpdateResults.FAILED;
 }