private static Playlist GetSavedAlbum(string artist, string album) { var A = new Playlist(); var aFolderPath = GetAlbumName(artist, album); if (Directory.Exists(aFolderPath)) { foreach (var file in Directory.GetFiles(aFolderPath, "*.mp3")) { A.Add(new SongInfo() { filePath = file, artist = artist, songName = GetNameFromPath(file), }); } return(A); } return(null); }
private static Playlist GetAlbumFromZip(string artist, string album, ZipArchive archive) { var A = new Playlist(); List <ZipArchiveEntry> entries = null; List <string> entryNames = null, entryUrls = null; var aFolderPath = GetAlbumName(artist, album); if ((entryNames = TrimSongNames(entryUrls = (entries = archive .Entries.Where(s => s.FullName.ToLower().EndsWith("mp3")).ToList()) .Select(s => s.FullName).ToList()).ToList()).Count < 2) { return(null); } Array.ForEach(Directory.CreateDirectory(aFolderPath).GetFiles() .Select(f => f.FullName).ToArray(), File.Delete); for (int c = 0; c < entries.Count; c++) { var str = entries[c].Open(); var path = aFolderPath + string.Format("/{0:D2} {1} f.mp3", c + 1, entryNames[c]); var fs = new FileStream(path, FileMode.Create); str.CopyTo(fs); str.Dispose(); fs.Dispose(); //ConvertStream(mp3P, path); //File.Delete(mp3P); A.Add(new SongInfo() { artist = artist, songName = entryNames[c], songUrl = entryUrls[c], filePath = path, }); str.Dispose(); } return(A); }