public static bool LoadEpisodes() { try { if (File.Exists("brbepisodes.json")) { string serializedBRBList = File.ReadAllText("brbepisodes.json"); BRBEpisodes = JsonConvert.DeserializeObject <List <BRBEpisode> >(serializedBRBList); } foreach (BRBEpisode ep in BRBEpisodes) { // Sacrifice some time to sort BRB playbacks ascending, just in case ep.PlaybackChapters.Sort(); } BRBEpisodes.Sort(); RefreshAvailableList(); return(true); } catch (IOException) { return(false); } catch (JsonException) { return(false); } }
public static bool RegisterNewBRB(string filename) { // Failsafe so BRB episodes do not get into the system twice, but this should never trigger foreach (BRBEpisode ep in BRBEpisodes) { if (ep.Filename == filename) { return(false); } } try { BRBEpisode newEpisode = new BRBEpisode(filename); if (newEpisode.Duration.Ticks > 0) { BRBEpisodes.Add(new BRBEpisode(filename)); BRBEpisodes.Sort(); RefreshAvailableList(); return(true); } else { return(false); } } catch (IOException) { return(false); } catch (VLCException) { return(false); } }
// Update the filename of a BRB episode, without considering anything else (for instance, when user updates a BRB to its new filename) public static bool TransferToNewFilename(BRBEpisode episode, string newFilename, bool removeOldEpisode) { BRBEpisode newEpisodeVersion = new BRBEpisode(newFilename, episode.Duration, episode.Favourite, episode.Title, episode.Description, episode.Credits, episode.IsNew, episode.PlaybackChapters, episode.GuaranteedPlays, episode.PriorityPlays, episode.AutoMutes, episode.AutoMuteEnabled); newEpisodeVersion.RefreshDuration(); // Make sure the episode's video file is understood by the application if (newEpisodeVersion.Duration.Ticks == 0) { return(false); } if (removeOldEpisode) { BRBEpisodes.Remove(episode); } BRBEpisodes.Add(newEpisodeVersion); BRBEpisodes.Sort(); return(true); }
public static BRBEpisode GetEpisode(string filename) { return(BRBEpisodes.FirstOrDefault(ep => ep.Filename == filename)); }