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(); }
private void btnGrabFrame_Click(object sender, EventArgs e) { string artFolder = mvCentralCore.Settings.TrackArtFolder; string safeName = mvs.Track.Replace(' ', '.').ToValidFilename(); string filename1 = Path.GetTempPath() + "\\{" + safeName + "} [" + new Random().Next(0xFFFFFFF).ToString() + "].jpg"; snapImage(filename1); bool i1; i1 = mvs.AddArtFromFile(filename1); File.Delete(filename1); if (i1 == true) { mvs.Commit(); } }
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(); } } }