Exemplo n.º 1
0
        public async Task AddPodcastTest()
        {
            const string title = "My Great Podcast";
            var location = new Uri("http://www.newssite.net/our-podcast");
            var image = new Uri("http://www.newssite-cdn.net/picture.jpg");

            var podcast = new Podcast
            {
                Title = title,
                Location = location,
                Image = image
            };

            await PodcastsFile.AddPodcastAsync(podcast);

            var podcasts = await PodcastsFile.ReadPodcastsAsync();

            Assert.AreEqual(1, podcasts.Count);

            var deserializedPodcast = podcasts[0];

            Assert.AreEqual(podcast.Id, deserializedPodcast.Id);
            Assert.AreEqual(podcast.Title, deserializedPodcast.Title);
            Assert.AreEqual(podcast.Location, deserializedPodcast.Location);
            Assert.AreEqual(podcast.Image, deserializedPodcast.Image);
        }
Exemplo n.º 2
0
        private async Task SaveUpdatedPodcastToFileAsync(Podcast podcast)
        {
            await File.UpdateAnObjectAsync(cast => cast.Id == podcast.Id, cast =>
            {
                cast.Update(podcast);
            });

            PodcastCache.First(cast => cast.Id == podcast.Id).Update(podcast);
        }
Exemplo n.º 3
0
        private async Task SaveNewPodcastToFileAsync(Podcast podcast)
        {
            if (PodcastCache.Any(cast => cast.Location == podcast.Location))
            {
                throw new DuplicatePodcastException(podcast.Location);
            }

            await File.AddPodcastAsync(podcast);

            PodcastCache.Add(new Podcast(podcast));
        }
Exemplo n.º 4
0
        // One does not simply deserialize a rss-xml
        private Podcast DeserializeRssDocument(XmlDocument rssDocument)
        {
            var channel = rssDocument.SelectSingleNode("//channel");

            if (channel == null)
            {
                throw new XmlException("Cannot find channel-node");
            }
            var podcast = new Podcast
            {
                Title         = channel.SelectSingleNode("title")?.InnerText,
                Description   = channel.SelectSingleNode("description")?.InnerText,
                LastBuildDate = channel.SelectSingleNode("lastBuildDate")?.InnerText,
                Generator     = channel.SelectSingleNode("generator")?.InnerText,
                ImageUrl      = channel.SelectSingleNode("image/url")?.InnerText,
                Language      = channel.SelectSingleNode("language")?.InnerText,
                Link          = channel.SelectSingleNode("link")?.InnerText,

                Itunes = new PodcastItunes
                {
                    Category = channel.ITunes("category", "text"),
                    Explicit = channel.ITunes("explicit") == "yes",
                    ImageUrl = channel.ITunes("image", "href"),
                    SubTitle = channel.ITunes("subtitle"),
                    Author   = channel.ITunes("author"),
                    Block    = channel.ITunes("block") == "yes",
                    RssType  = channel.ITunes("type"),

                    Summary = channel.ITunes("summary"),

                    Owner = new AppleItunesPerson
                    {
                        Email = channel.ITunes("itunes:owner/itunes:email"),
                        Name  = channel.ITunes("itunes:owner/itunes:name")
                    }
                }
            };

            if (!podcast.Generator.Contains("Podlove"))
            {
                _logger.LogWarning("Not generated by Podlove. Will fail most likely. But hey: good luck :)");
            }

            foreach (XmlNode episodeNode in channel.SelectNodes("item"))
            {
                podcast.Episodes.Add(GetEpisode(episodeNode));
            }



            return(podcast);
        }
Exemplo n.º 5
0
        public async Task <Podcast> GetPodcastAsync(string feedUrl)
        {
            var json = await GetChannelNodeAsync(feedUrl);

            string link               = feedUrl;
            string title              = json.title.ToString();
            string author             = json["itunes:author"]?.ToString();
            string summary            = json["itunes:summary"]?.ToString();
            string description        = json.description?.ToString();
            string imageLink          = json.image.url ?? json["itunes:image"]["@href"].ToString();
            string podcastDescription = string.Empty;

            if (description == null)
            {
                podcastDescription = summary;
            }
            else if (summary == null)
            {
                podcastDescription = description;
            }
            else
            {
                podcastDescription = description;
            }

            podcastDescription = podcastDescription.RemoveCData();

            var podcast = new Podcast(title, podcastDescription, author, link, imageLink, DateTime.Now);

            var episodes = new List <Episode>();

            var items = json.item;

            foreach (var item in items)
            {
                title = item.title.ToString();
                string subtitle = item["itunes:subtitle"].ToString();
                string path     = item.enclosure["@url"].ToString();
                author  = item["itunes:author"].ToString();
                summary = item["itunes:summary"].ToString();
                string pubDate  = item.pubDate.ToString();
                string imageUrl = item["itunes:image"] != null ? item["itunes:image"]["@href"] : imageLink;
                string guid     = item.guid.ToString();

                var episode = new Episode(title, subtitle, path, author, summary, pubDate, imageUrl, guid);
                episode.SetPodcast(podcast);
                episodes.Add(episode);
            }

            podcast.SetEpisodes(episodes.OrderByDescending(e => e.Published));
            return(podcast);
        }
Exemplo n.º 6
0
        public static async System.Threading.Tasks.Task <PodcastWithMoviesDto> CreatePodcastAsync(PodcastForCreationDto podcast)
        {
            Podcast newPodcast = new Podcast {
                Length = podcast.Length, Number = podcast.Number, RecordingDate = podcast.RecordingDate, ReleaseDate = podcast.ReleaseDate, Timestamps = new List <Timestamp>(), Title = podcast.Title, PodcastHosts = podcast.Hosts.Select(x => new PodcastHost {
                    HostId = x.Id
                }).ToList()
            };

            _context.Podcasts.Add(newPodcast);
            await _context.SaveChangesAsync();

            return(await GetPodcastAsync(newPodcast.Id));
        }
Exemplo n.º 7
0
        public async Task <IPodcastModel> GetPodcastBySlug(string slug)
        {
            if (slug == null)
            {
                throw new ArgumentNullException(nameof(slug));
            }

            Podcast podcast = await _podcastRepository.GetPodcastBySlug(slug);

            IPodcastModel podcastModel = await _podcastModelMapper.Map(podcast);

            return(podcastModel);
        }
 private void cbValjEnKategori_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         Podcast podcast  = new Podcast();
         var     kategori = cbValjEnKategori.Text;
         podcast.fyllComboboxMedPodcasts(kategori, cbValjEnPodcast);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 9
0
        public int updatePodcast(Podcast updPod)
        {
            //return query.updatePod(pod);

            int ret = query.updatePod(updPod);

            if (ret > 0)
            {
                updatePodcastsList(updPod);
            }

            return(ret);
        }
Exemplo n.º 10
0
        public FillXML(Podcast podd, List <Episode> episodeList)
        {
            System.Console.WriteLine(podd.getName());

            XElement root = new XElement("root",
                                         from ep in episodeList
                                         select new XElement("episode",
                                                             new XElement("title", ep.title),
                                                             new XElement("description", ep.description),
                                                             new XElement("duration", ep.duration)));

            root.Save(podd.getName() + ".xml");
        }
Exemplo n.º 11
0
        public PodcastAdd(Podcast podEdit)
        {
            InitializeComponent();

            this.podEdit = podEdit;

            loadPodTypes();
            retroComboBox.Enabled = false;
            retroPodAddEdit       = true;


            setPodInfo(podEdit);
        }
Exemplo n.º 12
0
        public int removePodcast(Podcast pod)
        {
            int ret = query.deletePod(pod);

            if (ret > 0)
            {
                podcasts.Remove(pod);

                removePodFromRetro(pod);
            }

            return(ret);
        }
Exemplo n.º 13
0
        private void addRetroBtn_Click(object sender, EventArgs e)
        {
            Podcast pod = null;

            using (PodcastAdd podAdd = new PodcastAdd(true))
            {
                if (podAdd.ShowDialog() == DialogResult.OK)
                {
                    newPods.Add(podAdd.GetPodcast());
                }
                loadPods();
            }
        }
Exemplo n.º 14
0
 private void dgvPod_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         if (dgvPod.SelectedRows.Count != 0)
         {
             Podcast podcast = (Podcast)dgvPod.SelectedRows[0].Tag;
             HamtaAvsnitt(podcast.AvsnittLista);
         }
     }
     catch (NullReferenceException)
     { return; }
 }
Exemplo n.º 15
0
 public List <Episode> GetAll(int index)
 {
     try
     {
         podcastList = dataManager.Deserialize();
         Podcast podcast = podcastList[index];
         episodeList = podcast.Episodes;
     }
     catch (ArgumentOutOfRangeException)
     {
     }
     return(episodeList);
 }
Exemplo n.º 16
0
        private void LogChange(int id, string action)
        {
            User     user        = authProvider.GetCurrentUser();
            DateTime timeChanged = DateTime.Now;
            Podcast  podcast     = podcastDal.GetPodcast(id.ToString());

            string eventDetail = user.Email + "," +
                                 user.Name + "," +
                                 action + "PODCAST: " +
                                 "PodcastID:  " + podcast.PodcastID;

            System.IO.File.AppendAllText(@"c:\pmlog\log.txt", (eventDetail + "\n"));
        }
Exemplo n.º 17
0
 private void ApagarPodcast()
 {
     if (this.Pronto() == false)
     {
         return;
     }
     if (this.TodosLidos() == false)
     {
         return;
     }
     p_objPodManager.Remover(p_objPodcastSelecionadoLista);
     p_objPodcastSelecionadoLista = null;
 }
Exemplo n.º 18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var    ListOfEpisodes = new List <Episode>();
            var    podcast        = new Podcast();
            var    Allfeeds       = new AllaFeeds();
            string url            = "1";

            loadPodCast(url);


            CBKatigorier();
            UpdateInterval(tbUF);
        }
Exemplo n.º 19
0
        //Används för test

        /*public async void fetchPodcasts()
         * {
         *  PodcastReader pr = new PodcastReader();
         *  //Podcast joerog = await pr.ReadPodcastRSS("http://joeroganexp.joerogan.libsynpro.com/rss");
         *  Podcast ajt = await pr.ReadPodcastRSS("http://feeds.soundcloud.com/users/soundcloud:users:118147039/sounds.rss?fbclid=IwAR0UHQZF3GhpNmuazs4-Kw7K6--IzB0AZjQQ-4QqKOmCKqQqeGi6xdMweQo");
         *  //joerog.UpdateInterval = 5;
         *  ajt.UpdateInterval = 2;
         *  PodcastCollection podColl = new PodcastCollection();
         *  //podColl.Add(joerog);
         *  podColl.Add(ajt);
         *  Debug.WriteLine(podColl[0].UpdateInterval);
         *  podColl.Serialize();
         * }*/

        public async void AddPodcast(string link, string category, int update)
        {
            PodcastReader pr     = new PodcastReader();
            Podcast       newPod = await pr.ReadPodcastRSS(link);

            newPod.UpdateInterval = update;
            newPod.Category       = category;
            PodcastCollection podColl = new PodcastCollection();

            podColl = podColl.Deserialize();
            podColl.Add(newPod);
            podColl.Serialize();
        }
        private void lstBoxPodcast_click(object sender, EventArgs e)
        {
            if (lstBoxPodcast.SelectedItem != null)
            {
                Podcast selectedItem = lstBoxPodcast.SelectedItem as Podcast;
                string  url          = selectedItem.URL;


                lstBoxEpisode.DataSource    = null;
                lstBoxEpisode.DataSource    = selectedItem.Episodes;
                lstBoxEpisode.DisplayMember = "titel";
            }
        }
Exemplo n.º 21
0
        private static void Main(string[] args)
        {
            // Creating basic demo models
            Podcast radioLabPodcast = new Podcast("Radio Lab", "Radiolab is a show about curiosity. Where sound illuminates ideas, and the boundaries blur between science, philosophy, and human experience.", "http://feeds.wnyc.org/radiolab");
            Episode episode         = new Episode(radioLabPodcast, 123, "Oliver Sacks: A Journey From Where to Where", "There’s nothing quite like the sound of someone thinking out loud, struggling to find words and ideas to match what’s in their head. Today, we are allowed to dip into the unfiltered thoughts of Oliver Sacks, one of our heroes, in the last months of his life.");

            var facade = new EpisodeFunctionalityFacade();

            facade.PlayEpisode(episode);

            Console.WriteLine("Press <Enter> to continue...");
            Console.ReadLine();
        }
Exemplo n.º 22
0
        public async Task <Podcast> AddNewPodcast(string url, string name, string category, int interval)
        {
            Podcast podcast = new Podcast();
            await Task.Run(() =>
            {
                var episodes = GetEpisodesForPodcast(url);
                Podcast p    = new Podcast(url, name, category, interval, episodes);

                podcastRepository.Create(p);
            });

            return(podcast);
        }
Exemplo n.º 23
0
        private void FillVEpisodes(Podcast podcast)
        {
            lvEpisodes.Items.Clear();
            var episodeList = podcast.Episodes;

            foreach (var e in episodeList)
            {
                ListViewItem episode = new ListViewItem();
                episode.Text = e.Title;
                episode.SubItems.Add(e.PubDate.ToString());
                lvEpisodes.Items.Add(episode);
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("id,url,titulo,descripcion,contenido,visible,prioridad,fecha_alta,imagen,archivoImagen,contenido2,visibleI,visibleC2")] Podcast podcast)
        {
            if (id != podcast.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string wwwRootPath = _hostEnvironment.WebRootPath;
                    string path        = null;

                    if (podcast.archivoImagen != null)
                    {
                        string fileName  = Path.GetFileNameWithoutExtension(podcast.archivoImagen.FileName);
                        string extension = Path.GetExtension(podcast.archivoImagen.FileName);
                        podcast.imagen = fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                        path           = Path.Combine(wwwRootPath + "/image/", fileName);

                        using (var fileStream = new FileStream(path, FileMode.Create))
                        {
                            await podcast.archivoImagen.CopyToAsync(fileStream);
                        }
                    }

                    //para los opcionales hay que hacer esta verificacion por si se activa el check pero la imagen es nulla
                    if (podcast.imagen == null && podcast.visibleI == true)
                    {
                        podcast.visibleI = false;
                    }

                    _context.Update(podcast);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PodcastExists(podcast.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(podcast));
        }
        public static async Task CreateNewEpisode(XElement title,
                                                  Podcast podcast, IEnumerable <XElement> childElements)
        {
            Logger.LogInformation("Adding Episode: " + title.Value + ". " + podcast.Id);

            var episode       = new EpisodeBuilder();
            var children      = childElements.ToList();
            var enclosure     = children.FirstOrDefault(x => x.Name == EnclosureElementName);
            var link          = children.FirstOrDefault(x => x.Name == LinkElementName);
            var publishedDate = children.FirstOrDefault(x => x.Name == PublishedDateElementName);

            //Author
            var itunesAuthor = children.FirstOrDefault(x => x.Name.LocalName == AuthorElementName);
            var author       = children.FirstOrDefault(x => x.Name == AuthorElementName);

            //Description
            var description   = children.FirstOrDefault(x => x.Name == DescriptionElementName);
            var itunesSummary = children.FirstOrDefault(x => x.Name.LocalName == SummaryElementName);
            var summary       = children.FirstOrDefault(x => x.Name == SummaryElementName);

            //Duration
            var itunesDuration = children.FirstOrDefault(x => x.Name.LocalName == DurationElementName);
            var duration       = children.FirstOrDefault(x => x.Name == DurationElementName);

            //Tags
            var keywords = children.FirstOrDefault(x => x.Name.LocalName == KeywordsElementName);
            var category = children.FirstOrDefault(x => x.Name == CategoryElementName);

            var newEpisode = episode
                             .AddTitle(title.Value)
                             .AddImageUrl(podcast.ImageUrl)
                             .AddAudioTypeAndAudioUrl(enclosure)
                             .AddSourceUrl(link)
                             .AddPodcast(podcast)
                             .AddPublishedDate(publishedDate)
                             .AddAuthor(itunesAuthor, author)
                             .AddDescription(description, itunesSummary, summary)
                             .AddAudioDuration(itunesDuration, duration)
                             .Build();

            var tempId = Guid.NewGuid().ToString();

            Episodes.Add(tempId, newEpisode);

            Logger.LogInformation("Added Episode: " + newEpisode.Title);

            var tagsFromXml = GetTagsFromXml(keywords, category);

            Logger.LogInformation("Checking for new tags for episode: " + newEpisode.Title);
            await CreateTags(newEpisode, tagsFromXml, podcast.PodcastTags, tempId).ConfigureAwait(false);
        }
Exemplo n.º 26
0
        //TODO - make retro and pod updates seperate function
        public int updatePodProdCode(Podcast updPod)
        {
            int ret = query.updatePodProdCode(updPod);

            if (ret > 0)
            {
                // update retro first
                updateRetrospectiveList(updPod);

                updatePodcastsList(updPod);
            }

            return(ret);
        }
Exemplo n.º 27
0
        public void SaveCast(Podcast p)
        {
            if (_cache == null)
            {
                _cache = new List <Podcast>();
            }

            _cache.Add(p);
            using (TextWriter _writer = new StreamWriter(FILENAME))
            {
                string output = JsonConvert.SerializeObject(_cache);
                _writer.Write(output);
            }
        }
        public bool CreatePodcast(Podcast model)
        {
            bool updateSuccesful = false;

            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();

                    SqlCommand command = new SqlCommand(SQL_CreatePodcast, connection);
                    command.Parameters.AddWithValue("@userID", 0);
                    command.Parameters.AddWithValue("@hosting", String.IsNullOrEmpty(model.Hosting)? "NULL" : model.Hosting);
                    command.Parameters.AddWithValue("@url", String.IsNullOrEmpty(model.URL) ? "NULL" : model.URL);
                    command.Parameters.AddWithValue("@title", String.IsNullOrEmpty(model.Title) ? "NULL" : model.Title);
                    command.Parameters.AddWithValue("@description", String.IsNullOrEmpty(model.Description) ? "NULL": model.Description);
                    command.Parameters.AddWithValue("@genreID", model.GenreID);
                    command.Parameters.AddWithValue("@originalRelease", model.OriginalRelease);
                    command.Parameters.AddWithValue("@runTime", String.IsNullOrEmpty(model.RunTime) ? "NULL" : model.RunTime);
                    command.Parameters.AddWithValue("@releaseFrequency", String.IsNullOrEmpty(model.ReleaseFrequency) ? "NULL" : model.ReleaseFrequency);
                    command.Parameters.AddWithValue("@averageLength",
                                                    String.IsNullOrEmpty(model.AverageLength) ? "NULL" : model.AverageLength);
                    command.Parameters.AddWithValue("@episodeCount", model.EpisodeCount);
                    command.Parameters.AddWithValue("@downloadCount", model.DownloadCount);
                    command.Parameters.AddWithValue("@measurementPlatform",
                                                    String.IsNullOrEmpty(model.MeasurementPlatform) ? "NULL" : model.MeasurementPlatform);
                    command.Parameters.AddWithValue("@demographic",
                                                    String.IsNullOrEmpty(model.Demographic) ? "NULL" : model.Demographic);
                    command.Parameters.AddWithValue("@affiliations",
                                                    String.IsNullOrEmpty(model.Affiliations) ? "NULL" : model.Affiliations);
                    command.Parameters.AddWithValue("@broadcastCity",
                                                    String.IsNullOrEmpty(model.BroadcastCity) ? "NULL" : model.BroadcastCity);
                    command.Parameters.AddWithValue("@broadcastState",
                                                    String.IsNullOrEmpty(model.BroadcastState) ? "NULL" : model.BroadcastState);
                    command.Parameters.AddWithValue("@inOhio", model.InOhio);
                    command.Parameters.AddWithValue("@isSponsored", model.IsSponsored);
                    command.Parameters.AddWithValue("@sponsor", String.IsNullOrEmpty(model.Sponsor) ? "NULL" : model.Sponsor);

                    updateSuccesful = (command.ExecuteNonQuery() > 0) ? true : false;
                }
            }

            catch (SqlException ex)
            {
                string exception = ex.ToString();
                updateSuccesful = false;
            }

            return(updateSuccesful);
        }
Exemplo n.º 29
0
        public async Task <IActionResult> PodcastEdit(int id, PodcastEditList model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = null;
                string path           = null;
                if (model.Audio != null)
                {
                    string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "music/1");
                    uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Audio.FileName;
                    path           = "/music/1/" + uniqueFileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                    model.Audio.CopyTo(new FileStream(filePath, FileMode.Create));
                }
                else
                {
                    path = GetAudioPath(id);
                }

                Podcast podcast = new Podcast
                {
                    Id            = id,
                    AuthorID      = model.AuthorID,
                    Name          = model.Name,
                    Description   = model.Description,
                    Audio         = path,
                    RecordingDate = model.RecordingDate
                };

                try
                {
                    db.Update(podcast);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PodcastExists(podcast.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                var authorName = db.Authors.Where(p => p.Id == podcast.AuthorID).ToList()[0].Name;
                return(RedirectToAction("PodcastsShow", new { name = authorName }));
            }
            return(View(model));
        }
Exemplo n.º 30
0
        public IActionResult New(NewPodcastDTO newPodcast)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var podcast = new Podcast(newPodcast.Url, newPodcast.Contains, newPodcast.Duration);

            _podcastRepository.Add(podcast);
            _podcastRepository.Save();

            return(RedirectToAction(nameof(Created), new { podcast.Id }));
        }
        // GET: Podcast/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Podcast podcast = db.Podcasts.Find(id);

            if (podcast == null)
            {
                return(HttpNotFound());
            }
            return(View(podcast));
        }
Exemplo n.º 32
0
        private void Unsubscribe_Click(object sender, RoutedEventArgs e)
        {
            var Unsubscribe = new Core.MessageBox("Unsubscribe from this podcast?", "Are you certain you wish to unsubscribe from " + SelectedPodcast.Title);

            if (Unsubscribe.ShowDialog() == true)
            {
                var Cast = DB.Podcasts.Find(SelectedPodcast.Id);
                DB.Entry(Cast).State = EntityState.Deleted;
                DB.SaveChanges();
                SelectedPodcast = null;
                RefreshDescription("", "", "");
                RefreshPodcasts();
            }
        }
Exemplo n.º 33
0
        public async void SkapaPodcastObjekt(Dictionary <string, object> podcastProperties)
        {
            string namn = podcastProperties["Namn"].ToString();
            string url  = podcastProperties["URL"].ToString();
            int    uppdateringsFrekvens = (int)podcastProperties["Uppdateringsfrekvens"];
            string kategori             = podcastProperties["Kategori"].ToString();

            List <Avsnitt> avsnitt = await avsnittRepository.HamtaAllaAvsnitt(url);

            DateTime nextUpdate = DateTime.Now;
            Podcast  newPodcast = new Podcast(namn, url, uppdateringsFrekvens, kategori, avsnitt, nextUpdate);

            podcastRepository.Skapa(newPodcast);
        }
Exemplo n.º 34
0
        public ActionResult Create(Podcast podcast)
        {
            if (ModelState.IsValid)
            {
                podcast = PopulatePodcastWithRSS(podcast.RSSURI);

                if (podcast != null)
                {
                    db.Podcasts.Add(podcast);
                    db.SaveChanges();
                }
                return RedirectToAction("Index");
            }

            return View(podcast);
        }
        public async Task<Podcast> GetPodcastAsync(string feedUrl)
        {
            var xml = await client.GetStringAsync(feedUrl);

            var xmlDocument = XDocument.Parse(xml);

            var title = xmlDocument.Element("rss").Element("channel").Element("title").Value;
            XNamespace itunes = "http://www.itunes.com/dtds/podcast-1.0.dtd";
            var items = xmlDocument.Element("rss").Element("channel").Elements("item");
            var description = xmlDocument.Element("rss").Element("channel").Element("description").Value;
            var summary = xmlDocument.Element("rss").Element("channel").Element(itunes + "summary").Value;
            var imageLink = xmlDocument.Element("rss").Element("channel").Element(itunes + "image").Attribute("href").Value;
            var author = xmlDocument.Element("rss").Element("channel").Element(itunes + "author").Value;
            string podcastDescription = string.Empty;

            if (description == null)
                podcastDescription = summary;
            else if (summary == null)
                podcastDescription = description;
            else
                podcastDescription = description;

            podcastDescription = podcastDescription.RemoveCData();

            var podcast = new Podcast(title, podcastDescription, author, feedUrl, imageLink, DateTime.Now);

            var episodes = new List<Episode>();

            foreach (var item in items)
            {
                title = item.Element("title").Value;
                var subtitle = item.Element(itunes + "subtitle").Value;
                var path = item.Element("enclosure").Attribute("url").Value;
                author = item.Element(itunes + "author").Value;
                summary = item.Element(itunes + "summary").Value;
                var pubDate = item.Element("pubDate").Value;
                var imageUrl = item.Element(itunes + "image") != null ? item.Element(itunes + "image").Attribute("href").Value : imageLink;
                var guid = item.Element("guid").Value;

                var episode = new Episode(title, subtitle, path, author, summary, pubDate, imageUrl, guid);
                episode.SetPodcast(podcast);
                episodes.Add(episode);
            }

            podcast.SetEpisodes(episodes);
            return podcast;
        }
Exemplo n.º 36
0
        public async Task<Podcast> GetPodcastAsync(string feedUrl)
        {
            var json = await GetChannelNodeAsync(feedUrl);

            string link = feedUrl;
            string title = json.title.ToString();
            string author = json["itunes:author"]?.ToString();
            string summary = json["itunes:summary"]?.ToString();
            string description = json.description?.ToString();
            string imageLink = json.image.url ?? json["itunes:image"]["@href"].ToString();
            string podcastDescription = string.Empty;

            if (description == null)
                podcastDescription = summary;
            else if (summary == null)
                podcastDescription = description;
            else
                podcastDescription = description;

            podcastDescription = podcastDescription.RemoveCData();

            var podcast = new Podcast(title, podcastDescription, author, link, imageLink, DateTime.Now);

            var episodes = new List<Episode>();

            var items = json.item;

            foreach (var item in items)
            {
                title = item.title.ToString();
                string subtitle = item["itunes:subtitle"].ToString();
                string path = item.enclosure["@url"].ToString();
                author = item["itunes:author"].ToString();
                summary = item["itunes:summary"].ToString();
                string pubDate = item.pubDate.ToString();
                string imageUrl = item["itunes:image"] != null ? item["itunes:image"]["@href"] : imageLink;
                string guid = item.guid.ToString();

                var episode = new Episode(title, subtitle, path, author, summary, pubDate, imageUrl, guid);
                episode.SetPodcast(podcast);
                episodes.Add(episode);
            }

            podcast.SetEpisodes(episodes.OrderByDescending(e=>e.Published));
            return podcast;
        }
Exemplo n.º 37
0
        public async Task<IEnumerable<Episode>> GetNewEpisodesAsync(Podcast podcast)
        {
            try
            {
                Podcast newPodcast = await feedParser.GetPodcastAsync(podcast.FeedUrl.ToString());
                var newEpisodes = new List<Episode>();

                foreach (var episode in newPodcast.Episodes)
                {
                    if (!podcast.Episodes.Contains(episode))
                    {
                        newEpisodes.Add(episode);
                    }
                }

                return newEpisodes.OrderBy(e => e.Published);
            }
            catch (Exception ex)
            {
                throw new GetPodcastException(podcast.FeedUrl.ToString(), ex);
            }
        }
Exemplo n.º 38
0
        protected override void ParseSubscription()
        {
            if (txtName.Text.Trim() == "" || txtURL.Text.Trim() == "")
            {
                MessageBox.Show(i18n.FillPodcastNameAndUrlFieldsMessage, i18n.AllFieldsRequiredTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.OnSubscriptionParsed(new SubscriptionParsedEventArgs(false));
                return;
            }

            if (Subscriptions.Instance.Dictionary.ContainsKey(txtURL.Text))
            {
                MessageBox.Show(string.Format(i18n.PodcastSubscriptionAlreadyExists, Subscriptions.Instance.Dictionary[txtURL.Text].Name), i18n.SubscriptionExists, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.OnSubscriptionParsed(new SubscriptionParsedEventArgs(false));
                return;
            }

            try
            {
                var subscription = new PodcastSubscription {Name = txtName.Text, Url = txtURL.Text};
                using (var podcast = new Podcast(subscription))
                {
                    if (!podcast.IsValid())
                    {
                        MessageBox.Show(i18n.ErrorParsingPodcastMessage, i18n.ErrorParsingPodcastTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.OnSubscriptionParsed(new SubscriptionParsedEventArgs(false));
                        return;
                    }
                }

                this.OnSubscriptionParsed(new SubscriptionParsedEventArgs(true, subscription));
            }
            catch(Exception)
            {
                MessageBox.Show(i18n.ErrorParsingPodcastMessage, i18n.ErrorParsingPodcastTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.OnSubscriptionParsed(new SubscriptionParsedEventArgs(false));
            }
        }
Exemplo n.º 39
0
        private async Task<List<Podcast>> AddPodcastsSeriallyAsync(PodcastsFile file, int numPodcasts)
        {
            var podcasts = new List<Podcast>();
            var random = new Random();

            foreach (var i in Enumerable.Range(0, numPodcasts))
            {
                var podcast = new Podcast
                {
                    Title = GetRandomString(random),
                    Location = GetRandomUrl(random, "podcast.xml"),
                };

                // only set Image sometimes
                if (random.NextDouble() > 0.5)
                    podcast.Image = GetRandomUrl(random, "album.png");

                await file.AddPodcastAsync(podcast);

                podcasts.Add(podcast);
            }

            return podcasts;
        }
Exemplo n.º 40
0
        private Podcast GetPodcastData(HtmlNode node)
        {
            Podcast returnPodcast = new Podcast();

            List<HtmlNode> nodes = new List<HtmlNode>();
            nodes = node.DescendantsAndSelf().ToList<HtmlNode>();

            try { returnPodcast.Title = GetTitle(node.ChildNodes.FindFirst("h3")); }
            catch (Exception) { }

            try { returnPodcast.EpisodeUri = GetEpisodeUri(node.ChildNodes.FindFirst("h3")); }
            catch (Exception) { }

            try { returnPodcast.Uri = GetUri(node.ChildNodes.FindFirst("audio")); }
            catch (Exception) { }

            try { returnPodcast.BibleReference = GetBibleReference(node.SelectSingleNode("p[@class='metadata']")); }
            catch (Exception) { }

            try
            {
                returnPodcast.Description = GetDescription(node,
                                              returnPodcast.BibleReference,
                                              node.SelectSingleNode("p[@class='metadata']").ChildNodes[0].InnerText);
            }
            catch (Exception) { }

            //returnPodcast.Length = GetPodcastLength(returnPodcast.Uri);

            return returnPodcast;
        }
Exemplo n.º 41
0
 public async Task SavePodcastAsync(Podcast podcast)
 {
     await storageService.SaveAsync(podcast);
 }
Exemplo n.º 42
0
    /// <summary>
    /// Add Podcast List To Collection
    /// </summary>
    protected void AddToCollection()
    {
        if (hdnPodcastCollection.Value != string.Empty)
        {
            string strCollectionData = hdnPodcastCollection.Value.Substring(1);

            if (strCollectionData.Length > 0)
            {
                string[] strPodcastList = strCollectionData.Split('~');
                int Recordcount = PodcastCollection.Count;
                if (strPodcastList.Length > 0)
                {
                    for (int i = 0; i < strPodcastList.Length; i++)
                    {
                        string[] strPodcastProperty = strPodcastList[i].Split('|');
                        if (strPodcastProperty.Length > 0)
                        {
                            Podcast newPodcast = new Podcast();
                            newPodcast.TrackId = strPodcastProperty[0].ToString();
                            newPodcast.TrackName = strPodcastProperty[1].ToString();
                            newPodcast.CollectionName = strPodcastProperty[2].ToString();
                            newPodcast.ArtistName = strPodcastProperty[3].ToString();
                            newPodcast.TrackViewUrl = strPodcastProperty[4].ToString();
                            newPodcast.ArtworkUrl60 = strPodcastProperty[5].ToString();
                            newPodcast.ArtworkUrl100 = strPodcastProperty[6].ToString();
                            newPodcast.DisplayOrder = Recordcount + i;
                            PodcastCollection.Add(newPodcast);
                        }
                    }
                    BindCollection();

                    //save collection as string
                    this.PodcastCollection = PodcastCollection;

                    _host.SaveWidgetDataMembers();
                }
            }
        }
    }
Exemplo n.º 43
0
        public async Task<PodcastFeed> GetPodcastFeedAsync(Podcast podcast)
        {
            await LoadFileAsync();

            var results = await EvaluatePodcastFeedAsync(podcast.Location);

            if (results.RedirectUri != null)
            {
                var record = new Podcast(podcast);
                record.Location = results.RedirectUri;
                await SaveUpdatedPodcastToFileAsync(record);
                podcast.Update(record);
            }

            return results.Feed;
        }
Exemplo n.º 44
0
        private Podcast PopulatePodcastWithRSS(string rssURL)
        {
            Podcast podcast = null;

            try
            {
                var reader = XmlReader.Create(rssURL);
                var feed = SyndicationFeed.Load(reader);

                podcast = new Podcast
                {
                    RSSURI = rssURL,
                    Name = feed.Title.Text,
                    ArtworkURI = feed.ImageUrl.AbsoluteUri,
                    Description = feed.Description.Text
                };
            }
            catch { }

            return podcast;
        }
Exemplo n.º 45
0
 public ActionResult Edit(Podcast podcast)
 {
     if (ModelState.IsValid)
     {
         db.Entry(podcast).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(podcast);
 }
Exemplo n.º 46
0
        public async Task<Podcast> AddPodcastAsync(Uri podcastUri)
        {
            await LoadFileAsync();

            var results = await EvaluatePodcastFeedAsync(podcastUri);

            if (results.RedirectUri != null)
            {
                podcastUri = results.RedirectUri;
            }

            var feed = results.Feed;

            var podcast = new Podcast
            {
                Title = feed.Title,
                Location = podcastUri,
                Image = feed.Image.Url,
            };

            await SaveNewPodcastToFileAsync(podcast);

            using (var subscription = new SubscriptionService(new Uri("http://localhost:3333"), new BasicAuthStrategy("my_user", "password")))
            {
                await subscription.PostSubscriptionAsync(podcast.Location.AbsoluteUri);
            }

            return podcast;
        }