Exemplo n.º 1
0
        public TitleDistill(Uri address, IWebsiteHost hostData, ILogger log)
            : base(address, log)
        {
            if (address == null)
            {
                log.Error("Address cannot be null");
                throw new NullReferenceException("Address cannot be null");
            }

            HostData = hostData;

            /// Sets the host URI of the series.
            HostVariables.Add("host", address.Host);

            /// Sets the host URI of the series including its scheme (ie. https://).
            HostVariables.Add("host_and_scheme", string.Concat(address.Scheme, Uri.SchemeDelimiter, address.Host));

            /// Sets the series' main address.
            HostVariables.Add("series_address", address.ToString());

            /// Set the the trimmed address for the main series page.
            HostVariables.Add("series_address_trimmed", address.ToString().Substring(0, address.ToString().LastIndexOf('/')));

            /// Sets the series name.
            HostVariables.Add("series_name", this.SeriesTitle);

            if (IsAddressChapterUri())
            {
                IsChapter = true;
            }
        }
Exemplo n.º 2
0
        public ChapterDistill(string name, Uri address, IWebsiteHost hostData, ILogger log)
            : base(name, address, log)
        {
            log.Trace("Entering ChapterDistill() constructor");

            if (hostData == null)
            {
                log.Error("Variable 'hostData' cannot be null.");
                throw new ArgumentNullException("Variable 'hostData' cannot be null.");
            }
            else
            {
                HostData = hostData;

                /// Sets the chapter's name according to the host.
                Parsing.RegisterChapterVariable(Name, HostVariables);
                log.Info("Chapter 'name' variable: {0}", HostVariables[Parsing.CHAPTER_VARIABLE]);

                /// Sets the chapter's address.
                HostVariables.Add("address", address.ToString());
                log.Info("Chapter 'address' value: {0}", HostVariables["address"]);

                /// Sets a trimmed version of the chapter's address.
                HostVariables.Add("address_trimmed", address.ToString().Substring(0, address.ToString().LastIndexOf('/')));
                log.Info("Chapter 'address_trimmed' value: {0}", HostVariables["address_trimmed"]);

                // Short-circuit the page listing if all of the 'pages' (chapter images) are in a single HTML page.
                SinglePage = HostData.Host.SinglePage;
                log.Info("Is single page: {0}", SinglePage);

                log.Info("No chapter directory: {0}", hostData.Chapters.NoChapterDirectory);

                if (hostData.Chapters.NoChapterDirectory)
                {
                    FormattedChapterName = string.Empty;
                    //log.Debug("Setting chapter path to '{0}'", ChapterPath);
                }
                else
                {
                    FormattedChapterName = Name;
                }
            }
        }