예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("EpisodeID,Title,Season,Episode,Description,PodcastDate,Genre,Link,Image,Language,Authors,Explicit,PodcastID")] PodcastEpisode podcastEpisode)
        {
            if (id != podcastEpisode.EpisodeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(podcastEpisode);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PodcastEpisodeExists(podcastEpisode.EpisodeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PodcastID"] = new SelectList(_context.Podcasts, "PodcastID", "PodcastID", podcastEpisode.PodcastID);
            return(View(podcastEpisode));
        }
        public async Task <IActionResult> PutPodcastEpisode([FromQuery] int id, [FromBody] PodcastEpisode podcastEpisode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != podcastEpisode.Id)
            {
                return(BadRequest());
            }

            _context.Entry(podcastEpisode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PodcastEpisodeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        private static IEnumerable <PodcastEpisode> GetRSS2Episodes(XmlNodeList entries, string editor)
        {
            int episodeNumber = entries.Count;

            foreach (XmlNode entry in entries)
            {
                PodcastEpisode episode = new PodcastEpisode();
                episode.EpisodeNumber = episodeNumber--;
                episode.Editor        = editor;
                episode.Title         = GetXmlElementValue(entry, "title");
                episode.Summary       = GetXmlElementValue(entry, "description");
                string link = GetXmlElementValue(entry, "link");
                if (entry["enclosure"] != null)
                {
                    link = GetXmlAttribute(entry["enclosure"], "url");
                }
                episode.FileUrl = new Uri(link);
                string date = GetXmlElementValue(entry, "pubDate");
                DateTime.TryParse(date, out DateTime pubDate);
                episode.PublishedDate = pubDate;
                string durationString = GetXmlElementValue(entry, "itunes:duration");
                TryParseDuration(durationString, out TimeSpan duration);
                episode.Duration = duration;
                episode.InnerXml = entry.InnerXml;
                yield return(episode);
            }
        }
예제 #4
0
        public async Task <IActionResult> Create(PodcastEpisode podcastepisode)
        {
            //Ignore user from model state
            ModelState.Remove("podcastepisode.User");

            //This creates a new variable to hold our current instance of the ActiveCustomer class and then sets the active customer's id to the CustomerId property on the product being created so that a valid model is sent to the database
            var user = await GetCurrentUserAsync();

            if (podcastepisode.PodcastChannelId == 0)
            {
                return(RedirectToAction("Create"));
            }

            if (podcastepisode.PodcastChannelId == 1)
            {
                return(RedirectToAction("ChannelCreate"));
            }

            if (ModelState.IsValid)
            {
                podcastepisode.User = user;
                context.Add(podcastepisode);
                await context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            PodcastCreateViewModel model = new PodcastCreateViewModel(context, user);

            return(View(model));
        }
예제 #5
0
        public async Task <IActionResult> Edit(string id, [Bind("EpisodeType,PodcastId,Season,EpisodeNumber,Title,Description,ImageUrl,Link,Length,Type,Url,Guide,Publicationdate,Duration,ExplicitBool")] PodcastEpisode podcastEpisode)
        {
            if (id != podcastEpisode.Guide)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(podcastEpisode);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PodcastEpisodeExists(podcastEpisode.Guide))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PodcastId"] = new SelectList(_context.Podcasts, "PodcastId", "PodcastId", podcastEpisode.PodcastId);
            return(View(podcastEpisode));
        }
예제 #6
0
        private void PlayEpisode(PodcastEpisode episode)
        {
            _currentPodcast = episode;
            _mediaPlayerWrapper.PlayEpisode(_currentPodcast.EpisodeControlData);
            OnPropertyChanged("PodcastDescription");

            UpdateDescription();
        }
 public TheAssetPodcastEpisodePage(PodcastEpisode episode, string title)
 {
     InitializeComponent();
     BindingContext = new PodcastEpisodeViewModel(episode)
     {
         Title = title
     };
 }
예제 #8
0
        private static async Task UpdateStatus()
        {
            try
            {
                if (Uri.TryCreate(new Uri(Config.Instance.ConfigObject.VlcRootUrl), $"/requests/status.xml", out var uri))
                {
                    var statusString = await SendRequest(uri);

                    var status = ParseStatus(statusString);
                    if (status.FileInfo != null && (status.State == PlayingState.Playing || status.State == PlayingState.Paused))
                    {
                        PodcastEpisode ep = new PodcastEpisode();
                        foreach (var podcast in Config.Instance.EpisodeList.Episodes)
                        {
                            ep = podcast.Value.Values.FirstOrDefault(x => x.FileName == status.FileInfo.FileName || x.Title == status.FileInfo.FileName);
                            if (ep != null)
                            {
                                break;
                            }
                        }
                        if (ep != null)
                        {
                            ep.Progress.Length   = status.Length > 0 ? new TimeSpan(0, 0, status.Length) : ep.Progress.Length;
                            ep.Progress.Progress = status.Position > 0 ? status.Position : (status.Time / status.Length);
                            Config.Instance.SaveConfig();
                            var existingArt = PodcastFunctions.CheckForPodcastAlbumArt(ep.PodcastShortCode);
                            if (!string.IsNullOrWhiteSpace(existingArt) && File.Exists(existingArt))
                            {
                                PodcastFunctions.PlayingAlbumArt = $"file:///{(existingArt.Replace("\\", "/"))}";
                            }
                            else if (!string.IsNullOrWhiteSpace(status.FileInfo.ArtworkUrl))
                            {
                                PodcastFunctions.PlayingAlbumArt = status.FileInfo.ArtworkUrl;
                            }
                            else
                            {
                                PodcastFunctions.PlayingAlbumArt = null;
                            }
                            PodcastFunctions.PlayingState   = status.State;
                            PodcastFunctions.PlayingEpisode = ep;
                        }

                        _nextUpdate = DateTime.UtcNow + _playingNextTime;
                    }
                    else if (status.State == PlayingState.Stopped)
                    {
                        PodcastFunctions.PlayingAlbumArt = "";
                        PodcastFunctions.PlayingState    = status.State;
                        PodcastFunctions.PlayingEpisode  = null;
                        _nextUpdate = DateTime.UtcNow + _defaultNextTime;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorTracker.CurrentError = ex.Message;
            }
        }
        public async Task <IActionResult> PostPodcastEpisode([FromBody] PodcastEpisode podcastEpisode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.PodcastEpisode.Add(podcastEpisode);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPodcastEpisode", new { id = podcastEpisode.Id }, podcastEpisode));
        }
예제 #10
0
        public async Task <IActionResult> Create([Bind("EpisodeID,Title,Season,Episode,Description,PodcastDate,Genre,Link,Image,Language,Authors,Explicit,PodcastID")] PodcastEpisode podcastEpisode)
        {
            if (ModelState.IsValid)
            {
                _context.Add(podcastEpisode);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PodcastID"] = new SelectList(_context.Podcasts, "PodcastID", "PodcastID", podcastEpisode.PodcastID);
            return(View(podcastEpisode));
        }
예제 #11
0
        public async Task <IActionResult> Create([Bind("EpisodeType,PodcastId,Season,EpisodeNumber,Title,Description,ImageUrl,Link,Length,Type,Url,Guide,Publicationdate,Duration,ExplicitBool")] PodcastEpisode podcastEpisode)
        {
            if (ModelState.IsValid)
            {
                _context.Add(podcastEpisode);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PodcastId"] = new SelectList(_context.Podcasts, "PodcastId", "PodcastId", podcastEpisode.PodcastId);
            return(View(podcastEpisode));
        }
예제 #12
0
        public async Task <PodcastEpisode> SearchEpisodeAsync(string resId)
        {
            var res = await _client.GetEpisodeByIdAsync(resId);

            var episode = new PodcastEpisode(res)
            {
                IsDownloaded = await _fileService.CheckIfMediaFileExists(resId + ".mp3")
            };

            episode.Podcast = new Podcast(res.Podcast, new[] { episode });
            return(episode);
        }
예제 #13
0
        private void ShowEpisodes(List <EpisodeControl> orderedByDateList)
        {
            foreach (EpisodeControl x in orderedByDateList)
            {
                if (x.Hidden)
                {
                    continue;
                }

                PodcastEpisode pce = new PodcastEpisode();
                pce.EpisodeControlData = x;
                pce.ShowName           = x.ShowName;
                _podcasts.Add(pce);
            }

            EpisodesItems.ItemsSource = _podcasts;
        }
예제 #14
0
        private static IEnumerable <PodcastEpisode> GetAtomEpisodes(XmlNodeList entries)
        {
            int episodeNumber = entries.Count;

            foreach (XmlNode entry in entries)
            {
                PodcastEpisode episode = new PodcastEpisode();
                episode.EpisodeNumber = episodeNumber--;
                episode.Title         = GetXmlElementValue(entry, "title");
                episode.Summary       = GetXmlElementValue(entry, "summary");
                DateTime.TryParse(GetXmlElementValue(entry, "updated"), out DateTime pub);
                episode.PublishedDate = pub;
                episode.FileUrl       = new Uri(GetXmlAttribute(entry["link"], "href"));
                episode.InnerXml      = entry.InnerXml;
                yield return(episode);
            }
        }
        public async Task <IActionResult> Create(int id, PodcastEpisodeCreateViewModel vm)
        {
            var episode = new PodcastEpisode
            {
                EpisodeNumber          = vm.EpisodeNumber,
                EpisodeTitle           = vm.EpisodeName,
                NormalizedEpisodeTitle = vm.EpisodeName.ToUpper(),
                Duration  = vm.Duration,
                Link      = vm.Url,
                PodcastId = id
            };

            await _applicationDbContext.PodcastEpisodes.AddAsync(episode);

            await _applicationDbContext.SaveChangesAsync();

            return(RedirectToAction("Detail", "Podcast", new { Id = id }));
        }
예제 #16
0
        private static IEnumerable <PodcastEpisode> GetRSS1Episodes(XmlNodeList entries)
        {
            int episodeNumber = entries.Count;

            foreach (XmlNode entry in entries)
            {
                PodcastEpisode episode = new PodcastEpisode();
                episode.EpisodeNumber = episodeNumber--;
                episode.Editor        = GetXmlElementValue(entry, "author");
                episode.Title         = GetXmlElementValue(entry, "title");
                episode.Summary       = GetXmlElementValue(entry, "description");
                episode.FileUrl       = new Uri(GetXmlElementValue(entry, "link"));
                DateTime.TryParse(GetXmlElementValue(entry, "pubDate"), out DateTime pubDate);
                episode.PublishedDate = pubDate;
                episode.InnerXml      = entry.InnerXml;
                yield return(episode);
            }
        }
예제 #17
0
        private void FetchPodcastEpisodes(int podcastId)
        {
            Podcast podcast = db.Podcasts.Find(podcastId);

            if (podcast == null)
            {
                return;
            }

            var  reader      = XmlReader.Create(podcast.RSSURI);
            var  feed        = SyndicationFeed.Load(reader);
            bool saveChanges = false;

            foreach (SyndicationItem episode in feed.Items)
            {
                // We assume if we find a match we're done updating
                if (db.PodcastEpisodes.Where(pe => pe.PodcastId == podcastId && pe.Name == episode.Title.Text).FirstOrDefault() != null)
                {
                    break;
                }

                SyndicationLink fileLocation = episode.Links.Where(l => l.Length > 0).FirstOrDefault();
                if (fileLocation == null)
                {
                    continue;
                }

                PodcastEpisode podcastEpisode = new PodcastEpisode
                {
                    Name         = episode.Title.Text,
                    FileLocation = fileLocation.Uri.AbsoluteUri,
                    PublishDate  = episode.PublishDate,
                    Summary      = episode.Summary.Text
                };

                podcast.Episodes.Add(podcastEpisode);
                saveChanges = true;
            }

            if (saveChanges)
            {
                db.SaveChanges();
            }
        }
예제 #18
0
    public async Task<PodcastEpisode> SaveTimeAsync(PodcastEpisode ep)
    {
      try
      {
        //Check to see if the podcast already exists, if Id is set.
        //then update it, else insert.
        if (!string.IsNullOrWhiteSpace(ep.Id))
        {
          await podcastTable.UpdateAsync(ep);
        }
        else
        {
          await podcastTable.InsertAsync(ep);
        }

        //return the episode back with the updated Id
        return ep;
      }
      catch (Exception ex)
      {
      }
      return null;
    }
예제 #19
0
        public Task <List <PodcastEpisode> > GetPodcastEpisodesAsync(Podcast podcast, bool theAsset, bool forceRefresh)
        {
            List <PodcastEpisode> podcastEpisodes = new List <PodcastEpisode>();

            XmlDocument xmldoc = theAsset ? GetTheAssetXmlDocument(forceRefresh) : GetTrumpIncXmlDocument(forceRefresh);

            XmlNodeList xmlNodeList = xmldoc.SelectNodes("//rss/channel/item");

            foreach (XmlNode xmlNode in xmlNodeList)
            {
                PodcastEpisode podcastEpisode = new PodcastEpisode
                {
                    ArtworkUrl  = podcast.Art,
                    Date        = xmlNode.SelectSingleNode("pubDate")?.InnerText,
                    Description = GetValue(xmlNode, "itunes:summary"),
                    //DisplayDate - This is a property based on Date
                    Duration      = GetValue(xmlNode, "itunes:duration"),
                    EpisodeNumber = GetValue(xmlNode, "itunes:episode"),
                    Explicit      = GetValue(xmlNode, "itunes:explicit"),
                    //Id = Guid.NewGuid().ToString(),
                    Mp3Url      = xmlNode.SelectSingleNode("enclosure")?.Attributes["url"].Value,
                    Title       = xmlNode.SelectSingleNode("title")?.InnerText,
                    PodcastName = podcast.Title
                };
                if (theAsset)
                {
                    podcastEpisode.EpisodeUrl = $"https://theassetpodcast.org/episode/{podcastEpisode.Title.ToLower().Replace(' ', '-')}/";
                }
                else
                {
                    podcastEpisode.EpisodeUrl = $"https://www.wnycstudios.org/podcasts/trumpinc/episodes/{podcastEpisode.Title.ToLower().Replace(' ', '-')}/";
                }
                podcastEpisodes.Add(podcastEpisode);
            }
            return(Task.FromResult(podcastEpisodes));
        }
예제 #20
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new ApplicationDbContext(serviceProvider.GetRequiredService <DbContextOptions <ApplicationDbContext> >()))
            {
                // Look for any episodes.
                if (context.PodcastEpisode.Any())
                {
                    return; // DB has been seeded
                }

                // add channels


                var channels = new PodcastChannel[]
                {
                    new PodcastChannel {
                        ChannelName = "The Joe Rogan Experience"
                    },
                    new PodcastChannel {
                        ChannelName = "The Tim Ferriss Show"
                    },
                    new PodcastChannel {
                        ChannelName = "Dan Carlin's Hardcore History"
                    }
                };

                foreach (PodcastChannel c in channels)
                {
                    context.PodcastChannel.Add(c);
                }
                context.SaveChanges();



                // add episodes

                var episodes = new PodcastEpisode[]
                {
                    new PodcastEpisode {
                        EpisodeName      = "#310 - Neil DeGrasse Tyson",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "The Joe Rogan Experience").PodcastChannelId
                    },
                    new PodcastEpisode {
                        EpisodeName      = "#801 - Gary Johnson",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "The Joe Rogan Experience").PodcastChannelId
                    },
                    new PodcastEpisode {
                        EpisodeName      = "#763 - Action Bronson",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "The Joe Rogan Experience").PodcastChannelId
                    },
                    new PodcastEpisode {
                        EpisodeName      = "Episode 1: Kevin Rose",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "The Tim Ferriss Show").PodcastChannelId
                    },
                    new PodcastEpisode {
                        EpisodeName      = "Episode 2: Joshua Waitzkin",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "The Tim Ferriss Show").PodcastChannelId
                    },
                    new PodcastEpisode {
                        EpisodeName      = "Ep. 14: Sam Harris, PhD - Spirituality, Neuroscienece, Meditation, and More",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "The Tim Ferriss Show").PodcastChannelId
                    },
                    new PodcastEpisode {
                        EpisodeName      = "Show 56 - King of Kings",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "Dan Carlin's Hardcore History").PodcastChannelId
                    },
                    new PodcastEpisode {
                        EpisodeName      = "Show 50 - Blueprint for Armageddon",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "Dan Carlin's Hardcore History").PodcastChannelId
                    },
                    new PodcastEpisode {
                        EpisodeName      = "Show 43 - Wrath of the Khans",
                        PodcastChannelId = channels.Single(s => s.ChannelName == "Dan Carlin's Hardcore History").PodcastChannelId
                    }
                };

                foreach (PodcastEpisode e in episodes)
                {
                    context.PodcastEpisode.Add(e);
                }
                context.SaveChanges();



                //   var products = new Product[]
                //   {
                //       new Product {
                //           Description = "Colorful throw pillows to liven up your home",
                //           ProductTypeId = productTypes.Single(s => s.Label == "Housewares").ProductTypeId,
                //           Title = "Throw Pillow",
                //           Price = 7.49,
                //           CustomerId = customers.Single(s => s.FirstName == "Tractor").CustomerId
                //       },
                //       new Product {
                //           Description = "A 2012 iPod Shuffle. Headphones are included. 16G capacity.",
                //           ProductTypeId = productTypes.Single(s => s.Label == "Electronics").ProductTypeId,
                //           Title = "iPod Shuffle",
                //           Price = 18.00,
                //           CustomerId = customers.Single(s => s.FirstName == "Steve").CustomerId
                //       },
                //       new Product {
                //           Description = "Stainless steel refrigerator. Three years old. Minor scratches.",
                //           ProductTypeId = productTypes.Single(s => s.Label == "Appliances").ProductTypeId,
                //           Title = "Samsung refrigerator",
                //           Price = 500.00,
                //           CustomerId = customers.Single(s => s.FirstName == "Carson").CustomerId
                //       }
                //   };

                //   foreach (Product i in products)
                //   {
                //       context.Product.Add(i);
                //   }
                //   context.SaveChanges();
            }
        }
예제 #21
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.PodcastDetail);

            var showNumber = Intent.GetIntExtra("show_number", 0);

            episode = Activity1.ViewModel.GetPodcast(showNumber);


            var description = FindViewById <TextView>(Resource.Id.descriptionView);

            description.Text = episode.Description;

            var play  = FindViewById <Button>(Resource.Id.playButton);
            var pause = FindViewById <Button>(Resource.Id.pauseButton);
            var stop  = FindViewById <Button>(Resource.Id.stopButton);

            seekBar       = FindViewById <SeekBar>(Resource.Id.seekBar1);
            status        = FindViewById <TextView>(Resource.Id.statusText);
            updateHandler = new Handler();

            player = new MediaPlayer();
            player.SetDataSource(this, Android.Net.Uri.Parse(episode.AudioUrl));
            player.PrepareAsync();

            player.Prepared += (sender, e) =>
            {
                initialized = true;
                player.SeekTo(timeToSet * 1000);
                UpdateStatus();
            };

            play.Click += (sender, e) =>
            {
                player.Start();
                updateHandler.PostDelayed(UpdateStatus, 1000);
            };

            pause.Click += (sender, e) => player.Pause();

            stop.Click += (sender, e) =>
            {
                player.Stop();
                player.Reset();
                player.SetDataSource(this, Android.Net.Uri.Parse(episode.AudioUrl));
                player.Prepare();
            };

            seekBar.ProgressChanged += (sender, e) =>
            {
                if (!e.FromUser)
                {
                    return;
                }

                player.SeekTo((int)(player.Duration * ((float)seekBar.Progress / 100.0)));
            };

            var updated = await episode.GetTimeAsync();

            if (updated == null || updated.ShowNumber != episode.ShowNumber)
            {
                return;
            }

            if (initialized && player != null)
            {
                player.SeekTo(updated.CurrentTime * 1000);
                UpdateStatus();
            }
            else
            {
                timeToSet = updated.CurrentTime;
            }
        }
예제 #22
0
 public PodcastEpisodeViewModel(PodcastEpisode episode) :
     this()
 {
     Episode = episode;
 }