Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Alfie #287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion dosagelib/plugins/a.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -136,6 +136,34 @@
help = 'Index format: nnn'


class Alfie(WordPressScraper):
url = 'https://buttsmithy.com/'
stripUrl = url + 'archives/comic/%s'
firstStripUrl = stripUrl % 'p1'
adult = True
starter = bounceStarter

def namer(self, image_url, page_url):
def repl(m):
return "{0}".format(m.group(1).zfill(4))

Check warning on line 148 in dosagelib/plugins/a.py

View check run for this annotation

Codecov / codecov/patch

dosagelib/plugins/a.py#L147-L148

Added lines #L147 - L148 were not covered by tests

name = sub('^p-?(\d+)', repl, page_url.split('/')[-1])

Check warning on line 150 in dosagelib/plugins/a.py

View check run for this annotation

Jenkins - Dosage / Flake8

W605

NORMAL: invalid escape sequence '\d'

Check warning on line 150 in dosagelib/plugins/a.py

View check run for this annotation

Codecov / codecov/patch

dosagelib/plugins/a.py#L150

Added line #L150 was not covered by tests

# Some of the first 1k pages were inconsistently named.
renames = {"/comic/p145": "0145-1", "/comic/p-145": "0145-2",

Check warning on line 153 in dosagelib/plugins/a.py

View check run for this annotation

Codecov / codecov/patch

dosagelib/plugins/a.py#L153

Added line #L153 was not covered by tests
"/comic/268": "0268", "/comic/1132": "0313",
"/comic/1169": "0319", "/comic/1186": "0324",
"/comic/1404": "0378", "/comic/0338-2": "0339",
"/comic/0369-2": "0469", "/comic/2080": "0517",
"/comic/o-525": "0525", "/comic/p-361": "0553",
"/comic/p-668-2": "0678", "/comic/p-670-2": "0670",
"/comic/p-679-2": "0690", "/comic/3140": "0805"}
for rename in renames:
if rename in page_url:
name = renames[rename]
return name

Check warning on line 164 in dosagelib/plugins/a.py

View check run for this annotation

Codecov / codecov/patch

dosagelib/plugins/a.py#L163-L164

Added lines #L163 - L164 were not covered by tests


class Alice(WordPressScraper):
url = 'https://web.archive.org/web/20210115132313/http://www.alicecomics.com/'
latestSearch = '//a[text()="Latest Alice!"]'
Expand Down