Beispiel #1
0
        public static DBAlbumInfo Get(DBTrackInfo mv)
        {
            if (mv.AlbumInfo.Count == 0)
            {
                return(null);
            }

            foreach (DBAlbumInfo db1 in GetAll())
            {
                if (db1.MdID != null && db1.MdID.Trim().Length > 0)
                {
                    if (String.Equals(db1.MdID.Trim(), mv.AlbumInfo[0].MdID.Trim(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(db1);
                    }
                }

                if (db1.Album.Trim().Length > 0)
                {
                    if (String.Equals(db1.Album.Trim(), mv.AlbumInfo[0].Album.Trim(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(db1);
                    }
                }
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Returns a list of DBTrackInfo objects that match the artist
        /// </summary>
        /// <param name="mbid"></param>
        /// <returns></returns>
        public static List <DBTrackInfo> GetEntriesByArtist(DBArtistInfo mv)
        {
            if (mv == null)
            {
                return(null);
            }

            lock (lockList)
            {
                List <DBTrackInfo> results = new List <DBTrackInfo>();
                List <DBTrackInfo> db1     = DBTrackInfo.GetAll();

                foreach (DBTrackInfo db2 in db1)
                {
                    if (db2.ArtistInfo.Count > 0)
                    {
                        if (mv == db2.ArtistInfo[0])
                        {
                            results.Add(db2);
                        }
                    }
                }
                return(results);
            }
        }
Beispiel #3
0
        public static void AddWatchedHistory(DBTrackInfo MusicVideo, DBUser user)
        {
            DBWatchedHistory history = new DBWatchedHistory();

            history.DateWatched = DateTime.Now;
            history.Movie       = MusicVideo;
            history.User        = user;
            history.Commit();
            MusicVideo.Commit();
        }
        public static DBSourceMusicVideoInfo Get(DBTrackInfo mv, DBSourceInfo source)
        {
            foreach (DBSourceMusicVideoInfo currInfo in mv.SourceMusicVideoInfo)
            {
                if (currInfo.Source == source)
                {
                    return(currInfo);
                }
            }

            return(null);
        }
        // One time upgrade tasks for movie information
        public static void PerformMusicVideoInformationUpgradeCheck()
        {
            Version ver = Assembly.GetExecutingAssembly().GetName().Version;

            logger.Info("Performing MusicVideo Information Upgrade Check...");

            float count            = 0;
            List <DBTrackInfo> mvs = DBTrackInfo.GetAll();
            float total            = mvs.Count;

            foreach (DBTrackInfo mv in mvs)
            {
                if (MaintenanceProgress != null)
                {
                    MaintenanceProgress("", (int)(count * 100 / total));
                }
                count++;

                // Skip uncommited files
                if (mv.ID == null)
                {
                    continue;
                }

                #region Upgrades required for 0.7.1

                if (mvCentralCore.GetDbVersionNumber() < new Version("0.7.1"))
                {
                    if (mv.LocalMedia.Count > 0 && mv.LocalMedia[0].ImportPath != null)
                    {
                        if (mv.LocalMedia[0].ImportPath.IsOpticalDrive && mv.LocalMedia[0].IsAvailable)
                        {
                            mv.DateAdded = mv.LocalMedia[0].File.CreationTime;
                        }
                        else
                        {
                            mv.DateAdded = mv.DateAdded.AddSeconds((double)mv.ID);
                        }
                    }
                }

                #endregion

                // commit MusicVideo
                mv.Commit();
            }

            if (MaintenanceProgress != null)
            {
                MaintenanceProgress("", 100);
            }
        }
Beispiel #6
0
        public static DBArtistInfo GetOrCreate(DBTrackInfo mv)
        {
            DBArtistInfo rtn = mv.ArtistInfo[0];

            if (rtn != null)
            {
                return(rtn);
            }

            rtn = new DBArtistInfo();
            mv.ArtistInfo.Add(rtn);
            return(rtn);
        }
Beispiel #7
0
 /// <summary>
 /// Returns a list of DBTrackInfo that are marked as DVDs
 /// </summary>
 /// <param name="mbid"></param>
 /// <returns></returns>
 public static List <DBTrackInfo> GetDVDEntries()
 {
     lock (lockList)
     {
         List <DBTrackInfo> results = new List <DBTrackInfo>();
         List <DBTrackInfo> db1     = DBTrackInfo.GetAll();
         foreach (DBTrackInfo db2 in db1)
         {
             if (db2.LocalMedia[0].IsDVD)
             {
                 results.Add(db2);
             }
         }
         return(results);
     }
 }
        public static DBSourceMusicVideoInfo GetOrCreate(DBTrackInfo mv, DBSourceInfo source)
        {
            DBSourceMusicVideoInfo rtn = Get(mv, source);

            if (rtn != null)
            {
                return(rtn);
            }

            rtn            = new DBSourceMusicVideoInfo();
            rtn.musicvideo = mv;
            rtn.Source     = source;

            // if this is the IMDb data source, populate the id with the imdb_id field
//            if (rtn.ScriptID == 874902 && mv.ImdbID.Trim().Length == 9)
//                rtn.Identifier = mv.ImdbID;

            mv.SourceMusicVideoInfo.Add(rtn);
            return(rtn);
        }
        // Loops through all local files in the system and removes anything that's invalid.
        public static void RemoveInvalidFiles()
        {
            logger.Info("Checking for invalid file entries in the database.");

            float count = 0;
            List <DBLocalMedia> files = DBLocalMedia.GetAll();
            float total = files.Count;

            int cleaned = 0;

            foreach (DBLocalMedia currFile in files)
            {
                if (MaintenanceProgress != null)
                {
                    MaintenanceProgress("", (int)(count * 100 / total));
                }
                count++;

                // Skip previously deleted files
                if (currFile.ID == null)
                {
                    continue;
                }

                // Remove Orphan Files
                if (currFile.AttachedmvCentral.Count == 0 && !currFile.Ignored)
                {
                    logger.Info("Removing: {0} (orphan)", currFile.FullPath);
                    currFile.Delete();
                    cleaned++;
                    continue;
                }

                // remove files without an import path
                if (currFile.ImportPath == null || currFile.ImportPath.ID == null)
                {
                    logger.Info("Removing: {0} (no import path)", currFile.FullPath);
                    currFile.Delete();
                    cleaned++;
                    continue;
                }

                // Remove entries from the database that have their file removed
                if (currFile.IsRemoved)
                {
                    logger.Info("Removing: {0} (file is removed)", currFile.FullPath);
                    currFile.Delete();
                    cleaned++;
                }
            }

            logger.Info("Removed {0} file entries.", cleaned.ToString());
            if (MaintenanceProgress != null)
            {
                MaintenanceProgress("", 100);
            }

            // Remove Orphan albums
            cleaned = 0;
            List <DBAlbumInfo> albumObjectList = DBAlbumInfo.GetAll();

            foreach (DBAlbumInfo albumObject in albumObjectList)
            {
                if (albumObject.Album.Trim() == string.Empty)
                {
                    albumObject.Album = "Unknow Album";
                    albumObject.Commit();
                }
                List <DBTrackInfo> mvs = DBTrackInfo.GetEntriesByAlbum(albumObject);
                if (mvs.Count == 0)
                {
                    logger.Info("Removing: {0} (albuminfo orphan)", albumObject.Album);
                    albumObject.Delete();
                    cleaned++;
                }
            }
            logger.Info("Removed {0} Album orphan entries.", cleaned.ToString());
            if (MaintenanceProgress != null)
            {
                MaintenanceProgress("", 100);
            }

            // Remove Orphan artist
            cleaned = 0;
            List <DBArtistInfo> allArtistList = DBArtistInfo.GetAll();

            foreach (DBArtistInfo artist in allArtistList)
            {
                List <DBTrackInfo> mvs = DBTrackInfo.GetEntriesByArtist(artist);
                if (mvs.Count == 0)
                {
                    logger.Info("Removing: {0} (artistinfo orphan)", artist.Artist);
                    artist.Delete();
                    cleaned++;
                }
            }
            logger.Info("Removed {0} Artist orphan entries.", cleaned.ToString());
            if (MaintenanceProgress != null)
            {
                MaintenanceProgress("", 100);
            }
        }
        // Loops through all mvCentral in the system to verify them
        public static void VerifyMusicVideoInformation()
        {
            logger.Info("Updating MusicVideo Information...");

            float count              = 0;
            List <DBTrackInfo> mvs   = DBTrackInfo.GetAll();
            List <DBUser>      users = DBUser.GetAll();
            float total              = mvs.Count;

            int removed  = 0;
            int settings = 0;

            foreach (DBTrackInfo mv in mvs)
            {
                if (MaintenanceProgress != null)
                {
                    MaintenanceProgress("", (int)(count * 100 / total));
                }
                count++;

                // Skip uncommited files
                if (mv.ID == null)
                {
                    continue;
                }

                #region Remove MusicVideo without attached local media

                // Remove mvCentral with no files
                if (mv.LocalMedia.Count == 0)
                {
                    logger.Info("'{0}' was removed from the system because it had no local media.", mv.Track);
                    mv.Delete();
                    removed++;
                    continue;
                }

                #endregion

                #region Add missing user settings

                if (mv.UserSettings.Count == 0)
                {
                    logger.Info("'{0}' was missing UserMovingSettings, adding now.", mv.Track);
                    foreach (DBUser currUser in users)
                    {
                        DBUserMusicVideoSettings userSettings = new DBUserMusicVideoSettings();
                        userSettings.User = currUser;
                        userSettings.Commit();
                        mv.UserSettings.Add(userSettings);
                        userSettings.CommitNeeded = false;
                    }
//                    lock (mv)
                    {
                        mv.Commit();
                    }
                    settings++;
                }

                #endregion
            }

            logger.Info("Removed {0} MusicVideo entries.", removed.ToString());
            logger.Info("Updated {0} MusicVideo entries with default user setting.", settings.ToString());
            if (MaintenanceProgress != null)
            {
                MaintenanceProgress("", 100);
            }
        }