summaryrefslogblamecommitdiffstatshomepage
path: root/docs/_examples/example_transformer.py
blob: 6e443ae2e07be6b0565eef63f59fe4cbc641b06a (plain) (tree)




















                                                            
from hircine.plugins import transformer
from hircine.scraper.types import Artist, Tag


@transformer
def transform(generator, info):
    for item in generator:
        # Ignore the "Drama" tag when scraping from mangadex
        if info.source == "mangadex":
            match item:
                case Tag(tag="Drama"):
                    continue

        # convert all Artist names to lowercase
        match item:
            case Artist(name):
                yield Artist(name.lower())
                continue

        # other items are not modified
        yield item