Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        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));
            }
        }
Beispiel #3
0
        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) }
            });
        }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
 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",
     });
 }
Beispiel #6
0
        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();
            }
        }
Beispiel #7
0
        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.");
            }
        }
        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.");
            });
        }
Beispiel #9
0
        public bool AddEpisodeToEpisodeList(Episode content)
        {
            int episodeListLength = Episodes.Count();

            Episodes.Add(content);
            bool wasAdded = episodeListLength + 1 == Episodes.Count();

            return(wasAdded);
        }
Beispiel #10
0
 public void LoadPodcast(Podcast p)
 {
     Podcast = p;
     Episodes.Clear();
     foreach (var e in p.Episodes)
     {
         Episodes.Add(e);
     }
 }
Beispiel #11
0
        public TvSeason(int seasonNum, string seasonUrl) : base(seasonNum, null)
        {
            this.SeasonUrl = seasonUrl;

            foreach (IEpisode ep in FetchEpisodes(seasonUrl))
            {
                Episodes.Add(ep);
            }
        }
 static void AddEpisodeImagesToCache(TmdbEpisodeImages images, int?id, int season, int episode)
 {
     if (images != null)
     {
         images.RequestAge = DateTime.Now.ToString();
         images.Season     = season;
         images.Episode    = episode;
         images.Id         = id;
         Episodes.Add(images);
     }
 }
        /// <summary>
        /// Добавить новый эпизод
        /// </summary>
        public void AddEpisode()
        {
            if (CanAddEpisode is false)
            {
                return;
            }
            using (var ctx = new CVDbContext(AppDataPath))
            {
                var cartoon = ctx.Cartoons
                              .Include(c => c.CartoonVoiceOvers)
                              .First(c => c.CartoonId == GlobalIdList.CartoonId);

                if (cartoon.CartoonVoiceOvers.Count == 0)
                {
                    WinMan.ShowDialog(new DialogViewModel(
                                          "У выбранного мультсериала отсутствуют озвучки, добавьте одну или более для создания нового эпизода",
                                          DialogType.INFO));
                    return;
                }

                // загрузка первой озвучки выбранного м/с
                CartoonVoiceOver voiceOver;

                if (DefaultVoiceOver == null)
                {
                    voiceOver = ctx.Cartoons
                                .Include(ce => ce.CartoonVoiceOvers)
                                .First(c => c.CartoonId == GlobalIdList.CartoonId).CartoonVoiceOvers.First();
                }
                else
                {
                    voiceOver = ctx.VoiceOvers
                                .First(vo => vo.CartoonVoiceOverId ==
                                       DefaultVoiceOver.CartoonVoiceOverId);
                }

                var episode = CreateNewEpisode(ctx, voiceOver);

                CreateNewEpisodeOption(ctx, episode, voiceOver);

                episode = ctx.CartoonEpisodes.ToList().Last();

                Episodes.Add(episode);
                NotifyOfPropertyChange(() => Episodes);
            }

            SelectedEpisode             = Episodes.LastOrDefault();
            EpisodeIndexes.CurrentIndex = Episodes.IndexOf(SelectedEpisode);
            EpisodeIndexes.EndIndex     = Episodes.IndexOf(SelectedEpisode);
            NotifyOfPropertyChange(() => CanEditNextEpisode);
            NotifyOfPropertyChange(() => CanEditPreviousEpisode);
        }
Beispiel #14
0
        private void AddEpisode(object parameter)
        {
            EpisodeOperation episodeOperation = new EpisodeOperation()
            {
                Status  = EpisodeOperation.OperationStatus.CANCEL,
                Episode = new Episode()
            };
            Window addEpisodeWindow = new PhilAddView(episodeOperation);

            addEpisodeWindow.ShowDialog();

            if (episodeOperation.Status != EpisodeOperation.OperationStatus.CANCEL)
            {
                Episodes.Add(episodeOperation.Episode);
                SelectedEpisode = episodeOperation.Episode;
            }
        }
Beispiel #15
0
        private void EditEpisode(object parameter)
        {
            EpisodeOperation episodeOperation = new EpisodeOperation()
            {
                Status  = EpisodeOperation.OperationStatus.CANCEL,
                Episode = SelectedEpisode
            };
            Window editEpisodeWindow = new PhilEditView(episodeOperation);

            editEpisodeWindow.ShowDialog();

            if (episodeOperation.Status != EpisodeOperation.OperationStatus.CANCEL)
            {
                Episodes.Remove(SelectedEpisode);
                Episodes.Add(episodeOperation.Episode);
                SelectedEpisode = episodeOperation.Episode;
            }
        }
Beispiel #16
0
        private void LoadEpisodes(string url)
        {
            var podcastFinder = new iTunesPodcastFinder.PodcastFinder();
            var results       = podcastFinder.GetPodcastEpisodesAsync(url);

            Episodes.Clear();

            foreach (var item in results.Result.Episodes)
            {
                Episodes.Add(
                    new Episode
                {
                    Title       = item.Title,
                    Description = item.Summary,
                    Url         = item.FileUrl.ToString(),
                    Duration    = item.Duration.ToString()
                });
            }
        }
        private void Refresh()
        {
            _tvshowtimeApiService.GetWatchlist(0, 0)
            .Subscribe(async(watchlistResponse) =>
            {
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    Episodes.Clear();

                    foreach (var episode in watchlistResponse.Episodes)
                    {
                        Episodes.Add(episode);
                    }
                });
            },
                       (error) =>
            {
                throw new Exception();
            });
        }
Beispiel #18
0
        /// <summary>
        /// Loads instance from XML.
        /// </summary>
        /// <param name="itemNode">Node to load XML from</param>
        /// <returns>true if sucessfully loaded from XML</returns>
        public bool Load(XmlNode seasonNode)
        {
            if (seasonNode.Name != ROOT_XML)
            {
                return(false);
            }

            foreach (XmlNode propNode in seasonNode.ChildNodes)
            {
                XmlElements element = XmlElements.Number;
                if (!Enum.TryParse <XmlElements>(propNode.Name, out element))
                {
                    continue;
                }

                string value = propNode.InnerText;
                switch (element)
                {
                case XmlElements.Number:
                    int number;
                    if (int.TryParse(value, out number))
                    {
                        this.Number = number;
                    }
                    break;

                case XmlElements.Episodes:
                    this.Episodes = new List <TvEpisode>();
                    foreach (XmlNode epNode in propNode.ChildNodes)
                    {
                        TvEpisode episode = new TvEpisode();
                        episode.Load(epNode);
                        Episodes.Add(episode);
                    }
                    Episodes.Sort();
                    break;
                }
            }

            return(true);
        }
Beispiel #19
0
        private void HandleEpisode(string newUrl)
        {
            Match episode = RegexPatterns.EpisodePattern.Match(newUrl);

            string title = episode.Groups[1].ToString();

            string noSpeTitle = RegexPatterns.NonSpecialCharaterPattern.Replace(title, "");
            string noSpeName  = RegexPatterns.NonSpecialCharaterPattern.Replace(SeriesName, "");

            if (noSpeTitle.ToLower().Contains(noSpeName.ToLower()))
            {
                Console.WriteLine(newUrl);
                Uri absoluteUrl = NormalizeUrl(watchLink, newUrl);
                if (!Episodes.Contains(absoluteUrl) && absoluteUrl != null &&
                    (absoluteUrl.Scheme == Uri.UriSchemeHttp || absoluteUrl.Scheme == Uri.UriSchemeHttps))
                {
                    Episodes.Add(absoluteUrl);
                    FoundNew = true;
                }
            }
        }
        private void PopulateDbSets()
        {
            Patients.Add(
                new Patient
            {
                DateOfBirth = new DateTime(1972, 10, 27),
                FirstName   = "Millicent",
                PatientId   = 1,
                LastName    = "Hammond",
                NhsNumber   = "1111111111"
            });

            Episodes.Add(
                new Episode
            {
                AdmissionDate = new DateTime(2014, 11, 12),
                Diagnosis     = "Irritation of inner ear",
                DischargeDate = new DateTime(2014, 11, 27),
                EpisodeId     = 1,
                PatientId     = 1
            });
        }
Beispiel #21
0
        private void OnAddEpisode(object parameter)
        {
            string commandParameter = parameter.ToString();

            if (commandParameter == "SAVE")
            {
                if (EpisodeToAdd != null)
                {
                    Episodes.Add(EpisodeToAdd);
                    EpisodeOperationFeedback = "New Episode Added";
                    SelectedEpisode          = EpisodeToAdd;
                }
            }
            else if (commandParameter == "CANCEL")
            {
                EpisodeOperationFeedback = "New Episode Canceled";
            }
            else
            {
                throw new ArgumentException($"{commandParameter} is not a valid command parameter for the adding Episodes.");
            }
            EpisodeToAdd = new Episode();
        }
        /// <summary>
        /// Updates the channel with any new episodes which have been published.
        /// </summary>
        /// <returns>Nothing - it's a <see cref="Task"/>.</returns>
        public async Task UpdateChannel()
        {
            PodcastChannel latestChannel = await FromPodcastUrl(RssUrl, false);

            var episodeGuids = new Collection <string>();

            // Get the guids of the episodes we already know about
            foreach (PodcastEpisode episode in Episodes)
            {
                episodeGuids.Add(episode.Guid);
            }

            // Add any published episodes that we don't already know about
            foreach (PodcastEpisode episode in latestChannel.Episodes)
            {
                if (!episodeGuids.Contains(episode.Guid))
                {
                    Episodes.Add(episode);
                }
            }

            // FIXME: user needs to switch to another channel and back to see the new episodes
            // TODO: consider updating other channel metadata if different to local copy
        }
Beispiel #23
0
        private void LoadUpcomingEpisodes()
        {
            _tvshowtimeApiService.GetAgenda(_currentPage, _pageSize)
            .Subscribe(async(agendaResponse) =>
            {
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    foreach (var episode in agendaResponse.Episodes)
                    {
                        // Do not add the same show twice
                        if (Episodes.Any(e => e.Id == episode.Id))
                        {
                            continue;
                        }

                        // Do not add episode if already aired
                        if (episode.AirDate < DateTime.Now)
                        {
                            continue;
                        }

                        string diffTime  = string.Empty;
                        var timeSpanDiff = episode.AirDate.Value.Subtract(DateTime.Now.ToUniversalTime());
                        if (episode.AirTime.HasValue)
                        {
                            timeSpanDiff = timeSpanDiff
                                           .Add(TimeSpan.FromHours(episode.AirTime.Value.DateTime.Hour));
                            timeSpanDiff = timeSpanDiff
                                           .Add(TimeSpan.FromMinutes(episode.AirTime.Value.DateTime.Minute));
                        }

                        if (timeSpanDiff.Days >= 7)
                        {
                            diffTime += $"{timeSpanDiff.Days} days";
                        }
                        else
                        {
                            if (timeSpanDiff.Days >= 1)
                            {
                                diffTime += $"{timeSpanDiff.Days} day";
                                if (timeSpanDiff.Days > 1)
                                {
                                    diffTime += "s";
                                }
                            }

                            if (timeSpanDiff.Hours >= 1)
                            {
                                if (!string.IsNullOrWhiteSpace(diffTime))
                                {
                                    diffTime += Environment.NewLine;
                                }

                                diffTime += $"{timeSpanDiff.Hours} hour";
                                if (timeSpanDiff.Hours > 1)
                                {
                                    diffTime += "s";
                                }
                            }

                            if (timeSpanDiff.Minutes >= 1)
                            {
                                if (!string.IsNullOrWhiteSpace(diffTime))
                                {
                                    diffTime += Environment.NewLine;
                                }

                                diffTime += $"{timeSpanDiff.Minutes} min.";
                            }
                        }

                        Episodes.Add(new UpcomingEpisodeViewModel
                        {
                            Id       = episode.Id,
                            Season   = episode.Season,
                            Number   = episode.Number,
                            Show     = episode.Show,
                            DiffTime = diffTime.Trim(),
                            Original = episode
                        });
                    }

                    if (agendaResponse.Episodes.Count >= _pageSize)
                    {
                        _currentPage++;
                        LoadUpcomingEpisodes();
                    }
                });
            },
                       (error) =>
            {
                throw new Exception();
            });
        }
Beispiel #24
0
        /// <summary>
        /// Loads instance from XML.
        /// </summary>
        /// <param name="itemNode">Node to load XML from</param>
        /// <returns>true if sucessfully loaded from XML</returns>
        public override bool Load(XmlNode showNode)
        {
            // Check that node is proper type
            if (showNode.Name != ROOT_XML)
            {
                return(false);
            }

            // Read base properties out
            base.ReadContentElements(showNode);

            // Read other elements
            foreach (XmlNode propNode in showNode.ChildNodes)
            {
                XmlElements element;
                if (!Enum.TryParse <XmlElements>(propNode.Name, out element))
                {
                    continue;
                }

                string value = propNode.InnerText;
                switch (element)
                {
                case XmlElements.Seasons:     // Support for older versions
                    this.Episodes.Clear();
                    foreach (XmlNode seasNode in propNode.ChildNodes)
                    {
                        foreach (XmlNode seasPropNode in seasNode.ChildNodes)
                        {
                            if (seasPropNode.Name == "Episodes")
                            {
                                foreach (XmlNode epNode in seasPropNode.ChildNodes)
                                {
                                    TvEpisode episode = new TvEpisode(this);
                                    episode.Load(epNode);
                                    Episodes.Add(episode);
                                }
                            }
                        }
                    }
                    break;

                case XmlElements.Episodes:
                    this.Episodes.Clear();
                    foreach (XmlNode epNode in propNode.ChildNodes)
                    {
                        TvEpisode episode = new TvEpisode(this);
                        episode.Load(epNode);
                        Episodes.Add(episode);
                    }
                    break;

                case XmlElements.DoMissing:
                    bool doMissing;
                    bool.TryParse(value, out doMissing);
                    this.DoMissingCheck = doMissing;
                    break;

                case XmlElements.IncludeInSchedule:
                    bool include;
                    bool.TryParse(value, out include);
                    this.IncludeInSchedule = include;
                    break;

                case XmlElements.AlternativeNameMatches:
                    this.AlternativeNameMatches = new ObservableCollection <string>();
                    foreach (XmlNode matchNode in propNode.ChildNodes)
                    {
                        if (!string.IsNullOrWhiteSpace(matchNode.InnerText))
                        {
                            this.AlternativeNameMatches.Add(matchNode.InnerText);
                        }
                    }
                    break;

                case XmlElements.DvdEpisodeOrder:
                    bool dvdOrder;
                    bool.TryParse(value, out dvdOrder);
                    this.DvdEpisodeOrder = dvdOrder;
                    break;
                }
            }

            // Sucess
            return(true);
        }