From f8d5ff79b24afe1eebcd2c7d4273655fb59b8ac0 Mon Sep 17 00:00:00 2001 From: "D. Moonfire" Date: Sun, 24 Sep 2023 00:23:37 -0500 Subject: [PATCH] Add Alfie --- dosagelib/plugins/a.py | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/dosagelib/plugins/a.py b/dosagelib/plugins/a.py index 32a5b42ceb..d7d093ad0d 100644 --- a/dosagelib/plugins/a.py +++ b/dosagelib/plugins/a.py @@ -3,7 +3,7 @@ # Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2015-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring -from re import compile, escape, MULTILINE +from re import compile, escape, sub, MULTILINE from ..util import tagre from ..scraper import BasicScraper, ParserScraper, _BasicScraper, _ParserScraper @@ -136,6 +136,45 @@ class ALessonIsLearned(_BasicScraper): help = 'Index format: nnn' +class Alfie(WordPressScraper): + url = 'https://buttsmithy.com/' + stripUrl = url + 'archives/comic/%s' + firstStripUrl = stripUrl % 'p1' + adult = True + + def namer(self, image_url, page_url): + def repl(m): + return "{0}".format(m.group(1).zfill(4)) + + if page_url == "https://buttsmithy.com/": + page = self.getPage(page_url) + links = page.xpath('//h2[@class="post-title"]/a/@href') + page_url = links[0] + + name = sub('^p-?(\d+)', repl, page_url.split('/')[-1]) + + if name == "o-525": + name = "0525" + if name == "0369-2": + name = "0469" + if name == "1404": + name = "0378" + if name == "0338-2": + name = "0339" + if page_url == "https://buttsmithy.com/archives/comic/1186": + name = "0324" + if page_url == "https://buttsmithy.com/archives/comic/1169": + name = "0319" + if page_url == "https://buttsmithy.com/archives/comic/1132": + name = "0313" + if page_url == "https://buttsmithy.com/archives/comic/p-145": + name = "0145-2" + if page_url == "https://buttsmithy.com/archives/comic/p145": + name = "0145-1" + + return name + + class Alice(WordPressScraper): url = 'https://web.archive.org/web/20210115132313/http://www.alicecomics.com/' latestSearch = '//a[text()="Latest Alice!"]'