public Dictionary <string, string> MetaManual(object obj) { List <string> TagList = new List <string>(); if (obj.GetType() == typeof(Media)) { Media m = (Media)obj; Dictionary <string, string> meta = new Dictionary <string, string>(); meta.Add("File name", m.GetFileName()); meta.Add("Format", ""); meta.Add("Duration HH:MM:SS", ""); if (m.GetType() == typeof(Song)) { Song s = (Song)m; SongMetadata sm = (SongMetadata)s.GetMetadata(); meta.Add("Name", sm.GetName()); meta.Add("Artist", sm.GetArtist()); meta.Add("Album", sm.GetAlbum()); meta.Add("Genre", sm.GetGenre()); meta.Add("Release Year", sm.GetPublicationYear().ToString()); meta.Add("Label", sm.GetLabel()); meta.Add("Lyrics", sm.GetLyrics());; } else if (m.GetType() == typeof(Video)) { VideoMetadata vm = (VideoMetadata)((Video)m).GetMetadata(); meta.Add("Name", vm.GetName()); meta.Add("Creator", vm.GetCreator()); meta.Add("Genre", vm.GetGenre());; meta.Add("Category", vm.GetCategory()); string actors = ""; foreach (string item in vm.GetActors()) { actors += item; actors += ", "; } actors = actors.Substring(0, actors.Length - 2); actors += "."; meta.Add("Actors", actors); meta.Add("Director", vm.GetDirector()); meta.Add("Studio", vm.GetStudio()); meta.Add("Release Year", vm.GetPubYear().ToString()); meta.Add("Description", vm.GetDescription()); meta.Add("Resolution", vm.GetResolution()); meta.Add("Aspect Ratio", vm.GetAspectRatio()); } return(meta); } return(null); }
public Video(string fileName, VideoMetadata vm, string format, string duration) : base(fileName, format, duration) { MetaData = vm; Artist per; string director = vm.GetDirector(); bool dirEx = Spotflix.GetPeopleDB.ContainsKey(director); if (dirEx) { per = Spotflix.GetPeopleDB[director]; per.AddProfession("Director"); per.AddWork(this); } else { per = new Artist(director); per.AddProfession("Director"); per.AddWork(this); Spotflix.AddPerson(per); } List <string> actorList = vm.GetActors(); foreach (string act in actorList) { Artist art; bool acEx = Spotflix.GetPeopleDB.ContainsKey(act); if (acEx) { art = Spotflix.GetPeopleDB[act]; art.AddProfession("Actor"); art.AddWork(this); } else { art = new Artist(act); art.AddProfession("Actor"); art.AddWork(this); Spotflix.AddPerson(art); } } Spotflix.ImportMedia(this); }
public (List <Media>, List <Artist>, List <User>, List <Playlist>, List <Album>) Search(string Hkey) { List <Media> Res1 = new List <Media>(); List <Artist> Res2 = new List <Artist>(); List <User> Res3 = new List <User>(); List <Playlist> Res4 = new List <Playlist>(); List <Album> Res5 = new List <Album>(); List <Media> a = Spotflix.GetMediaDB; List <Artist> b = new List <Artist>(); List <User> c = new List <User>(); List <Playlist> d = new List <Playlist>(); List <Album> e = new List <Album>(); string key = Hkey.ToLower().Trim(); foreach (Artist item in Spotflix.GetPeopleDB.Values) { b.Add(item); foreach (Album al in item.GetAlbums().Values) { e.Add(al); } } foreach (User item in Spotflix.GetUserDB.Values) { c.Add(item); foreach (Playlist pl in item.GetPlaylist()) { d.Add(pl); } } foreach (Media media in a) { if (media.GetType() == typeof(Song)) { SongMetadata meta = (SongMetadata)media.GetMetadata(); bool IN, Year, rIN; IN = meta.GetName().ToLower().Contains(key) || meta.GetArtist().ToLower().Contains(key) || meta.GetAlbum().ToLower().Contains(key) || meta.GetGenre().ToLower().Contains(key) || meta.GetLabel().ToLower().Contains(key); if (key != "") { rIN = key.Contains(meta.GetName().ToLower()) || key.Contains(meta.GetArtist().ToLower()) || key.Contains(meta.GetAlbum().ToLower()) || key.Contains(meta.GetGenre().ToLower()) || key.Contains(meta.GetLabel().ToLower()); } else { rIN = false; } string year = meta.GetPublicationYear().ToString(); Year = (year.Contains(key) || key.Contains(year)); if (IN || Year || rIN) { Res1.Add(media); } } else //video { VideoMetadata meta = (VideoMetadata)media.GetMetadata(); bool IN, Year, rIN; IN = meta.GetName().ToLower().Contains(key) || meta.GetGenre().ToLower().Contains(key) || meta.Actors4Search().Contains(key) || meta.GetAspectRatio().ToLower().Contains(key) || meta.GetResolution().ToLower().Contains(key) || meta.GetDirector().ToLower().Contains(key) || meta.GetStudio().ToLower().Contains(key) || meta.GetCategory().ToLower().Contains(key) || meta.GetCreator().ToLower().Contains(key); rIN = key.Contains(meta.GetName().ToLower()) || key.Contains(meta.GetGenre().ToLower()) || key.Contains(meta.GetAspectRatio().ToLower()) || key.Contains(meta.GetCategory().ToLower()) || key.Contains(meta.GetResolution().ToLower()) || key.Contains(meta.GetDirector().ToLower()) || key.Contains(meta.GetStudio().ToLower()) || key.Contains(meta.GetCreator().ToLower()); string year = meta.GetPubYear().ToString(); Year = (year.Contains(key) || key.Contains(year)); if (IN || Year || rIN) { Res1.Add(media); } } } foreach (Artist item in b) { if (item.GetName().ToLower().Contains(key) || key.Contains(item.GetName().ToLower())) { Res2.Add(item); foreach (Album alb in item.GetAlbums().Values) { Res5.Add(alb); } } foreach (Album al in e) { if (al.GetName().ToLower().Contains(key.Trim()) || al.GetArtist().GetName().Contains(key)) { Res5.Add(al); Res2.Add(item); } foreach (Media m in al.GetSongs()) { if (Res1.Contains(m) && !Res5.Contains(al)) { Res5.Add(al); } } } } foreach (User item in c) { if (item.GetUsername().ToLower().Contains(key) || key.Contains(item.GetUsername().ToLower())) { Res3.Add(item); } } foreach (Playlist item in d) { if (item.GetName().ToLower().Contains(key) || key.Contains(item.GetName().ToLower()) && !item.GetPrivate()) { if (item.GetPrivate() == false) { Res4.Add(item); } } foreach (Media m in item.GetList()) { if (Res1.Contains(m) && !Res4.Contains(item) && item.GetPrivate() == false) { Res4.Add(item); } } } (List <Media>, List <Artist>, List <User>, List <Playlist>, List <Album>)SearchResults = (Res1, Res2, Res3, Res4, Res5); return(SearchResults); }