public async Task GetEpisodeDetails() { if (NavigationService.IsNetworkAvailable) { var index = SelectedEpisode.IndexNumber; if (SelectedEpisode != null && Episodes.IsNullOrEmpty()) { SetProgressBar(AppResources.SysTrayGettingEpisodeDetails); try { if (string.IsNullOrEmpty(SelectedEpisode.SeriesId)) { var episode = await ApiClient.GetItemAsync(SelectedEpisode.Id, AuthenticationService.Current.LoggedInUserId); if (episode == null) { await _messageBox.ShowAsync(AppResources.ErrorEpisodeDetails); NavigationService.GoBack(); return; } SelectedEpisode = episode; } var query = new EpisodeQuery { UserId = AuthenticationService.Current.LoggedInUserId, SeasonId = SelectedEpisode.SeasonId, SeriesId = SelectedEpisode.SeriesId, Fields = new[] { ItemFields.ParentId, ItemFields.Overview, ItemFields.MediaSources, } }; //Log.Info("Getting episodes for Season [{0}] ({1}) of TV Show [{2}] ({3})", SelectedSeason.Name, SelectedSeason.Id, SelectedTvSeries.Name, SelectedTvSeries.Id); var episodes = await ApiClient.GetEpisodesAsync(query); Episodes = episodes.Items.OrderBy(x => x.IndexNumber).ToList(); } catch (HttpException ex) { Utils.HandleHttpException("GetEpisodeDetails()", ex, NavigationService, Log); } SetProgressBar(); } if (SelectedEpisode != null) { SelectedEpisode = Episodes.FirstOrDefault(x => x.IndexNumber == index); CanResume = SelectedEpisode != null && SelectedEpisode.CanResume; } } }
public void Refresh() { IsLoading = true; _tvshowtimeApiService.GetWatchlist(0, 0) .Subscribe(async(watchlistResponse) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { _watchedOrUnwatchedEpisode = false; _followedOrUnfollowedShow = false; LastLoadingDate = DateTime.Now; Episodes.Clear(); foreach (var episode in watchlistResponse.Episodes) { Episodes.Add(episode); } IsLoading = false; }); }, async(error) => { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { IsLoading = false; }); _toastNotificationService.ShowErrorNotification("An error happened. Please retry later."); }); }
public void RemoveFromDatabase(Database.CustomDbContext db) { if (db == null) { return; } if (InDatabase) { InDatabase = false; if (Show != null) { Show.RemoveFromDatabase(db); } foreach (FavEpisodeData episode in Episodes.ToList()) { episode.RemoveFromDatabase(db); } foreach (DownloadData nonEpisode in NonEpisodes.ToList()) { nonEpisode.RemoveFromDatabase(db); } Database.DatabaseWriter.RemoveFromDatabase <FavSeasonData>(db.FavSeasonData, this); } }
internal void CopyFrom(TvShowSeason season) { Season = season.Season; var c = Episodes.Count; var ec = season.Episodes.Count; while (c > ec) { Episodes.Remove(Episodes.ElementAt(--c)); } for (var i = 0; i < ec; i++) { TvShowEpisode episode; if (c < i + 1) { episode = new TvShowEpisode(); Episodes.Add(episode); } else { episode = Episodes.ElementAt(i); } episode.CopyFrom(season.Episodes.ElementAt(i)); } }
private void OnDeleteEpisode(object parameter) { if (SelectedEpisode != null) { string episodeName = SelectedEpisode.Name; MessageBoxResult result = MessageBox.Show($"Are you sure you want to delete the {episodeName} episode from series?", "Delete Episode", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: Episodes.Remove(SelectedEpisode); EpisodeOperationFeedback = "Episode Deleted"; if (Episodes.Any()) { SelectedEpisode = Episodes[0]; } break; case MessageBoxResult.No: EpisodeOperationFeedback = "Episode Deletion Canceled"; break; } } }
public void should_be_able_to_get_a_single_episode() { var series = GivenSeriesWithEpisodes(); var episodes = Episodes.GetEpisodesInSeries(series.Id); Episodes.Get(episodes.First().Id).Should().NotBeNull(); }
private void SeasonsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { Episodes.Clear(); foreach (string season in SeasonsListBox.SelectedItems) { var episodesResult = Directory.EnumerateFiles(season); foreach (var filePath in episodesResult) { Episodes.Add(filePath); } } if (SeasonsListBox.SelectedItems.Count == 0) { WriteOutput("Selections cleared.", OutputMessageLevel.Warning); } else if (SeasonsListBox.SelectedItems.Count == 1) { WriteOutput($"{System.IO.Path.GetFileName(openFolderDialog.FileName)} selected ({Episodes.Count} episodes).", OutputMessageLevel.Informational); } else { WriteOutput($"{SeasonsListBox.SelectedItems.Count} seasons selected ({Episodes.Count} total episodes).", OutputMessageLevel.Informational); } Analytics.TrackEvent("Season Selection", new Dictionary <string, string> { { "Selected Seasons", SeasonsListBox.SelectedItems.Count.ToString(CultureInfo.InvariantCulture) } }); }
private void FollowRequester(Show s, Episodes eps) { MultiSelect m = new MultiSelect(true, s.Name); m.FileFormats = Settings.Instance.DefaultFormat; m.FileQuality = Settings.Instance.DefaultQuality; m.Episodes = eps; DialogResult f = m.ShowDialog(); if (f == DialogResult.OK) { if (Follows.Instance.IsFollow(s.Id, s.PluginName, m.FileQuality, m.FileFormats)) { Log(LogType.Warn, "You are already following '" + s.Name + "' with this settings"); } else { Follows.Instance.AddFollow(s.Id, s.PluginName, m.FileQuality, m.FileFormats); foreach (Episode ep in eps.Items) { Follows.Instance.AddDownload(EpisodeWithDownloadSettings.FromEpisode(ep, m.FileQuality, m.FileFormats)); } foreach (Episode ep in m.Active) { AddDownloadEpisode(ep, m.FileQuality, m.FileFormats); } } } }
public async void CheckDownloads() { await Task.Run(async() => { try { var folder = await FileHelper.GetLocalFolder(true); if (await folder.TryGetItemAsync(Root) == null) { return; } var podcastFolder = await folder.GetFolderAsync(Root); var files = await podcastFolder.GetFilesAsync(); foreach (var file in files) { var fileName = file.Name; var episode = Episodes.FirstOrDefault(e => e.LocalFilename.ContainsIgnoreCase(fileName)); if (episode != null) { episode.IsAlreadyDownloaded = true; episode.UpdateDownloadInfo(); } } } catch { // Ignore error } }); }
private float GetScoreMid() { float maxY = Episodes.Max(item => item.ImdbRating); float minY = Episodes.Min(item => item.ImdbRating); return((maxY + minY) / 2); }
static void RemoveEpisodeImagesFromCache(TmdbEpisodeImages images, int season, int episode) { if (images != null) { Episodes.RemoveAll(e => e.Id == images.Id && e.Season == season && e.Episode == episode); } }
public static TmdbEpisodeImages GetEpisodeImages(int?id, int season, int episode, bool forceUpdate = false) { if (id == null) { return(null); } // if its in our cache return it var episodeImages = Episodes.FirstOrDefault(e => e.Id == id && e.Season == season && e.Episode == episode); if (episodeImages != null) { if (forceUpdate) { return(episodeImages); } // but only if the request is not very old if (DateTime.Now.Subtract(new TimeSpan(TraktSettings.TmdbEpisodeImageMaxCacheAge, 0, 0, 0, 0)) < Convert.ToDateTime(episodeImages.RequestAge)) { return(episodeImages); } TraktLogger.Info("Episode image cache expired. TMDb ID = '{0}', Season = '{1}', Episode = '{2}', Request Age = '{3}'", id, season, episode, episodeImages.RequestAge); RemoveEpisodeImagesFromCache(episodeImages, season, episode); } // get movie images from tmdb and add to the cache episodeImages = TmdbAPI.TmdbAPI.GetEpisodeImages(id.ToString(), season, episode); AddEpisodeImagesToCache(episodeImages, id, season, episode); return(episodeImages); }
private void ShowPodcastEpisodes(NotificationMessage <Podcast> message) { Episodes.Add(new Episode() { Description = "How can competition teach machine learning? Carl and Richard talk to Anthony Goldbloom of Kaggle about competitive machine learning. Kaggle hosts competitions provided by industry and academia to find machine learning solutions on different data sets. While the competitive aspects tend toward only particular types of data sets, Anthony talks about how two very different machine learning algorithms - Gradient Boosting Machine and Deep Recurrent Neural Networks - have risen to the top. Want to learn machine learning in a hurry? Join a competition!", DownloadUrl = new Uri("https://s3.amazonaws.com/dnr/dotnetrocks_1307_competitive_machine_learning.mp3"), IsDownloaded = false, PodcastId = 1, EpisodeId = 1, Name = "Competitive Machine Learning with Anthony Goldbloom" }); Episodes.Add(new Episode() { Description = "Where does our sense of right and wrong come from? We watch chimps at a primate research center sharing blackberries, observe 3-year-olds fighting over toys, and tour Eastern State Penitentiary -- the countrys first penitentiary. Plus, a story of land grabbing, indentured servitude, and slumlording in the fourth grade.", DownloadUrl = new Uri("http://www.radiolab.org/story/91508-morality/"), IsDownloaded = false, PodcastId = 1, EpisodeId = 2, Name = "Morality" }); Episodes.Add(new Episode() { Description = "Some Explanation...", DownloadUrl = new Uri("http://www.DownlowdUrl"), IsDownloaded = false, PodcastId = 1, EpisodeId = 3, Name = "Episode3", }); }
public async Task <IActionResult> Edit(int id, [Bind("ID,ShowName,Season,EpisodeNumber,EpisodeName,Description,BestCharacter,HumorRating,StoryRating,OverallGrade")] Episodes episodes) { if (id != episodes.ID) { return(NotFound()); } if (ModelState.IsValid) { try { episodes.OverallGrade = episodes.HumorRating + episodes.StoryRating; _context.Update(episodes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EpisodesExists(episodes.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(episodes)); }
private void RefreshEpisodesList() { Episodes.Clear(); foreach (string season in SeasonsListBox.SelectedItems) { var folderName = System.IO.Path.GetFileName(season); if (string.IsNullOrEmpty(folderName)) { WriteOutput($"Could not identify directory.", OutputMessageLevel.Error); return; } var episodesResult = Directory.EnumerateFiles(season); WriteOutput($"Searching {folderName} episodes...", OutputMessageLevel.Normal); foreach (var filePath in episodesResult) { if (System.IO.Path.HasExtension(filePath)) { Episodes.Add(filePath); WriteOutput($"Adding {filePath}...", OutputMessageLevel.Normal, true); } } WriteOutput($"Refreshed {folderName} {Episodes.Count} episodes.", OutputMessageLevel.Normal, true); } }
/// <summary> /// Изменить выбранный эпизод и все связанные данные /// </summary> /// <param name="value">Конечное значение эпизода</param> private void ChangeSelectedEpisode(CartoonEpisode value) { if (IsDesignTime) { _selectedEpisode = value; NotifyOfPropertyChange(() => SelectedEpisode); return; } if (_selectedEpisode == value) { return; } IdList.EpisodeId = value?.CartoonEpisodeId ?? 0; ChangeSelectedVoiceOver(null); if (value == null) { _selectedEpisode = null; EpisodeIndexes.CurrentIndex = -1; NotifyEpisodeData(); } else { EpisodeIndexes.CurrentIndex = Episodes.IndexOf(value); LoadData(); } }
/// <summary> /// Изменить выбранный эпизод и все связанные данные /// </summary> /// <param name="value">Конечное значение эпизода</param> private void ChangeSelectedEpisode(CartoonEpisode value) { if (IsDesignTime) { _selectedEpisode = value; NotifyOfPropertyChange(() => SelectedEpisode); return; } EpisodeIndexes.CurrentIndex = value == null ? -1 : Episodes.IndexOf(value); NotifyOfPropertyChange(() => CanSelectNextEpisode); NotifyOfPropertyChange(() => CanSelectPreviousEpisode); if (_selectedEpisode == value) { return; } IdList.EpisodeId = value?.CartoonEpisodeId ?? 0; SelectedEpisodeVoiceOver = null; if (value == null) { _selectedEpisode = null; NotifyEpisodeData(); } else { LoadData(); } }
private void OnEditEpisode(object parameter) { string commandParameter = parameter.ToString(); if (commandParameter == "SAVE") { if (EpisodeToEdit != null) { Episode episodeToDelete = SelectedEpisode; Episodes.Add(EpisodeToEdit); SelectedEpisode = EpisodeToEdit; Episodes.Remove(episodeToDelete); EpisodeOperationFeedback = "Episode Updated"; } } else if (commandParameter == "CANCEL") { // EpisodeToEdit = SelectedEpisode.Copy(); EpisodeOperationFeedback = "Episode Update Canceled"; } else { throw new ArgumentException($"{commandParameter} is not a valid command parameter for the adding Episodes."); } }
private void DeleteEpisode(object parameter) { if (SelectedEpisode != null) { string episodeName = SelectedEpisode.Name; MessageBoxResult result = MessageBox.Show($"Are you sure you want to delete the {episodeName} episode from inventory?", "Delete Episodes", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: Episodes.Remove(SelectedEpisode); MessageBox.Show($"{episodeName} Episode Deleted", "Delete Episodes"); if (Episodes.Any()) { SelectedEpisode = Episodes[0]; } break; case MessageBoxResult.No: MessageBox.Show($"{episodeName} Episode Deletion Canceled", "Delete Episodes"); break; } } }
void CheckForAutomaticDownloads() { if (!IsInLibrary) { return; } int checkCount = AppSettings.Instance.DownloadLastEpisodesCount; if (checkCount == 0) { return; } foreach (var episode in Episodes.OrderByDescending(e => e.PublicationDate)) { if (!episode.IsPlayed && !episode.DownloadInProgress && !episode.IsAlreadyDownloaded) { episode.DownloadAsync(false); } checkCount--; if (checkCount == 0) { return; } } }
public async Task GetEpisodeDetails() { if (_navService.IsNetworkAvailable) { if (SelectedEpisode != null && Episodes.IsNullOrEmpty()) { SetProgressBar(AppResources.SysTrayGettingEpisodeDetails); try { var query = new ItemQuery { UserId = AuthenticationService.Current.LoggedInUser.Id, ParentId = SelectedEpisode.ParentId, Fields = new[] { ItemFields.ParentId, ItemFields.Overview } }; //Log.Info("Getting episodes for Season [{0}] ({1}) of TV Show [{2}] ({3})", SelectedSeason.Name, SelectedSeason.Id, SelectedTvSeries.Name, SelectedTvSeries.Id); var episodes = await _apiClient.GetItemsAsync(query); Episodes = episodes.Items.OrderBy(x => x.IndexNumber).ToList(); } catch (HttpException ex) { } SetProgressBar(); } } }
public void SetEpisode(int index) { if (AllModalsClosed()) { Episodes e = allEpisodes[index]; episodeNo.text = "Episode " + (index + 1); episodeTitle.text = lm.GetString("episode_" + (index + 1) + "_title"); episodeDesc.text = lm.GetString("episode_" + (index + 1) + "_desc"); if (PlayerPrefs.GetInt("currentEpisodeNumber") == index) { episodePlay.text = string.Format(lm.GetString("ui_title_continue_episode"), (index + 1)); } else { episodePlay.text = string.Format(lm.GetString("ui_title_play_episode"), (index + 1)); } episodeBackground.sprite = e.episodeImage; selectedEpisode = index; selected.transform.SetParent(episodeButtons[index].transform.Find("Image"), false); RectTransform rt = selected.GetComponent <RectTransform>(); rt.offsetMax = new Vector2(5f, 5f); rt.offsetMin = new Vector2(-5f, -5f); } }
public async Task <ActionResult <Episodes> > PutEpisodes(long id, Episodes episodes) { if (id != episodes.Id) { return(BadRequest()); } _context.Entry(episodes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EpisodesExists(id)) { return(NotFound()); } else { throw; } } return(episodes); }
public void UnwatchAll() { Episodes.ForEach(x => x.PlayedLength = 0); Episodes.ForEach(x => x.Hidden = false); Episodes.ForEach(x => x.PlayedLengthScaled = 0); Modifyed = true; }
public async Task <ActionResult <Episodes> > PostEpisodes(Episodes episodes) { _context.Episodes.Add(episodes); await _context.SaveChangesAsync(); return(CreatedAtAction("GetEpisodes", new { id = episodes.Id }, episodes)); }
internal void UpdateEpisode(List <EpisodeControl> newEpisodes) { bool addedNew = false; foreach (EpisodeControl newEpisode in newEpisodes) { bool newEpisodeFlag = true; foreach (EpisodeControl episode in Episodes) { if (episode.SameAs(newEpisode)) { newEpisodeFlag = false; } } if (newEpisodeFlag) { Episodes.Add(newEpisode); addedNew = true; } } if (addedNew) { DebugLog.LogInfo($"Added episodes to {Title}"); Modifyed = true; Shows.GetShowService.Save(); } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Episodes.Clear(); var episodes = await GetEpisodes(); foreach (var episode in episodes) { Episodes.Add(episode); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
/// <summary> /// Действие при изменении выбора сезона /// </summary> public void SelectionChanged(ListBox lb) { EpisodeIndexes.CurrentIndex = Episodes.IndexOf(SelectedEpisode); lb.ScrollIntoView(lb.SelectedItem); NotifyOfPropertyChange(() => CanEditNextEpisode); NotifyOfPropertyChange(() => CanEditPreviousEpisode); }
protected void ProcessEpisodes(IEnumerable <TVShowEpisode> episodes) { Episodes = episodes.OrderBy(e => e.EpisodeNumber).ToList(); GroupedEpisodes = GetGroupedEpisodes(Episodes); GroupedUnwatchedEpisodes = GetGroupedEpisodes(Episodes.Where(e => e.PlayedState != ItemPlayedState.HasBeenPlayed)); }
internal bool IsPostable() { return((Movies != null && Movies.Any()) || (Shows != null && Shows.Any()) || (Seasons != null && Seasons.Any()) || (Episodes != null && Episodes.Any()) || (People != null && People.Any())); }
/// <summary> /// Videoes the library callback manager. /// </summary> /// <param name="requestState">State of the request.</param> private void VideoLibraryCallbackManager(XRequestState requestState) { object returnObject = null; VideoLibrary operation = GetMethod(requestState.RequestOperation); var query = JObject.Parse(requestState.ResponseData); JObject result = (JObject)query["result"]; switch (operation) { case VideoLibrary.Clean: returnObject = result.Values(0).ToString(); break; case VideoLibrary.Export: break; case VideoLibrary.GetEpisodeDetails: Episode episode = null; if (result["episodedetails"] != null) { JObject item = (JObject)result["episodedetails"]; episode = Episode.FromJsonObject(item); } returnObject = episode; break; case VideoLibrary.GetEpisodes: case VideoLibrary.GetRecentlyAddedEpisodes: var episodes = new Episodes(); episodes.LoadFromJsonObject(result); returnObject = episodes; break; case VideoLibrary.GetGenres: var genres = new Genres(); genres.LoadFromJsonObject(result); returnObject = genres; break; case VideoLibrary.GetMovieDetails: Movie movie = null; if (result["moviedetails"] != null) { JObject item = (JObject)result["moviedetails"]; movie = Movie.FromJsonObject(item); } returnObject = movie; break; case VideoLibrary.GetMovies: case VideoLibrary.GetRecentlyAddedMovies: var movies = new Movies(); movies.LoadFromJsonObject(result); returnObject = movies; break; case VideoLibrary.GetMovieSetDetails: MovieSetExtended movieSet = null; if (result["setdetails"] != null) { JObject item = (JObject)result["setdetails"]; movieSet = MovieSetExtended.FromJsonObject(item); } returnObject = movieSet; break; case VideoLibrary.GetMovieSets: var movieSets = new MovieSets(); movieSets.LoadFromJsonObject(result); returnObject = movieSets; break; case VideoLibrary.GetMusicVideoDetails: MusicVideo musicVideo = null; if (result["musicvideodetails"] != null) { JObject item = (JObject)result["musicvideodetails"]; musicVideo = MusicVideo.FromJsonObject(item); } returnObject = musicVideo; break; case VideoLibrary.GetMusicVideos: case VideoLibrary.GetRecentlyAddedMusicVideos: var musicVideos = new MusicVideos(); musicVideos.LoadFromJsonObject(result); returnObject = musicVideos; break; case VideoLibrary.GetSeasons: var seasons = new Seasons(); seasons.LoadFromJsonObject(result); returnObject = seasons; break; case VideoLibrary.GetTVShowDetails: TvShow tvShow = null; if (result["tvshowdetails"] != null) { JObject item = (JObject)result["tvshowdetails"]; tvShow = TvShow.FromJsonObject(item); } returnObject = tvShow; break; case VideoLibrary.GetTVShows: var tvShows = new TvShows(); tvShows.LoadFromJsonObject(result); returnObject = tvShows; break; case VideoLibrary.Scan: returnObject = result.Values(0).ToString(); break; } if (requestState.UserCallback != null) requestState.UserCallback(returnObject); }