(extractor = GenericExtractor, opts)
| 203 | |
| 204 | const RootExtractor = { |
| 205 | extract(extractor = GenericExtractor, opts) { |
| 206 | const { contentOnly, extractedTitle } = opts; |
| 207 | // This is the generic extractor. Run its extract method |
| 208 | if (extractor.domain === '*') return extractor.extract(opts); |
| 209 | |
| 210 | opts = { |
| 211 | ...opts, |
| 212 | extractor, |
| 213 | }; |
| 214 | |
| 215 | if (contentOnly) { |
| 216 | const content = extractResult({ |
| 217 | ...opts, |
| 218 | type: 'content', |
| 219 | extractHtml: true, |
| 220 | title: extractedTitle, |
| 221 | }); |
| 222 | return { |
| 223 | content, |
| 224 | }; |
| 225 | } |
| 226 | const title = extractResult({ ...opts, type: 'title' }); |
| 227 | const date_published = extractResult({ ...opts, type: 'date_published' }); |
| 228 | const author = extractResult({ ...opts, type: 'author' }); |
| 229 | const next_page_url = extractResult({ ...opts, type: 'next_page_url' }); |
| 230 | const content = extractResult({ |
| 231 | ...opts, |
| 232 | type: 'content', |
| 233 | extractHtml: true, |
| 234 | title, |
| 235 | }); |
| 236 | const lead_image_url = extractResult({ |
| 237 | ...opts, |
| 238 | type: 'lead_image_url', |
| 239 | content, |
| 240 | }); |
| 241 | const excerpt = extractResult({ ...opts, type: 'excerpt', content }); |
| 242 | const dek = extractResult({ ...opts, type: 'dek', content, excerpt }); |
| 243 | const word_count = extractResult({ ...opts, type: 'word_count', content }); |
| 244 | const direction = extractResult({ ...opts, type: 'direction', title }); |
| 245 | const { url, domain } = extractResult({ |
| 246 | ...opts, |
| 247 | type: 'url_and_domain', |
| 248 | }) || { url: null, domain: null }; |
| 249 | |
| 250 | let extendedResults = {}; |
| 251 | if (extractor.extend) { |
| 252 | extendedResults = selectExtendedTypes(extractor.extend, opts); |
| 253 | } |
| 254 | |
| 255 | return { |
| 256 | title, |
| 257 | content, |
| 258 | author, |
| 259 | date_published, |
| 260 | lead_image_url, |
| 261 | dek, |
| 262 | next_page_url, |
nothing calls this directly
no test coverage detected