2 from __future__ import print_function
3 from constant import DETAIL_URL, IMAGE_URL
4 from logger import logger
7 class Doujinshi(object):
8 def __init__(self, name=None, subtitle=None, id=None, img_id=None, ext='jpg', pages=0):
10 self.subtitle = subtitle
15 self.downloader = None
16 self.url = '%s/%d' % (DETAIL_URL, self.id)
19 return '<Doujinshi: %s>' % self.name
22 logger.info('Print doujinshi information')
23 print('Doujinshi: %s' % self.name)
24 print('Subtitle: %s' % self.subtitle)
25 print('URL: %s' % self.url)
26 print('Pages: %d' % self.pages)
29 logger.info('Start download doujinshi: %s' % self.name)
32 for i in xrange(1, self.pages + 1):
33 download_queue.append('%s/%d/%d.%s' % (IMAGE_URL, int(self.img_id), i, self.ext))
34 self.downloader.download(download_queue, self.id)
36 logger.critical('Downloader has not be loaded')
39 if __name__ == '__main__':
40 test = Doujinshi(name='test nhentai doujinshi', id=1)
45 except Exception as e:
46 print('Exception: %s' % str(e))