Exemplo n.º 1
0
        public static RssHelper DoFeed(Feed feed)
        {
            Debug.WriteLine("feed url :>> {0}", feed.Url);

            var inst = new RssHelper();

            inst.DnldRssAndParseToGetAllCasts(feed);

            return(inst);
        }
Exemplo n.º 2
0
        public static RssHelper FindNewCasts(Feed feed)
        {
            try
            {
                Debug.WriteLine("~> {0,-32}   {1,5} casts,    LatestRssText.Length={2,5:N0} kb", feed.Name, feed.DnLds.Count, .001 * feed.LatestRssText.Length);

                var inst = new RssHelper();
                inst.ParseRssToGetAllCasts(feed);
                return(inst);
            }
            catch (Exception ex) { ex.Log(); throw; }
        }
Exemplo n.º 3
0
        void doSyndItem(Feed feed, SyndicationItem si)
        {
            //Debug.WriteLine("  Pub Date \t Title:  \t{0} \t\t {1} ", si.PublishDate, si.Title.Text);
            try
            {
                string preSrcUrl = null, fileSize = null;

                var content = si.ElementExtensions.FirstOrDefault(r => r.OuterName == "content");
                if (content != null)
                {
                    RssHelper.getFromContent(content, ref preSrcUrl, ref fileSize);
                }

                var orgSrcUrl = preSrcUrl ?? si.Id;
                var altSrcUrl = RssHelper.tryGetStrVal(si, "origEnclosureLink") ?? "";
                var orignLink = RssHelper.tryGetStrVal(si, "origLink") ?? "";
                var duration_ = RssHelper.tryGetStrVal(si, "duration") ?? "44.4";
                var summary_0 = RssHelper.tryGetStrVal(si, "summary") ?? si.Summary.Text;
                var castSumry = summary_0.Length < 1000 ? summary_0 : summary_0.Substring(0, 1000);

                //if (altSrcUrl != "")					orgSrcUrl = altSrcUrl; //for DNR - much faster src... actually, not really.

                //foreach (SyndicationElementExtension see in si.ElementExtensions) { var xe = see.GetObject<XElement>(); Debug.WriteLine("   xEl  =   name/value:  {0,-64}=  {1}", xe.Name, xe.Value); foreach (var atr in xe.Attributes()) Debug.WriteLine("     atr -               {0,-64} - {1}", atr.Name, atr.Value); }
                var ts = TimeSpan.FromMinutes(44);
                if (duration_.Contains(':'))
                {
                    TimeSpan.TryParse(duration_, out ts);
                }
                else
                if (double.TryParse(duration_, out var durSec))
                {
                    ts = TimeSpan.FromSeconds(durSec);
                }

                var enclosure = si.Links.FirstOrDefault(r => r.RelationshipType == "enclosure");

                var fileLen = fileSize != null?Convert.ToInt64(fileSize) : enclosure != null ? enclosure.Length : 0;

                if (fileLen < 150000 && feed.Name.Contains("CBC")) //cbc seems to be using kb.
                {
                    fileLen *= 1024;
                }

                var prefix = feed.Tla;
                if (!isMedia(orgSrcUrl))
                {
                    if (enclosure != null && Path.GetExtension(enclosure.Uri.ToString()).Length != 0)
                    {
                        orgSrcUrl = enclosure.Uri.ToString();
                    }
                    else
                    {
                        prefix = "Non-Media\\";
                    }
                }

                if (orgSrcUrl.EndsWith("/"))
                {
                    return;
                }

                var castTitle = UnicodeBuster(si.Title.Text).Replace("\n", " ").Trim();
                var fileName  = MiscHelper.GetSmartPathFileName(orgSrcUrl, si.PublishDate.Date, prefix, feed.SubFolderEx, feed.IsTitleInFilename ? castTitle : null, feed.IsNewerFirst);

                RssDnldInfos.Add(new RssDnldInfo
                {
                    CastTitle   = castTitle,
                    Published   = si.PublishDate.Date > DateTime.Today.AddYears(-100) ? si.PublishDate.Date : DateTime.Today.AddYears(-100),
                    OrgSrcUrl   = orgSrcUrl,
                    AltSrcUrl   = altSrcUrl,
                    OrignLink   = orignLink,
                    CastSumry   = UnicodeBuster(castSumry),
                    TtlMinuts   = ts.TotalMinutes,
                    CastFileLen = fileLen,
                    CasFilename = fileName
                }); // var isNewDlRowAdded = saveToDnldRow_IsNewAdded(_db, feed, si.Title.Text.Replace("\n", " ").Trim(), si.PublishDate.Date, orgSrcUrl_, altSrcUrl, origLink_, summary__, ts.TotalMinutes, fileLen, fnm);
            }
            catch (Exception ex) { ex.Log(); }
        }