public void LoadDisk(Title title, Disk disk) { _currentDisk = disk; _currentTitle = title; if (disk == null) diskSource.DataSource = typeof(Disk); else diskSource.DataSource = _currentDisk; }
public static Title ConvertOMLSDKTitleToTitle(OMLSDKTitle omlsdktitle) { Title _title = new Title(); if (omlsdktitle != null) { _title.NameTrimmed = CopyString(omlsdktitle.Name); _title.OriginalNameTrimmed = CopyString(omlsdktitle.OriginalName); _title.SortNameTrimmed = CopyString(omlsdktitle.SortName); _title.Synopsis = CopyString(omlsdktitle.Synopsis); _title.ProductionYear = omlsdktitle.ProductionYear; _title.ReleaseDate = omlsdktitle.ReleaseDate; _title.DateAdded = omlsdktitle.DateAdded; _title.Runtime = omlsdktitle.Runtime; _title.StudioTrimmed = CopyString(omlsdktitle.Studio); _title.UPCTrimmed = CopyString(omlsdktitle.UPC); _title.WatchedCount = omlsdktitle.WatchedCount; _title.UserStarRating = omlsdktitle.UserStarRating; _title.EpisodeNumber = omlsdktitle.EpisodeNumber; _title.SeasonNumber = omlsdktitle.SeasonNumber; _title.AspectRatioTrimmed = CopyString(omlsdktitle.AspectRatio); _title.VideoDetails = CopyString(omlsdktitle.VideoDetails); _title.VideoResolutionTrimmed = CopyString(omlsdktitle.VideoResolution); _title.VideoStandardTrimmed = CopyString(omlsdktitle.VideoStandard); //_title.VideoFormat = (VideoFormat)Enum.Parse(typeof(VideoFormat), omlsdktitle.VideoFormat.ToString()); _title.FrontCoverPath = CopyString(omlsdktitle.FrontCoverPath); _title.BackCoverPath = CopyString(omlsdktitle.BackCoverPath); _title.CountryOfOriginTrimmed = CopyString(omlsdktitle.CountryOfOrigin); _title.MetadataSourceIDTrimmed = CopyString(omlsdktitle.MetadataSourceID); _title.MetadataSourceNameTrimmed = CopyString(omlsdktitle.MetadataSourceName); _title.ImporterSourceTrimmed = CopyString(omlsdktitle.ImporterSource); _title.OfficialWebsiteURLTrimmed = CopyString(omlsdktitle.OfficialWebsiteURL); _title.ParentalRatingTrimmed = CopyString(omlsdktitle.ParentalRating); _title.ParentalRatingReasonTrimmed = CopyString(omlsdktitle.ParentalRatingReason); #region Disks foreach (OMLSDKDisk omlsdkdisk in omlsdktitle.Disks) { Disk disk = new Disk(); disk.Name = omlsdkdisk.Name; disk.Path = omlsdkdisk.Path; disk.Format = (VideoFormat)Enum.Parse(typeof(VideoFormat), omlsdkdisk.Format.ToString()); disk.ExtraOptions = omlsdkdisk.ExtraOptions; _title.AddDisk(disk); } #endregion #region Extra Features _title.ExtraFeatures = omlsdktitle.ExtraFeatures; #endregion #region Trailers foreach (string Trailer in omlsdktitle.Trailers) { _title.AddTrailer(Trailer); } #endregion #region Genres if (omlsdktitle.Genres != null) { foreach (string genre in omlsdktitle.Genres) { _title.AddGenre(genre); } } #endregion #region Actring Roles if (omlsdktitle.ActingRoles != null) { foreach (OMLSDKRole role in omlsdktitle.ActingRoles) { _title.AddActingRole(role.PersonName, role.RoleName); } } #endregion #region Non Acting Roles if (omlsdktitle.NonActingRoles != null) { foreach (OMLSDKRole role in omlsdktitle.NonActingRoles) { _title.AddNonActingRole(role.PersonName, role.RoleName); } } #endregion #region Directors if (omlsdktitle.Directors != null) { foreach (OMLSDKPerson person in omlsdktitle.Directors) { _title.AddDirector(ConvertOMLSDKPersonToPerson(person)); } } #endregion #region Writers if (omlsdktitle.Writers != null) { foreach (OMLSDKPerson person in omlsdktitle.Writers) { _title.AddWriter(ConvertOMLSDKPersonToPerson(person)); } } #endregion #region Producers if (omlsdktitle.Producers != null) { foreach (OMLSDKPerson person in omlsdktitle.Producers) { _title.AddProducer(ConvertOMLSDKPersonToPerson(person)); } } #endregion #region Tags if (omlsdktitle.Tags != null) { foreach (string tag in omlsdktitle.Tags) { _title.AddTag(tag); } } #endregion #region Audio Tracks if (omlsdktitle.AudioTracks != null) { foreach (string track in omlsdktitle.AudioTracks) { _title.AddAudioTrack(track); } } #endregion #region Subtitles if (omlsdktitle.Subtitles != null) { foreach (string subtitles in omlsdktitle.Subtitles) { _title.AddSubtitle(subtitles); } } #endregion #region Fanart Paths if (omlsdktitle.FanArtPaths != null) { foreach (string path in omlsdktitle.FanArtPaths) { _title.AddFanArtImage(path); } } #endregion } return _title; }
public string deleteDisk(Disk d) { string status = string.Empty; if (File.Exists(d.Path)) _reallydeleteFile(d.Path, out status); if (Directory.Exists(d.Path)) _reallydeleteFolder(d.Path, out status); return status; }
void TranscodeFile(string filename) { Disk disk = new Disk("Test", filename, VideoFormat.MKV); MediaSource source = new MediaSource(disk); AddTextString("Starting transcode job on " + source.Disk); var host = TranscodingNotifyingService.NewTranscodingServiceProxy(); host.Channel.Transcode(source, Environment.UserName); AddTextString(""); }
public List<Title> CreateTitlesFromPathArray(int? parentid, string[] path, string Tag) { // Create a list of all newly added titles List<Title> NewTitles = new List<Title>(); bool titleCreated = false; Title folderTitle; foreach (string file in path) { try { if (Directory.Exists(file)) { // Folder passed in. This is where St Sana kicks in Servant stsana = new Servant(); stsana.Log += new Servant.SSEventHandler(StSana_Log); stsana.BasePaths.Add(file); stsana.Scan(); int? a_parent; if (OMLEngine.Settings.OMLSettings.StSanaCreateTLFolder) { titleCreated = false; folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(parentid, Path.GetFileName(file), TitleTypes.Collection, null, out titleCreated); a_parent = folderTitle.Id; if (titleCreated) NewTitles.Add(folderTitle); } else { a_parent = parentid; } if (stsana.Entities != null) { foreach (Entity e in stsana.Entities) { int? e_parent = a_parent; if (e.Name != file) { switch (e.EntityType) { case Serf.EntityType.COLLECTION: case Serf.EntityType.MOVIE: if ((e.Series.Count() > 1) || (OMLEngine.Settings.OMLSettings.StSanaAlwaysCreateMovieFolder)) { titleCreated = false; folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(a_parent, e.Name, TitleTypes.Collection, null, out titleCreated); e_parent = folderTitle.Id; if (titleCreated) NewTitles.Add(folderTitle); } else { e_parent = a_parent; } break; case Serf.EntityType.TV_SHOW: titleCreated = false; folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(a_parent, e.Name, TitleTypes.TVShow, null, out titleCreated); e_parent = folderTitle.Id; if (titleCreated) NewTitles.Add(folderTitle); break; } } foreach (Series s in e.Series) { int? s_parent = e_parent; // if the s.name and e.name are the same, its a movie, to be sure though lets check s.number, it should be // -1 for non tv shows. if (s.Name.ToUpperInvariant().CompareTo(e.Name.ToUpperInvariant()) != 0 || s.Number > -1) { //s_parent = CreateFolderNonDuplicate(e_parent, s.Name, TitleTypes.Collection, false); if (s.Name != e.Name) { switch (e.EntityType) { case Serf.EntityType.COLLECTION: case Serf.EntityType.MOVIE: if ((e_parent == a_parent) || (OMLEngine.Settings.OMLSettings.StSanaAlwaysCreateMovieFolder)) { titleCreated = false; folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(e_parent, s.Name, TitleTypes.Collection, null, out titleCreated); s_parent = folderTitle.Id; if (titleCreated) NewTitles.Add(folderTitle); } else { s_parent = e_parent; } break; case Serf.EntityType.TV_SHOW: titleCreated = false; folderTitle = TitleCollectionManager.CreateFolderNonDuplicate(e_parent, s.Name, TitleTypes.Season, (short)s.Number, out titleCreated); s_parent = folderTitle.Id; if (titleCreated) NewTitles.Add(folderTitle); break; } } else { s_parent = e_parent; } } foreach (Video v in s.Videos) { StSana_Log("Processing " + v.Name); //int v_parent = CreateFolder(s_parent, Path.GetFileNameWithoutExtension(v.Name), TitleTypes.Collection, false); List<Disk> disks = new List<Disk>(); if ((e.EntityType == Serf.EntityType.COLLECTION) || (e.EntityType == Serf.EntityType.MOVIE)) { // Collection or movie mode. Create one title per folder with multiple disks foreach (string f in v.Files) { if (!TitleCollectionManager.ContainsDisks(OMLEngine.FileSystem.NetworkScanner.FixPath(f))) { Disk disk = new Disk(); disk.Path = f; disk.Format = disk.GetFormatFromPath(f); // (VideoFormat)Enum.Parse(typeof(VideoFormat), fileExtension.ToUpperInvariant()); disk.Name = string.Format("Disk {0}", 0); if (disk.Format != VideoFormat.UNKNOWN) { disks.Add(disk); } } } if (disks.Count != 0) { Title newTitle = TitleCollectionManager.CreateTitle(s_parent, Path.GetFileNameWithoutExtension(v.Name), TitleTypes.Unknown, Tag, disks.ToArray()); CheckDiskPathForImages(newTitle, disks[0]); NewTitles.Add(newTitle); TitleCollectionManager.SaveTitleUpdates(); } } else { // TV mode. Create one title per file, each with single disks foreach (string f in v.Files) { if (!TitleCollectionManager.ContainsDisks(OMLEngine.FileSystem.NetworkScanner.FixPath(f))) { Disk disk = new Disk(); disk.Path = f; disk.Format = disk.GetFormatFromPath(f); //(VideoFormat)Enum.Parse(typeof(VideoFormat), fileExtension.ToUpperInvariant()); disk.Name = string.Format("Disk {0}", 0); if (disk.Format != VideoFormat.UNKNOWN) { disks.Add(disk); } } if (disks.Count != 0) { short episodeno = 0; if (v.EpisodeNumbers.Count > 0) episodeno = (short)v.EpisodeNumbers[0]; Title newTitle = TitleCollectionManager.CreateTitle(s_parent, Path.GetFileNameWithoutExtension(f), TitleTypes.Episode, Tag, (short)s.Number, episodeno, disks.ToArray()); CheckDiskPathForImages(newTitle, disks[0]); NewTitles.Add(newTitle); TitleCollectionManager.SaveTitleUpdates(); } } } } } } } } if (File.Exists(file)) { StSana_Log("Processing " + file); string extension = Path.GetExtension(file).ToUpper().Replace(".", ""); extension = extension.Replace("-", ""); Disk disk = new Disk(); disk.Path = file; disk.Format = disk.GetFormatFromPath(file); // (VideoFormat)Enum.Parse(typeof(VideoFormat), extension.ToUpperInvariant()); disk.Name = string.Format("Disk {0}", 0); if (disk.Format != VideoFormat.UNKNOWN) { Title newTitle = TitleCollectionManager.CreateTitle(parentid, Path.GetFileNameWithoutExtension(file), TitleTypes.Unknown, Tag, new Disk[1] { disk }); CheckDiskPathForImages(newTitle, disk); NewTitles.Add(newTitle); TitleCollectionManager.SaveTitleUpdates(); } } } catch (Exception ex) { Utilities.DebugLine("[OMLEngine] CreateTitlesFromPathArray exception" + ex.Message); } } return NewTitles; }
private void CheckDiskPathForImages(Title title, Disk disk) { if ((disk == null) || (string.IsNullOrEmpty(disk.Path))) return; string diskFolder = disk.GetDiskFolder; string diskPathWithExtension = null; string diskPathWithoutExtension = null; if (!string.IsNullOrEmpty(disk.GetDiskFile)) { diskPathWithExtension = disk.Path; diskPathWithoutExtension = disk.GetDiskFolder + "\\" + Path.GetFileNameWithoutExtension(disk.GetDiskFile); } string image = null; // If the Disk is a media file, look for an image in the disk // folder with the same name as the media file. if (!string.IsNullOrEmpty(diskPathWithExtension)) { if (File.Exists(diskPathWithExtension + ".jpg")) { image = diskPathWithExtension + ".jpg"; } else if (File.Exists(diskPathWithExtension + ".png")) { image = diskPathWithExtension + ".png"; } else if (File.Exists(diskPathWithoutExtension + ".jpg")) { image = diskPathWithoutExtension + ".jpg"; } else if (File.Exists(diskPathWithoutExtension + ".png")) { image = diskPathWithoutExtension + ".png"; } } // Look for a generic folder.xxx image if (string.IsNullOrEmpty(image)) { if (File.Exists(Path.Combine(diskFolder, "folder.jpg"))) { image = Path.Combine(diskFolder, "folder.jpg"); } else if (File.Exists(Path.Combine(diskFolder, "folder.png"))) { image = Path.Combine(diskFolder, "folder.png"); } } // Look for any jpg image if (string.IsNullOrEmpty(image)) { string[] imagefiles = Directory.GetFiles(diskFolder, "*.jpg"); if (imagefiles.Count() > 0) { image = imagefiles[0]; } } // Look for any jpg image if (string.IsNullOrEmpty(image)) { string[] imagefiles = Directory.GetFiles(diskFolder, "*.png"); if (imagefiles.Count() > 0) { image = imagefiles[0]; } } if (!string.IsNullOrEmpty(image)) { title.FrontCoverPath = image; } // Check for fanart string fanartfolder = Path.Combine(diskFolder, "Fanart"); if (Directory.Exists(fanartfolder)) { foreach (string imagefile in Directory.GetFiles(fanartfolder)) { string extension = Path.GetExtension(imagefile); if (!string.IsNullOrEmpty(extension)) { if ((string.Compare(extension, ".jpg", true) == 0) || (string.Compare(extension, ".png", true) == 0) || (string.Compare(extension, ".bmp", true) == 0)) { title.AddFanArtImage(imagefile); } } } } }
public DiskInfoFrm(Title title, Disk disk) { _disk = disk; _title = title; InitializeComponent(); //OMLEngine.DiskInfo di = new OMLEngine.DiskInfo(_disk.Name, _disk.Path, _disk.Format); TreeNode topNode = new TreeNode(); topNode.Name = _disk.Path; topNode.Text = _disk.Path; tvDiskInfo.Nodes.Add(topNode); int FeatureNo = 0; int VideoStreamNo = 0; int AudioStreamNo = 0; foreach (DIFeature df in _disk.DiskFeatures) { TreeNode featureNode = new TreeNode(); featureNode.Name = "Feature," + FeatureNo.ToString() + "," + df.Name; featureNode.Text = df.Name; topNode.Nodes.Add(featureNode); if (df.Filesize != 0) { featureNode.Nodes.Add("Size : " + df.Filesize.ToString()); } if (df.Format != null) { if (df.Format.ToString() != "") { featureNode.Nodes.Add("Format : " + df.Format); } } featureNode.Nodes.Add(string.Format("Duration : {0:00}:{1:00}:{2:00}",Math.Floor(df.Duration.TotalHours),df.Duration.Minutes,df.Duration.Seconds)); if (df.Chapters.Count > 0) { TreeNode chapters = new TreeNode(); chapters.Name = "Chapters"; chapters.Text = "Chapters"; featureNode.Nodes.Add(chapters); foreach (DIChapter ch in df.Chapters) { chapters.Nodes.Add("Chapter " + ch.ChapterNumber.ToString() + string.Format(" : Start Time {0:00}:{1:00}:{2:00}", Math.Floor(ch.StartTime.TotalHours), ch.StartTime.Minutes, ch.StartTime.Seconds) + string.Format(" : Duration {0:00}:{1:00}:{2:00}", Math.Floor(ch.Duration.TotalHours), ch.Duration.Minutes, ch.Duration.Seconds)); } } TreeNode video = new TreeNode(); video.Name = "Video Streams"; video.Text = "Video Streams"; featureNode.Nodes.Add(video); foreach (DIVideoStream vd in df.VideoStreams) { TreeNode videostream = new TreeNode(); videostream.Name = "VideoStream," + FeatureNo.ToString() + "," + VideoStreamNo.ToString() + "," + vd.Name; videostream.Text = vd.Name; video.Nodes.Add(videostream); if (vd.TitleID != 0) { videostream.Nodes.Add(videostream.Name, "Title ID : " + vd.TitleID); } if (vd.AspectRatio != "") { videostream.Nodes.Add(videostream.Name, "Aspect Ratio : " + vd.AspectRatio); } if (vd.Bitrate != 0) { videostream.Nodes.Add(videostream.Name, "Bitrate : " + vd.Bitrate.ToString() + "kbps"); } if (vd.Format != null) { if (vd.Format.ToString() != "") { videostream.Nodes.Add(videostream.Name, "Format : " + vd.Format); } } if (vd.FrameRate != 0) { videostream.Nodes.Add(videostream.Name, "Framerate : " + vd.FrameRate.ToString() + "fps"); } if (vd.Resolution.Width != 0) { videostream.Nodes.Add(videostream.Name, "Picture Size : " + vd.Resolution.Width.ToString() + "x" + vd.Resolution.Height.ToString()); } if (vd.ScanType != "") { videostream.Nodes.Add(videostream.Name, "Scan Type : " + vd.ScanType); } VideoStreamNo++; } TreeNode audio = new TreeNode(); audio.Name = "Audio Streams"; audio.Text = "Audio Streams"; featureNode.Nodes.Add(audio); foreach (DIAudioStream ad in df.AudioStreams) { TreeNode audiostream = new TreeNode(); audiostream.Name = ad.Name; audiostream.Text = ad.Name; audio.Nodes.Add(audiostream); if (ad.TrackNo != 0) { audiostream.Nodes.Add("Track No : " + ad.TrackNo.ToString()); } if (ad.AudioID != 0) { audiostream.Nodes.Add("Audio ID : " + ad.AudioID.ToString()); } // Build enocding string StringBuilder str = new StringBuilder(); str.Append("Encoding : " + ad.Encoding.ToString()); if (ad.EncodingProfile != DIAudioEncodingProfile.Undefined) str.Append(" " + ad.EncodingProfile.ToString()); if (ad.SubFormat != "") { str.Append(" in " + ad.SubFormat); } audiostream.Nodes.Add(str.ToString()); if (ad.Language != "") { audiostream.Nodes.Add("Language : " + ad.Language.ToString()); } if (ad.SampleFreq != 0) { audiostream.Nodes.Add("Sample Frequency : " + ad.SampleFreq.ToString()); } if (ad.Channels != 0) { audiostream.Nodes.Add("Channels : " + ad.Channels.ToString()); } if (ad.Bitrate != 0) { audiostream.Nodes.Add("Bitrate : " + ad.Bitrate.ToString() + "kbps (" + ad.BitrateMode + ")"); } AudioStreamNo++; } FeatureNo++; } }
public void TEST_BASE_CASE() { Title t = new Title(); t.AspectRatio = "Widescreen"; t.BackCoverPath = "back.jpg"; t.CountryOfOrigin = "US"; t.DateAdded = new DateTime(2008, 01, 01); t.Studio = "Paramount"; Disk disk = new Disk(); disk.Name = "Disk 1"; disk.Path = "myfile.wpl"; disk.Format = VideoFormat.WPL; t.Disks.Add(disk); t.FrontCoverPath = "front.jpg"; t.WatchedCount = 1; t.ImporterSource = "MyMovies"; t.MetadataSourceID = "123"; t.MetadataSourceName = "MyMovies"; t.ParentalRating = "R"; t.Name = "My Movie"; t.OfficialWebsiteURL = "http://www.mymovie.com"; t.OriginalName = "My Movie"; t.ReleaseDate = new DateTime(2008, 1, 1); t.Runtime = 110; t.Synopsis = "This is my long synopsis of my movie"; t.UPC = "123ABC"; t.UserStarRating = 5; t.VideoStandard = "NTSC"; t.AddActingRole("Translucent", "Actor"); t.AddActingRole("taranu", "Actor"); t.AddNonActingRole("KingManon", "crew"); t.AddNonActingRole("Chris", "crew"); t.AddDirector(new Person("Tim")); t.AddGenre("Comedy"); t.AddAudioTrack("English"); t.AddAudioTrack("French"); t.AddProducer(new Person("Sony")); t.AddWriter(new Person("Timothy")); Assert.AreEqual("Widescreen", t.AspectRatio); Assert.AreEqual("back.jpg", t.BackCoverPath); Assert.AreEqual("US", t.CountryOfOrigin); Assert.IsTrue(new DateTime(2008, 01, 01).CompareTo(t.DateAdded) == 0); Assert.AreEqual("Paramount", t.Studio); Assert.AreEqual("myfile.wpl", t.Disks[0].Path); Assert.AreEqual("Disk 1", t.Disks[0].Name); Assert.AreEqual("front.jpg", t.FrontCoverPath); Assert.AreEqual(1, t.WatchedCount); Assert.AreEqual("MyMovies", t.ImporterSource); Assert.AreEqual("123", t.MetadataSourceID); Assert.AreEqual("MyMovies", t.MetadataSourceName); Assert.AreEqual("R", t.ParentalRating); Assert.AreEqual("My Movie", t.Name); Assert.AreEqual("http://www.mymovie.com", t.OfficialWebsiteURL); Assert.AreEqual("My Movie", t.OriginalName); Assert.IsTrue(new DateTime(2008, 01, 01).CompareTo(t.ReleaseDate) == 0); Assert.AreEqual("123ABC", t.UPC); Assert.AreEqual(5, t.UserStarRating); Assert.AreEqual(VideoFormat.WPL, t.Disks[0].Format); Assert.AreEqual("NTSC", t.VideoStandard); Assert.AreEqual(2, t.ActingRoles.Count); IEnumerable<string> actors = t.ActingRoles.Select(a => a.PersonName); Assert.That(actors.Contains("Translucent")); Assert.That(actors.Contains("taranu")); //Assert.AreEqual("KingManon", ((Person)t.Crew[0]).full_name); //Assert.AreEqual("Chris", ((Person)t.Crew[1]).full_name); Assert.AreEqual(1, t.Directors.Count); Assert.AreEqual("Tim", ((Person)t.Directors[0]).full_name); Assert.AreEqual(1, t.Genres.Count); Assert.AreEqual("Comedy", t.Genres[0]); Assert.AreEqual(2, t.AudioTracks.Count); Assert.AreEqual("English", t.AudioTracks[0]); Assert.AreEqual("French", t.AudioTracks[1]); Assert.AreEqual(1, t.Producers.Count); Assert.AreEqual("Sony", t.Producers[0]); Assert.AreEqual(1, t.Writers.Count); Assert.AreEqual("Timothy", ((Person)t.Writers[0]).full_name); }