2020-04-18 11:45:44 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# SPDX-License-Identifier: MIT
|
2016-10-28 22:21:41 +00:00
|
|
|
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
2016-04-12 22:52:16 +00:00
|
|
|
# Copyright (C) 2012-2014 Bastian Kleineidam
|
2021-01-10 18:18:45 +00:00
|
|
|
# Copyright (C) 2015-2021 Tobias Gruetzmacher
|
2013-01-23 18:34:11 +00:00
|
|
|
"""
|
2016-04-12 22:52:16 +00:00
|
|
|
Script to get arcamax comics and save the info in a JSON file for further
|
|
|
|
processing.
|
2013-01-23 18:34:11 +00:00
|
|
|
"""
|
2016-04-12 22:52:16 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
from scriptutil import ComicListUpdater
|
2016-04-12 22:52:16 +00:00
|
|
|
|
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
class ArcamaxUpdater(ComicListUpdater):
|
|
|
|
dup_templates = ("Creators/%s", "DrunkDuck/%s", "GoComics/%s",
|
2021-01-10 18:18:45 +00:00
|
|
|
"KeenSpot/%s", "ComicGenesis/%s")
|
2013-01-23 18:34:11 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
# names of comics to exclude
|
|
|
|
excluded_comics = (
|
2016-05-22 21:17:24 +00:00
|
|
|
# better source available
|
|
|
|
"Dilbert",
|
|
|
|
"HagarTheHorrible",
|
2016-04-14 20:22:37 +00:00
|
|
|
)
|
2013-01-23 18:34:11 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
def handle_url(self, url):
|
|
|
|
"""Parse one search result page."""
|
|
|
|
data = self.get_url(url)
|
2013-01-23 18:34:11 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
for comiclink in data.cssselect('a.comic-icon'):
|
|
|
|
path = comiclink.attrib['href']
|
|
|
|
name = comiclink.attrib['title']
|
2013-01-23 18:34:11 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
self.add_comic(name, path.rsplit('/', 2)[1])
|
2016-04-13 22:17:59 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
def collect_results(self):
|
|
|
|
"""Parse all search result pages."""
|
|
|
|
self.handle_url('http://www.arcamax.com/comics')
|
2013-01-23 18:34:11 +00:00
|
|
|
|
2016-05-22 20:55:06 +00:00
|
|
|
def get_entry(self, name, entry):
|
2016-05-22 21:17:24 +00:00
|
|
|
return u"cls('%s', '%s')," % (name, entry)
|
2013-01-23 18:34:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-04-14 20:22:37 +00:00
|
|
|
ArcamaxUpdater(__file__).run()
|