Exemple #1
0
        /// <summary>
        /// Reads <see cref="TagType.ID3v2"/> tags from a <paramref name="Channel"/>.
        /// </summary>
        public bool ReadID3v2(int Channel)
        {
            var ptr = Bass.ChannelGetTags(Channel, TagType.ID3v2);

            if (ptr == IntPtr.Zero)
                return false;

            var id3V2 = new ID3v2Tag(ptr);

            foreach (var frame in id3V2.TextFrames)
                if (!SetTagUsingLookupTable(frame.Key, frame.Value, LookupTables.Id3v2))
                    Other.Add(frame.Key, frame.Value);

            Pictures.AddRange(id3V2.PictureFrames);

            return true;
        }
Exemple #2
0
 public void Reset(IPage page)
 {
     Pictures.Clear();
     Pictures.AddRange(page.Pictures.Select(p => new PictureDto(p)));
     Layout = page.Layout;
 }
        public override bool ProcessContentLinks()
        {
            string fname  = Path.GetFileName(SourceFilePath);
            bool   yml    = string.Equals(fname, "toc.yml", StringComparison.InvariantCultureIgnoreCase);
            bool   result = string.Equals(fname, "toc.md", StringComparison.InvariantCultureIgnoreCase) ||
                            yml ||
                            ContentHasAudienceApplicationUser(_content);

            if (result)
            {
                FoundLink[] links = FindAllLinks(yml, _content);
                Links.AddRange(links.Select(l => l.FullMatch));
                foreach (FoundLink link in links.GroupBy(k => k).Select(k => k.Key))
                {
                    if (String.IsNullOrEmpty(link.Link.Trim()))
                    {
                        continue;
                    }

                    string linkClear = CleanLinkOfQueryAndHash(link.Link);

                    if (linkClear.StartsWith("http", StringComparison.InvariantCultureIgnoreCase) ||
                        linkClear.EndsWith("toc.md", StringComparison.InvariantCultureIgnoreCase) ||
                        linkClear.EndsWith("toc.yml", StringComparison.InvariantCultureIgnoreCase) ||
                        linkClear.StartsWith("mailto", StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }

                    try
                    {
                        string href = BuildFullUrl("/" + SourceFilePath, linkClear);
                        ProcessLink(href, link.Link, new ConceptualItemParameter(ref _content, link, href));
                    }
                    catch (Exception ex)
                    {
                        Logger.LogWarning($"Message: \"{ex.Message}\", File: \"{fname}\", Href: \"{link.Link}\"");
                    }
                }

                FoundPicture[] pictures = FindAllPictures(_content);
                Pictures.AddRange(pictures.Select(p => p.FullMatch));
                foreach (FoundPicture picture in pictures)
                {
                    try
                    {
                        string href = BuildFullUrl("/" + SourceFilePath, GetOnlyLink(picture.Link1));
                        ProcessLink(href, picture.Link1, null);

                        if (!String.IsNullOrEmpty(picture.Link2) && !picture.Link1.Equals(picture.Link2))
                        {
                            string link2 = CleanLinkOfQueryAndHash(GetOnlyLink(picture.Link2));
                            href = BuildFullUrl("/" + SourceFilePath, link2);
                            ProcessLink(href, picture.Link2, null);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogWarning($"Message: \"{ex.Message}\", File: \"{fname}\", Link1: \"{picture.Link1}\", Link2: \"{picture.Link2}\"");
                    }
                }

                FoundLink[] includes = FindIncludedLinks(_content);
                foreach (FoundLink link in includes.GroupBy(k => k).Select(k => k.Key))
                {
                    if (String.IsNullOrEmpty(link.Link.Trim()))
                    {
                        continue;
                    }

                    string linkClear = CleanLinkOfQueryAndHash(link.Link);

                    if (linkClear.StartsWith("http", StringComparison.InvariantCultureIgnoreCase) ||
                        linkClear.EndsWith("toc.md", StringComparison.InvariantCultureIgnoreCase) ||
                        linkClear.EndsWith("toc.yml", StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }

                    try
                    {
                        string href = BuildFullUrl("/" + SourceFilePath, linkClear);
                        if (!FilesToIgnore.Contains(href.TrimStart('\\')))
                        {
                            FilesToIgnore.Add(href.TrimStart('\\'));
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogWarning($"Message: \"{ex.Message}\", File: \"{fname}\", Href: \"{link.Link}\"");
                    }
                }
                return(HasModified);
            }
            if (!(fname != null && fname.Equals("toc.md", StringComparison.InvariantCultureIgnoreCase)))
            {
                FilesToRemove.Add(SourceFilePath.TrimStart('\\'));
            }
            return(false);
        }