2012-11-28 17:15:12 +00:00
|
|
|
#!/usr/bin/env python
|
2016-04-06 22:20:03 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-01-05 15:50:57 +00:00
|
|
|
# Copyright (C) 2012-2014 Bastian Kleineidam
|
2016-04-06 22:20:03 +00:00
|
|
|
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
2012-11-28 17:15:12 +00:00
|
|
|
"""
|
2016-04-06 22:20:03 +00:00
|
|
|
Script to get a list of creators.com comics and save the info in a JSON file
|
|
|
|
for further processing.
|
2012-11-28 17:15:12 +00:00
|
|
|
"""
|
2016-04-06 22:20:03 +00:00
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
from scriptutil import ComicListUpdater
|
2016-04-06 22:20:03 +00:00
|
|
|
|
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
class CreatorsUpdater(ComicListUpdater):
|
|
|
|
dup_templates = ('GoComics/%s',)
|
2012-11-28 17:15:12 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
# names of comics to exclude
|
|
|
|
excluded_comics = (
|
|
|
|
# no images
|
|
|
|
'Doodles',
|
|
|
|
)
|
2012-11-28 17:15:12 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
def handle_url(self, url):
|
|
|
|
"""Parse one listing page."""
|
|
|
|
data = self.get_url(url)
|
2012-11-28 17:15:12 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
for comicdiv in data.cssselect('ul.all-test li'):
|
|
|
|
comiclink = comicdiv.cssselect('a')[0]
|
|
|
|
comicurl = comiclink.attrib['href']
|
|
|
|
name = comicdiv.cssselect('p strong')[0].text
|
2016-04-06 22:20:03 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
self.add_comic(name, comicurl.rsplit('/', 1)[1])
|
2016-04-06 22:20:03 +00:00
|
|
|
|
2016-04-14 20:22:37 +00:00
|
|
|
def collect_results(self):
|
|
|
|
"""Parse all search result pages."""
|
|
|
|
self.handle_url('https://www.creators.com/categories/comics/all')
|
|
|
|
self.handle_url('https://www.creators.com/categories/cartoons/all')
|
2012-11-28 17:15:12 +00:00
|
|
|
|
2016-05-22 21:56:59 +00:00
|
|
|
def get_entry(self, name, path):
|
|
|
|
langopt = ", 'es'" if name.lower().endswith('spanish') else ''
|
|
|
|
return u"cls('%s', '%s'%s)," % (name, path, langopt)
|
2012-11-28 17:15:12 +00:00
|
|
|
|
2017-05-14 22:54:02 +00:00
|
|
|
|
2012-11-28 17:15:12 +00:00
|
|
|
if __name__ == '__main__':
|
2016-04-14 20:22:37 +00:00
|
|
|
CreatorsUpdater(__file__).run()
|