コード例 #1
0
ファイル: DBTrackInfo.cs プロジェクト: RoChess/mvcentral
        public override void Delete()
        {
            if (this.ID == null)
            {
                base.Delete();
                return;
            }

            DBAlbumInfo a1 = null;

            if (this.AlbumInfo.Count > 0)
            {
                a1 = this.AlbumInfo[0];
            }
            DBArtistInfo a3 = null;

            if (this.ArtistInfo.Count > 0)
            {
                a3 = this.ArtistInfo[0];
            }

            base.Delete();

            if (a1 != null)
            {
                List <DBTrackInfo> a7 = GetEntriesByAlbum(a1);
                if (a7 == null || a7.Count == 0)
                {
                    logger.Info("Removing Album '{0}' .", a1.Album);
                    a1.Delete();
                }
            }

            if (a3 != null)
            {
                List <DBTrackInfo> a7 = GetEntriesByArtist(a3);
                if (a7 == null || a7.Count == 0)
                {
                    logger.Info("Removing Artist '{0}' .", a3.Artist);
                    a3.Delete();
                }
            }
        }
コード例 #2
0
ファイル: DBTrackInfo.cs プロジェクト: RoChess/mvcentral
        /// <summary>
        /// Returns a list of DBTrackInfo objects that match the album
        /// </summary>
        /// <param name="mbid"></param>
        /// <returns></returns>
        public static List <DBTrackInfo> GetEntriesByAlbum(DBAlbumInfo 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.AlbumInfo.Count > 0)
                    {
                        if (mv == db2.AlbumInfo[0])
                        {
                            results.Add(db2);
                        }
                    }
                }
                return(results);
            }
        }
コード例 #3
0
        /// <summary>
        /// Based on the calculated signature retrive data from providers
        /// </summary>
        /// <param name="mvSignature"></param>
        /// <returns></returns>
        public List<DBTrackInfo> GetTrackDetail(MusicVideoSignature mvSignature)
        {
            List<DBSourceInfo> trackSources;
              lock (trackDetailSources) trackSources = new List<DBSourceInfo>(trackDetailSources);

              List<DBSourceInfo> artistSources;
              lock (artistDetailSources) artistSources = new List<DBSourceInfo>(artistDetailSources);

              // Try each datasource (ordered by their priority) to get results
              List<DBTrackInfo> results = new List<DBTrackInfo>();
              foreach (DBSourceInfo currSource in trackSources)
              {
            if (currSource.IsDisabled(DataType.TRACKDETAIL))
              continue;

            // if we have reached the minimum number of possible matches required, we are done
            if (results.Count >= mvCentralCore.Settings.MinimumMatches && mvCentralCore.Settings.MinimumMatches != 0)
            {
              logger.Debug("We have reached the minimum number of possible matches required, we are done.");
              break;
            }

            // search with the current provider
            List<DBTrackInfo> newResults = currSource.Provider.GetTrackDetail(mvSignature);

            // tag the results with the current source
            foreach (DBTrackInfo currMusicVideo in newResults)
            {
              currMusicVideo.PrimarySource = currSource;

              // ****************** Additional Artist Info Processing ******************
              // Check and update Artist details from additional providers
              DBArtistInfo artInfo = new DBArtistInfo();
              artInfo = currMusicVideo.ArtistInfo[0];

              foreach (DBSourceInfo artistExtraInfo in artistDetailSources)
              {
            if (artistExtraInfo != currSource)
            {
              logger.Debug("Searching for additional Artist infomation from Provider: " + artistExtraInfo.Provider.Name);
              artInfo = artistExtraInfo.Provider.GetArtistDetail(currMusicVideo).ArtistInfo[0];
            }
              }
              artInfo.DisallowBackgroundUpdate = true;
              currMusicVideo.ArtistInfo[0] = artInfo;

              // If album support disabled or no associated album then skip album processing
              if (mvCentralCore.Settings.DisableAlbumSupport || currMusicVideo.AlbumInfo.Count == 0)
            continue;

              // ****************** Additional Album Info Processing ******************
              // Check and update Album details from additional providers
              DBAlbumInfo albumInfo = new DBAlbumInfo();
              albumInfo = currMusicVideo.AlbumInfo[0];

              foreach (DBSourceInfo albumExtraInfo in albumDetailSources)
              {
            if (albumExtraInfo != currSource)
            {
              logger.Debug("Searching for additional Album infomation from Provider: " + albumExtraInfo.Provider.Name);
              albumInfo = albumExtraInfo.Provider.GetAlbumDetail(currMusicVideo).AlbumInfo[0];
            }
              }
              albumInfo.DisallowBackgroundUpdate = true;
              currMusicVideo.AlbumInfo[0] = albumInfo;
            }

            // add results to our total result list and log what we found
            results.AddRange(newResults);
              }
              return results;
        }
コード例 #4
0
        /// <summary>
        /// get the album details
        /// </summary>
        /// <param name="mv"></param>
        /// <returns></returns>
        public DBTrackInfo GetAlbumDetail(DBTrackInfo mv)
        {
            // ****************** Additional Album Info Processing ******************
              // Check and update Album details from additional providers
              DBAlbumInfo albumInfo = new DBAlbumInfo();
              albumInfo = mv.AlbumInfo[0];

              foreach (DBSourceInfo albumExtraInfo in albumDetailSources)
              {
            if (albumInfo.PrimarySource != albumExtraInfo.Provider)
            {
              albumInfo = albumExtraInfo.Provider.GetAlbumDetail(mv).AlbumInfo[0];
              albumInfo.PrimarySource = albumExtraInfo;
            }
              }
              mv.AlbumInfo[0] = albumInfo;

              return mv;
        }
コード例 #5
0
        /// <summary>
        /// parses and replaces variables from a filename based on the pattern supplied
        /// returning a list of possible file matches
        /// </summary>
        /// <param name="pattern"></param>
        /// <param name="mv"></param>
        /// <returns></returns>
        private List<string> getPossibleNamesFromPattern(string pattern, object mv)
        {
            Regex parser = new Regex("%(.*?)%", RegexOptions.IgnoreCase);
              // Artist Artwork
              if (mv.GetType() == typeof(DBArtistInfo))
              {
            mvArtistObject = (DBArtistInfo)mv;
            lock (lockObj)
            {
              List<string> filenames = new List<string>();
              foreach (string currPattern in pattern.Split('|'))
              {
            // replace db field patterns
            string filename = parser.Replace(currPattern, new MatchEvaluator(dbArtistNameParser)).Trim().ToLower();
            if (filename != null)
              filenames.Add(filename);
              }
              return filenames;
            }
              }
              // Album Artwork
              if (mv.GetType() == typeof(DBAlbumInfo))
              {
            mvAlbumObject = (DBAlbumInfo)mv;
            lock (lockObj)
            {
              List<string> filenames = new List<string>();
              foreach (string currPattern in pattern.Split('|'))
              {
            // replace db field patterns
            string filename = parser.Replace(currPattern, new MatchEvaluator(dbAlbumNameParser)).Trim().ToLower();
            if (filename != null)
              filenames.Add(filename);
              }
              return filenames;
            }
              }
              // This is track data
              if (mv.GetType() == typeof(DBTrackInfo))
              {
            // try to create our filename(s)
            this.mvTrackObject = (DBTrackInfo)mv;
            //this.mvTrackObject.LocalMedia[0].TrimmedFullPath;
            lock (lockObj)
            {
              List<string> filenames = new List<string>();
              foreach (string currPattern in pattern.Split('|'))
              {
            // replace db field patterns

            string filename = parser.Replace(currPattern, new MatchEvaluator(dbTrackNameParser)).Trim().ToLower();

            // replace %filename% pattern
            if (mvTrackObject.LocalMedia.Count > 0)
            {
              string videoFileName = Path.GetFileNameWithoutExtension(mvTrackObject.LocalMedia[0].File.Name);
              filename = filename.Replace("%filename%", videoFileName);
            }

            filenames.Add(filename);
              }
              return filenames;
            }
              }

              //should never get here
              return null;
        }
コード例 #6
0
        /// <summary>
        /// Get the Album Artwork using the old method
        /// </summary>
        /// <param name="mvAlbumObject"></param>
        /// <returns></returns>
        private bool getOldAlbumArt(DBAlbumInfo mvAlbumObject)
        {
            logger.Debug("In Method getOldAlbumArt(DBAlbumInfo mv)");
              bool found = false;

              string AlbumArtFolderPath = mvCentralCore.Settings.AlbumArtFolder;
              DirectoryInfo albumartFolder = new DirectoryInfo(AlbumArtFolderPath);

              string safeName = mvAlbumObject.Album.Replace(' ', '.').ToValidFilename();
              Regex oldtrackRegex = new Regex("^{?" + Regex.Escape(safeName) + "}? \\[-?\\d+\\]\\.(jpg|png)");

              foreach (FileInfo currFile in albumartFolder.GetFiles())
              {
            if (oldtrackRegex.IsMatch(currFile.Name))
            {
              found &= mvAlbumObject.AddArtFromFile(currFile.FullName);
            }
              }
              return found;
        }
コード例 #7
0
        public List<DBTrackInfo> GetTrackDetail(MusicVideoSignature mvSignature)
        {
            // Switch off album support
              if (mvCentralCore.Settings.DisableAlbumSupport)
            mvSignature.Album = null;

              List<DBTrackInfo> results = new List<DBTrackInfo>();
              if (mvSignature == null)
            return results;

              logger.Debug("In Method: GetTrackDetail(MusicVideoSignature mvSignature)");
              logger.Debug("*** Artist: " + mvSignature.Artist + " - " + mvSignature.ArtistMdId);
              logger.Debug("*** Album: " + mvSignature.Album + " - " + mvSignature.AlbumMdId);
              logger.Debug("*** Other: " + mvSignature.Title + " - " + mvSignature.MdId);
              lock (lockObj)
              {
            DBTrackInfo mvTrackData = null;
            // Artist/Album handling, if the track and artist dont match and the track contains the artist name this would indicate the that track is in the format /<artist>/<album>/<atrist - track>.<ext>
            // This will throw out the parseing so remove the artist name from the track.
            // This is not the best fix, need to add code so I know whch expression produced the result or better still have a ignore folder structure when pasring option.
            if (mvSignature.Track != null && mvSignature.Artist != null)
            {
              if ((mvSignature.Track.ToLower().Trim() != mvSignature.Artist.ToLower().Trim()) && mvSignature.Track.ToLower().Contains(mvSignature.Artist.ToLower().Trim()))
            mvTrackData = getMusicVideoTrack(mvSignature.Artist, Regex.Replace(mvSignature.Track, mvSignature.Artist, string.Empty, RegexOptions.IgnoreCase));
              else
            mvTrackData = getMusicVideoTrack(mvSignature.Artist, mvSignature.Track);
            }
            else
              mvTrackData = getMusicVideoTrack(mvSignature.Artist, mvSignature.Track);

            if (mvTrackData != null)
            {
              if (mvTrackData.ArtistInfo.Count == 0)
              {
            DBArtistInfo artistInfo = new DBArtistInfo();
            artistInfo.Artist = mvSignature.Artist;
            mvTrackData.ArtistInfo.Add(artistInfo);
              }

              if (mvSignature.Album != null && mvSignature.Artist != null)
              {
            if (!mvCentralCore.Settings.UseMDAlbum)
            {
              DBAlbumInfo albumInfo = new DBAlbumInfo();
              albumInfo.Album = mvSignature.Album;
              setMusicVideoAlbum(ref albumInfo, mvSignature.Artist, mvSignature.Album, null);
              mvTrackData.AlbumInfo.Clear();
              mvTrackData.AlbumInfo.Add(albumInfo);
            }
              }
              else if (mvTrackData.AlbumInfo.Count > 0 && mvCentralCore.Settings.SetAlbumFromTrackData)
              {
            logger.Debug("There are {0} Albums found for Artist: {1} / {2}", mvTrackData.AlbumInfo.Count.ToString(), mvSignature.Artist, mvSignature.Title);
            DBAlbumInfo albumInfo = new DBAlbumInfo();
            albumInfo.Album = mvTrackData.AlbumInfo[0].Album;
            setMusicVideoAlbum(ref albumInfo, mvSignature.Artist, mvTrackData.AlbumInfo[0].Album, null);
            mvTrackData.AlbumInfo.Clear();
            mvTrackData.ArtistInfo[0].Artist = mvSignature.Artist;
            mvTrackData.AlbumInfo.Add(albumInfo);
              }
              else
            mvTrackData.AlbumInfo.Clear();

              results.Add(mvTrackData);
            }
              }
              return results;
        }
コード例 #8
0
        // 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);
            }
        }
コード例 #9
0
 /// <summary>
 /// Set the Album Information - override existing data
 /// </summary>
 /// <param name="mv"></param>
 /// <param name="albumInfo"></param>
 private void SetMusicVideoAlbum(ref DBAlbumInfo mv, AlbumInfo albumInfo)
 {
     mv.bioSummary = getBioSummary(albumInfo.Review, 50);
       mv.bioContent = albumInfo.Review;
       mv.YearReleased = albumInfo.Year.ToString();
       mv.Rating = albumInfo.Rating;
 }
コード例 #10
0
 private void setMusicVideoAlbum(ref DBAlbumInfo mv, XmlNode node)
 {
 }
コード例 #11
0
 /// <summary>
 /// Set the Album Information
 /// </summary>
 /// <param name="mv"></param>
 /// <param name="albumInfo"></param>
 private void setMusicVideoAlbum(ref DBAlbumInfo mv, MusicAlbumInfo albumInfo)
 {
 }
コード例 #12
0
    /// <summary>
    /// Get the Album Art
    /// </summary>
    /// <param name="mv"></param>
    /// <returns></returns>
    public bool GetAlbumArt(DBAlbumInfo mv)
    {
      if (string.IsNullOrEmpty(mv.MdID.Trim()))
        return false;
      logger.Debug("In Method: GetAlbumArt(DBAlbumInfo mv)");

      // Get the images
      // If we have a MBID for this Artist use this to retrive the image otherwise fall back to keyword search
      var html = getJSON(SearchAlbumImage, APIKey, mv.MdID.Trim());

      // If we reveived nothing back, bail out
      if (string.IsNullOrEmpty(html))
        return false;

      int albumartAdded = 0;
      var URLList = new List<string>();
      URLList = ExtractURL("albumcover", html);
      if (URLList != null)
      {
        foreach (string _url in URLList)
        {
          var _fileURL = _url.Substring(checked(_url.IndexOf("|") + 1));
          if (mv.AddArtFromURL(_fileURL) == ImageLoadResults.SUCCESS)
            albumartAdded++;
        }
      }

      return (albumartAdded > 0);
    }
コード例 #13
0
        /// <summary>
        /// Grab the album data and process
        /// </summary>
        /// <param name="mv"></param>
        /// <param name="artist"></param>
        /// <param name="album"></param>
        /// <param name="mbid"></param>
        private void setMusicVideoAlbum(ref DBAlbumInfo mv, string artistName, string albumName, string mbid)
        {
            if (string.IsNullOrEmpty(artistName) && string.IsNullOrEmpty(albumName))
            return;
              logger.Debug(string.Format("In Method: setMusicVideoAlbum(ref DBAlbumInfo mv, Atrist: {0}, Album: {1}, MBID: {2})", artistName, albumName, mbid));

              MusicDatabase m_db = null;
              try
              {
            m_db = MusicDatabase.Instance;
              }
              catch (Exception e)
              {
            logger.Error("setMusicVideoAlbum: Music database init failed " + e.ToString());
            return;
              }

              var albumInfo = new MediaPortal.Music.Database.AlbumInfo();
              if (!m_db.GetAlbumInfo(albumName, artistName, ref albumInfo))
            return;

              // Album name
              if (albumInfo.Album.ToLower() == albumInfo.Album)
              {
            mv.Album = System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase(albumInfo.Album);
              }
              else
              {
            mv.Album = albumInfo.Album;
              }
              // MBID
              // mv.MdID
              // Image URL
              if (!string.IsNullOrEmpty(albumInfo.Image) && !mv.ArtUrls.Contains(albumInfo.Image))
            mv.ArtUrls.Add(albumInfo.Image);
              // Tags: Actors, Directors and Writers
              // mv.Tag.Add(tagstr);
              // WIKI
              mv.bioSummary = albumInfo.Review;
              mv.bioContent = albumInfo.Review;
              // Tag
              char[] delimiters = new char[] { ',' };
              string[] tags = albumInfo.Styles.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
              foreach (string tag in tags)
              {
            mv.Tag.Add(tag.Trim());
              }
              // Additional
              if (albumInfo.Year > 0)
              {
            mv.YearReleased = Convert.ToString(albumInfo.Year);
              }
        }
コード例 #14
0
        private DBTrackInfo getMusicVideoTrack(string artist, string track)
        {
            if (track == null)
            return null;

              logger.Debug("In Method: getMusicVideoTrack(Artist: " + artist + " Track: " + track + ")");

              MusicDatabase m_db = null;
              try
              {
            m_db = MusicDatabase.Instance;
              }
              catch (Exception e)
              {
            logger.Error("getMusicVideoTrack: Music database init failed " + e.ToString());
            return null;
              }

              var trackInfo = new MediaPortal.Music.Database.Song();
              if (!m_db.GetSongByMusicTagInfo(artist, string.Empty, track, false, ref trackInfo))
            return null;

              DBTrackInfo mv = new DBTrackInfo();
              mv.Track = trackInfo.Title;
              // mv.MdID = value;
              // Artist
              var _artist = string.Empty ;
              if (!string.IsNullOrEmpty(trackInfo.AlbumArtist))
              {
            _artist = trackInfo.AlbumArtist;
              } else if (!string.IsNullOrEmpty(trackInfo.Artist))
              {
            _artist = trackInfo.Artist;
              }
              if (!string.IsNullOrEmpty(_artist))
              {
            DBArtistInfo d4 = new DBArtistInfo();
            setMusicVideoArtist(ref d4, _artist, null);
            mv.ArtistInfo.Add(d4);
              }
              // Album
              if (!string.IsNullOrEmpty(trackInfo.Album))
              {
            DBAlbumInfo d4 = new DBAlbumInfo();
            setMusicVideoAlbum(ref d4, _artist, trackInfo.Album, null);
            // Have we actually got a valid album?
            if (d4.Album.Trim() != string.Empty)
              mv.AlbumInfo.Add(d4);
              }
              // Tag
              char[] delimiters = new char[] { ',' };
              string[] tags = trackInfo.Genre.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
              foreach (string tag in tags)
              {
            mv.Tag.Add(tag.Trim());
              }
              // mv.bioSummary = mvCentralUtils.StripHTML(cdataSection.Value);
              // mv.bioContent = mvCentralUtils.StripHTML(cdataSection.Value);

              if (mv.ArtistInfo.Count == 0)
            return null;

              return mv;
        }
コード例 #15
0
        /// <summary>
        /// Get the Album Artwork from Mediaportal folder
        /// </summary>
        /// <param name="mvArtistObject"></param>
        /// <returns></returns>
        private bool getMPAlbumArt(DBAlbumInfo mvAlbumObject)
        {
            logger.Debug("In Method: getMPAlbumArt(DBAlbumInfo mvAlbumObject)");
              bool found = false;

              string artist = string.Empty;
              string album = mvAlbumObject.Album;

              List<DBTrackInfo> a1 = DBTrackInfo.GetEntriesByAlbum(mvAlbumObject);
              if (a1.Count > 0)
              {
            artist = a1[0].ArtistInfo[0].Artist;
              }

              string thumbFolder = Thumbs.MusicAlbum ;
              string cleanTitle = string.Format("{0}-{1}", MediaPortal.Util.Utils.MakeFileName(artist), MediaPortal.Util.Utils.MakeFileName(album));
              string filename = thumbFolder + @"\" + cleanTitle + "L.jpg";

              if (File.Exists(filename))
              {
            found &= mvAlbumObject.AddArtFromFile(filename);
              }
              logger.Debug("In Method: getMPAlbumArt(DBAlbumInfo mvAlbumObject) filename: " + filename + " - " + found);
              return found;
        }
コード例 #16
0
ファイル: ConfigForm.cs プロジェクト: andrewjswan/mvcentral
        /// <summary>
        /// Add Track to a user selected album
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createAlbumToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DBBasicInfo selectedTrack = null;
              switch (tcMusicVideo.SelectedTab.Name)
              {
            case "tpTrack":
              selectedTrack = CurrentTrack;
              break;
            default:
              return;
              }

              if (mvLibraryTreeView.SelectedNode.Level == 2)
              {
            MessageBox.Show("Please move track to Artist level before creating an album", "Unable to Create Album", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            return;
              }

              var activeTrack = DBTrackInfo.Get((int)selectedTrack.ID);
              var activeAtrist = DBArtistInfo.Get(CurrentTrack);

              var createAlbum = new CreateAlbumForTrack(activeTrack);
              createAlbum.ShowDialog();

              if (!createAlbum.exitStatus) return;
              var albumCheck = DBAlbumInfo.Get(createAlbum.Album);

              if (albumCheck == null)
              {
            // No existing album - create, lookup details and add to track
            var sourceProviders = mvCentralCore.DataProviderManager.AlbumDetailSources.ToList();

            var albumToAdd = new DBAlbumInfo
              {
            Album = createAlbum.Album,
            MdID = createAlbum.AlbumMBID,
            PrimarySource = sourceProviders[0]
              };
            albumToAdd.Commit();
            activeTrack.AlbumInfo.Add(albumToAdd);
            activeTrack.Commit();
            albumToAdd.PrimarySource = sourceProviders[0];
            albumToAdd.PrimarySource.Provider.GetAlbumDetails((DBBasicInfo) albumToAdd, createAlbum.Album,
                                                          createAlbum.AlbumMBID);
            albumToAdd.Commit();
              }
              else
              {
            // Album already exists - add to track
            activeTrack.AlbumInfo.Add(albumCheck);
            activeTrack.Commit();
              }
              // Reload and display the library
              ReloadList();

              // Select and expand the artist
              foreach (TreeNode tn in mvLibraryTreeView.Nodes.Cast<TreeNode>().Where(tn => tn.Text == activeAtrist.Artist))
              {
            mvLibraryTreeView.SelectedNode = tn;
            tn.Expand();
              }
              mvLibraryTreeView.Refresh();
              // Do we already have this album....
        }
コード例 #17
0
ファイル: ConfigForm.cs プロジェクト: andrewjswan/mvcentral
        private void manualAssignButton_Click(object sender, EventArgs e)
        {
            unapprovedGrid.EndEdit();

              foreach (DataGridViewRow currRow in unapprovedGrid.SelectedRows)
              {
            MusicVideoMatch selectedMatch = (MusicVideoMatch)currRow.DataBoundItem;

            DBLocalMedia mediaToPlay = selectedMatch.LocalMedia[0];

            if (mediaToPlay.State != MediaState.Online) mediaToPlay.Mount();
            while (mediaToPlay.State != MediaState.Online) { Thread.Sleep(1000); };

            ManualAssignPopup popup = new ManualAssignPopup(selectedMatch);

            popup.ShowDialog(this);

            if (popup.DialogResult == DialogResult.OK)
            {

              // create a musicvideo with the user supplied information
              DBTrackInfo mv = new DBTrackInfo();
              mv.Track = popup.Track;
              if (popup.Album.Trim().Length > 0)
              {
            DBAlbumInfo db1 = DBAlbumInfo.Get(popup.Album);
            if (db1 == null) db1 = new DBAlbumInfo();
            db1.Album = popup.Album;
            mv.AlbumInfo.Add(db1);
              }
              DBArtistInfo db2 = DBArtistInfo.Get(popup.Artist);
              if (db2 == null)
              {
            db2 = new DBArtistInfo();
            db2.Artist = popup.Artist;
              }
              mv.ArtistInfo.Add(db2);

              foreach (DBSourceInfo r1 in mvCentralCore.DataProviderManager.AllSources)
              {
            if (r1.Provider is ManualProvider)
            {
              mv.PrimarySource = r1;
              mv.ArtistInfo[0].PrimarySource = r1;
              if (mv.AlbumInfo != null && mv.AlbumInfo.Count > 0) mv.AlbumInfo[0].PrimarySource = r1;
            }
              }

              // We have DVD and set to split DVD into chapters
              // This is a great idea that falls flat for two reasons..
              //  1. There is not decent source of DVD/Track info
              //  2. Even if the tracks were split out and named I have yet to find a method of playing a single track from a DVD
              // For now will skip this
              bool dothisCodeBlock = false;
              // Split the DVD into chapters
              if (selectedMatch.LocalMedia[0].IsDVD && cbSplitDVD.Checked && dothisCodeBlock)
              {

            string videoPath = mediaToPlay.GetVideoPath();
            if (videoPath == null) videoPath = selectedMatch.LongLocalMediaString;
            string pathlower = Path.GetDirectoryName(videoPath).ToLower();
            pathlower = pathlower.Replace("\\video_ts", "");
            pathlower = pathlower.Replace("\\adv_obj", "");
            pathlower = pathlower.Replace("\\bdmv", "");
            if (pathlower.Length < 3) pathlower = pathlower + "\\";
            ChapterExtractor ex =
            Directory.Exists(Path.Combine(pathlower, "VIDEO_TS")) ?
            new DvdExtractor() as ChapterExtractor :
            Directory.Exists(Path.Combine(pathlower, "ADV_OBJ")) ?
            new HddvdExtractor() as ChapterExtractor :
            Directory.Exists(Path.Combine(Path.Combine(pathlower, "BDMV"), "PLAYLIST")) ?
            new BlurayExtractor() as ChapterExtractor :
            null;

            if (ex != null)
            {
              List<ChapterInfo> rp = ex.GetStreams(pathlower, 1);

              if (mediaToPlay.IsMounted)
              {
                mediaToPlay.UnMount();
                while (mediaToPlay.IsMounted) { Thread.Sleep(1000); };
              }
              foreach (ChapterInfo ci in rp)
              {
                foreach (ChapterEntry c1 in ci.Chapters)
                {
                  //skip menus/small crap
                  //                                    if (c1.Time.TotalSeconds < 20) continue;
                  DBTrackInfo db1 = new DBTrackInfo();
                  db1.Copy(mv);
                  db1.TitleID = ci.TitleID;
                  db1.Track = "Chapter " + ci.TitleID.ToString("##") + " - " + c1.chId.ToString("##");
                  db1.Chapter = "Chapter " + c1.chId.ToString("##");
                  db1.ChapterID = c1.chId;
                  db1.PlayTime = c1.Time.ToString();
                  db1.OffsetTime = c1.OffsetTime.ToString();
                  db1.ArtistInfo.Add(mv.ArtistInfo[0]);
                  if (mv.AlbumInfo != null && mv.AlbumInfo.Count > 0) db1.AlbumInfo.Add(mv.AlbumInfo[0]);
                  db1.LocalMedia.Add(selectedMatch.LocalMedia[0]);
                  db1.Commit();
                }
              }
              selectedMatch.LocalMedia[0].UpdateMediaInfo();
              selectedMatch.LocalMedia[0].Commit();
              mvStatusChangedListener(selectedMatch, MusicVideoImporterAction.COMMITED);
              //                        ReloadList();
              return;
            }
              }

              // update the match
              PossibleMatch selectedMV = new PossibleMatch();
              selectedMV.MusicVideo = mv;

              MatchResult result = new MatchResult();
              result.TitleScore = 0;
              result.YearScore = 0;
              result.MdMatch = true;

              selectedMV.Result = result;

              selectedMatch.PossibleMatches.Add(selectedMV);
              selectedMatch.Selected = selectedMV;

              ThreadStart actions = delegate
              {
            // Manually Assign Movie
            mvCentralCore.Importer.ManualAssign(selectedMatch);
              };

              Thread thread = new Thread(actions);
              thread.Name = "ManualUpdateThread";
              thread.Start();
            }
              }
        }
コード例 #18
0
        /// <summary>
        /// Get Album Artwork already on disk
        /// </summary>
        /// <param name="albumInfo"></param>
        /// <returns></returns>
        public bool GetAlbumArt(DBAlbumInfo albumInfo)
        {
            logger.Debug("In Method GetAlbumArt(DBAlbumInfo mv)");

              if (albumInfo == null)
            return false;

              // if we already have a artist move on for now
              if (albumInfo.ArtFullPath.Trim().Length > 0)
            return false;

              bool found = false;

              if (mvCentralCore.Settings.SearchCustomFolderForAlbumArt)
              {
            found = getAlbumArtFromCustomAlbumArtFolder(albumInfo);
            logger.Debug("Sucessfully added fanart from custom folder: {0}", albumInfo.ArtFullPath);
              }

              if (!found)
            found = getAlbumArtFromAlbumArtFolder(albumInfo);

              if (!found)
            found = getOldAlbumArt(albumInfo);

              return found;
        }
コード例 #19
0
        /// <summary>
        /// Get the Album Art
        /// </summary>
        /// <param name="mv"></param>
        /// <returns></returns>
        public bool GetAlbumArt(DBAlbumInfo mvAlbumObject)
        {
            Logger.Debug("In Method : GetAlbumArt(DBAlbumInfo mv)");

              if (mvAlbumObject == null)
            return false;

              List<string> albumImageList = mvAlbumObject.ArtUrls;
              // Reload existing Artwork - Why springs to mind??
              if (albumImageList.Count > 0)
              {
            // grab album art loading settings
            int maxAlbumArt = mvCentralCore.Settings.MaxAlbumArts;

            int albumartAdded = 0;
            int count = 0;
            foreach (string albumImage in albumImageList)
            {
              if (mvAlbumObject.AlternateArts.Count >= maxAlbumArt)
            break;

              if (mvAlbumObject.AddArtFromURL(albumImage) == ImageLoadResults.SUCCESS)
            albumartAdded++;

              count++;
            }
            // We added some artwork so commit
            if (count > 0)
              mvAlbumObject.Commit();
              }

              // Now add any new art from this provider
              string strAlbumHTML;
              DBArtistInfo artist = null;
              List<DBTrackInfo> tracksOnAlbum = DBTrackInfo.GetEntriesByAlbum(mvAlbumObject);

              if (tracksOnAlbum.Count > 0)
              {
            artist = DBArtistInfo.Get(tracksOnAlbum[0]);

            if (GetAlbumHTML(artist.Artist, mvAlbumObject.Album, out strAlbumHTML))
            {
              var albumInfo = new MusicAlbumInfo();

              if (albumInfo.Parse(strAlbumHTML))
              {
            ImageLoadResults imageLoadResults = mvAlbumObject.AddArtFromURL(albumInfo.ImageURL);

            if (imageLoadResults == ImageLoadResults.SUCCESS || imageLoadResults == ImageLoadResults.SUCCESS_REDUCED_SIZE)
              mvAlbumObject.Commit();
              }
            }
              }
              // We always return sucess...
              return true;
        }
コード例 #20
0
        /// <summary>
        /// get the Album Artwork from the custom album artwork folder 
        /// </summary>
        /// <param name="mvAlbumObject"></param>
        /// <returns></returns>
        private bool getAlbumArtFromCustomAlbumArtFolder(DBAlbumInfo mvAlbumObject)
        {
            logger.Debug("In Method getAlbumArtFromCustomAlbumArtFolder(DBAlbumInfo mv)");
              if (mvAlbumObject == null)
            return false;

              // grab a list of possible filenames for the albumart based on the user pattern
              string pattern = mvCentralCore.Settings.AlbumArtworkFilenamePattern;
              List<string> filenames = getPossibleNamesFromPattern(pattern, mvAlbumObject);

              // check the albumart folder for the user patterned albumart
              string albumArtFolderPath = mvCentralCore.Settings.CustomAlbumArtFolder;
              FileInfo newAlbumArt = getFirstFileFromFolder(albumArtFolderPath, filenames);
              if (newAlbumArt != null && newAlbumArt.Exists)
              {
            mvAlbumObject.ArtFullPath = newAlbumArt.FullName;
            mvAlbumObject.AlternateArts.Add(newAlbumArt.FullName);
            mvAlbumObject.GenerateThumbnail();
            logger.Info("Loaded Albumimage from " + newAlbumArt.FullName);
            return true;
              }
              return false;
        }
コード例 #21
0
 public bool GetAlbumArt(DBAlbumInfo mv)
 {
     return false;
 }
コード例 #22
0
        /// <summary>
        /// Get Album Artwork already on disk
        /// </summary>
        /// <param name="albumInfo"></param>
        /// <returns></returns>
        public bool GetAlbumArt(DBAlbumInfo albumInfo)
        {
            if (albumInfo == null)
            return false;
              logger.Debug("In Method: GetAlbumArt(DBAlbumInfo mv)");

              // if we already have a artist move on for now
              if (albumInfo.ArtFullPath.Trim().Length > 0 && File.Exists(albumInfo.ArtFullPath.Trim()))
            return false;

              return getMPAlbumArt(albumInfo);
        }