summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/wordpress.py
blob: dd7d28aee8e8fab056ebccd194088abcd96233ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-

# Copyright 2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""Extractors for WordPress blogs"""

from .common import BaseExtractor, Message
from .. import text


class WordpressExtractor(BaseExtractor):
    """Base class for wordpress extractors"""
    basecategory = "wordpress"

    def items(self):
        for post in self.posts():
            yield Message.Difrectory, post



BASE_PATTERN = WordpressExtractor.update({})


class WordpressBlogExtractor(WordpressExtractor):
    """Extractor for WordPress blogs"""
    subcategory = "blog"
    directory_fmt = ("{category}", "{blog}")
    pattern = BASE_PATTERN + r"/?$"

    def posts(self):
        url = self.root + "/wp-json/wp/v2/posts"
        params = {"page": 1, "per_page": "100"}

        while True:
            data = self.request(url, params=params).json()
            exit()
        yield 1