Exemplo n.º 1
0
        protected override string ParseSeriesTitle(string html)
        {
            Log.Trace("Entering ParseSeriesTitle");

            string path      = HostData.Title.Path;
            string pathvalue = HostData.Title.Value;

            var details = new ParseDetails <string>
                          (
                path,
                pathvalue,
                (element, parseDetails) =>
            {
                return(Parsing.GenericParseAction <string>(
                           element,
                           parseDetails,
                           HostData.Title,
                           (filteredTitle) => filteredTitle,
                           HostVariables
                           ));
            },
                Log
                          );

            var title = Parsing.ParseContent <string>(html, details);

            var seriesTitle = (title.Count > 0 && !string.IsNullOrWhiteSpace(title[0])) ? title[0] : "Untitled";

            // Todo: Define constant.
            HostVariables["series_name"] = seriesTitle;

            return(seriesTitle);
        }
Exemplo n.º 2
0
        protected override List <Uri> ParseImageAddresses(string html)
        {
            var details = new ParseDetails <Uri>
                          (
                HostData.Page.Path,
                HostData.Page.Value,
                (element, parseDetails) => GenericParseAction(element, parseDetails, HostData.Page, (uri) => new ValidatedUri(uri)),
                Log
                          );

            return(Parsing.ParseAddresses(html, details));
        }
Exemplo n.º 3
0
        string ParseChapterTitle(HtmlNode element, string html)
        {
            if (string.IsNullOrWhiteSpace(HostData.Chapters.Title) || string.IsNullOrWhiteSpace(HostData.Chapters.TitleValue))
            {
                return(GetFirstNonEmptyNodeText(element));
            }
            else
            {
                string chapterTitle = null;

                /// Check if the path has the meta variable '__literal' for literal values. If not,
                /// assume it points to an XPATH.
                if (Parsing.IsMetaVariableLiteral(HostData.Chapters.Title))
                {
                    /// Since the 'chapter' variable will become available after this method executes with the
                    /// creation of a new 'Chapter' instance, we'll have to register the variable now in order
                    /// to gain access to it. It should be noted that setting the chapter's name in this manner
                    /// does not take the default chapter format's place. It effectively overwrites the
                    /// chapter's name.

                    Parsing.RegisterChapterVariable(GetFirstNonEmptyNodeText(element), HostVariables);
                    chapterTitle = Parsing.EvaluateVariable(HostData.Chapters.TitleValue, HostVariables);
                }
                else
                {
                    var details = new ParseDetails <string>(
                        HostData.Chapters.Title,
                        HostData.Chapters.TitleValue,
                        (_, parseDetails) =>
                    {
                        return(SectionGenericParseAction(
                                   _,
                                   parseDetails,
                                   HostData.Chapters.TitleParseRegex,
                                   HostData.Chapters.TitleParseReplace,
                                   (title) => title
                                   ));
                    },
                        Log
                        );

                    var results = Parsing.ParseContentFromNode(element, details);
                    chapterTitle = results.Count > 0 ? results[0] : null;
                }

                return(chapterTitle);
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ParseDetails details = value as ParseDetails;

            return(value == null || string.IsNullOrEmpty(details.Url)? Visibility.Hidden : Visibility.Visible);
        }