static void Main(string[] args) { if (args.Length == 0) { ExitMessage("Please drag a .bplist file onto this .exe", 1); } string path = args[0]; bool fileExists = File.Exists(path); if (!fileExists) { ExitMessage("The specified file does not exist!", 1); } string text = File.ReadAllText(path); var legacy = PlaylistConverter.DeserializeLegacyPlaylist(text); var playlist = PlaylistConverter.ConvertLegacyPlaylist(legacy); string newPath = path.Replace(".bplist", ".blist"); using (FileStream fs = File.Open(newPath, FileMode.OpenOrCreate)) { using (MemoryStream ms = PlaylistLib.SerializeStream(playlist)) { ms.CopyTo(fs); fs.Flush(); } } }
static bool ConvertFile(string path) { bool fileExists = File.Exists(path); if (fileExists == false) { Console.WriteLine($"File \"{path}\" does not exist"); return(false); } using (StreamReader file = File.OpenText(path)) { try { var legacy = PlaylistConverter.DeserializeLegacyPlaylist(file); var playlist = PlaylistConverter.ConvertLegacyPlaylist(legacy); string newPath = path.Replace(".bplist", ".blist").Replace(".json", ".blist"); using (FileStream fs = File.Open(newPath, FileMode.OpenOrCreate)) { PlaylistLib.SerializeStream(playlist, fs); return(true); } } catch (Exception ex) { Console.WriteLine($"Exception in {path}"); Console.WriteLine(ex.ToString()); return(false); } } }
/* Overwrites a legacy playlist with Blister playlist. Does not change file name. */ public static void OverwritePlaylist(string path, Playlist playlist) { using (FileStream fs = File.Open(path, FileMode.OpenOrCreate)) { PlaylistLib.SerializeStream(playlist, fs); } }