]> git.lizzy.rs Git - nhentai.git/commitdiff
a shocking typo: dojinshi -> doujinsi
authorRicter Z <ricterzheng@gmail.com>
Wed, 3 Feb 2016 09:56:13 +0000 (17:56 +0800)
committerRicter Z <ricterzheng@gmail.com>
Wed, 3 Feb 2016 09:56:13 +0000 (17:56 +0800)
MANIFEST.in
nhentai/cmdline.py
nhentai/command.py
nhentai/constant.py
nhentai/dojinshi.py
nhentai/parser.py
requirements.txt
setup.py

index 3d387c34829f2aeecd6c1503c5016e028c8f8d84..8afbefe8d878a5769d67dc0cb3ec28bff30b14a7 100644 (file)
@@ -1,2 +1,2 @@
 include README.md
-include requirements.txt
\ No newline at end of file
+include requirements.txt
index 380757c8d8c379c9054913fa6d6c9e68c8c04b85..891d1ab59a0b3944c316b810e73672b71d679a9d 100644 (file)
@@ -19,18 +19,18 @@ def banner():
 
 def cmd_parser():
     parser = OptionParser()
-    parser.add_option('--download', dest='is_download', action='store_true', help='download dojinshi or not')
-    parser.add_option('--id', type='int', dest='id', action='store', help='dojinshi id of nhentai')
-    parser.add_option('--ids', type='str', dest='ids', action='store', help='dojinshi id set, e.g. 1,2,3')
+    parser.add_option('--download', dest='is_download', action='store_true', help='download doujinshi or not')
+    parser.add_option('--id', type='int', dest='id', action='store', help='doujinshi id of nhentai')
+    parser.add_option('--ids', type='str', dest='ids', action='store', help='doujinshi id set, e.g. 1,2,3')
     parser.add_option('--search', type='string', dest='keyword', action='store', help='keyword searched')
     parser.add_option('--page', type='int', dest='page', action='store', default=1,
                       help='page number of search result')
     parser.add_option('--path', type='string', dest='saved_path', action='store', default='',
-                      help='path which save the dojinshi')
+                      help='path which save the doujinshi')
     parser.add_option('--threads', '-t', type='int', dest='threads', action='store', default=5,
-                      help='thread count of download dojinshi')
+                      help='thread count of download doujinshi')
     parser.add_option('--timeout', type='int', dest='timeout', action='store', default=30,
-                      help='timeout of download dojinshi')
+                      help='timeout of download doujinshi')
     args, _ = parser.parse_args()
 
     if args.ids:
@@ -38,7 +38,7 @@ def cmd_parser():
         args.ids = set(map(int, filter(lambda id: id.isdigit(), _)))
 
     if args.is_download and not args.id and not args.ids and not args.keyword:
-        logger.critical('Dojinshi id/ids is required for downloading')
+        logger.critical('Doujinshi id/ids is required for downloading')
         parser.print_help()
         raise SystemExit
 
index 87bc795fe0ff2af81ec203d171e900b88f4336b4..647952ccd213d9cf3ad98f7ccb25935b2ff6f723 100644 (file)
@@ -2,8 +2,8 @@
 # coding: utf-8
 import signal
 from cmdline import cmd_parser, banner
-from parser import dojinshi_parser, search_parser, print_dojinshi
-from dojinshi import Dojinshi
+from parser import doujinshi_parser, search_parser, print_doujinshi
+from doujinshi import Doujinshi
 from downloader import Downloader
 from logger import logger
 
@@ -14,32 +14,32 @@ def main():
 
     logger.log(15, 'nHentai: あなたも変態。 いいね?')
 
-    dojinshi_ids = []
-    dojinshi_list = []
+    doujinshi_ids = []
+    doujinshi_list = []
 
     if options.keyword:
-        dojinshis = search_parser(options.keyword, options.page)
-        print_dojinshi(dojinshis)
+        doujinshis = search_parser(options.keyword, options.page)
+        print_doujinshi(doujinshis)
         if options.is_download:
-            dojinshi_ids = map(lambda d: d['id'], dojinshis)
+            doujinshi_ids = map(lambda d: d['id'], doujinshis)
     else:
-        dojinshi_ids = options.ids
+        doujinshi_ids = options.ids
 
-    if dojinshi_ids:
-        for id in dojinshi_ids:
-            dojinshi_info = dojinshi_parser(id)
-            dojinshi_list.append(Dojinshi(**dojinshi_info))
+    if doujinshi_ids:
+        for id in doujinshi_ids:
+            doujinshi_info = doujinshi_parser(id)
+            doujinshi_list.append(Doujinshi(**doujinshi_info))
     else:
         raise SystemExit
 
     if options.is_download:
         downloader = Downloader(path=options.saved_path,
                                 thread=options.threads, timeout=options.timeout)
-        for dojinshi in dojinshi_list:
-            dojinshi.downloader = downloader
-            dojinshi.download()
+        for doujinshi in doujinshi_list:
+            doujinshi.downloader = downloader
+            doujinshi.download()
     else:
-        map(lambda dojinshi: dojinshi.show(), dojinshi_list)
+        map(lambda doujinshi: doujinshi.show(), doujinshi_list)
 
     logger.log(15, u'🍺 All done.')
 
@@ -50,4 +50,4 @@ def signal_handler(signal, frame):
 
 signal.signal(signal.SIGINT, signal_handler)
 if __name__ == '__main__':
-    main()
\ No newline at end of file
+    main()
index 476978c6aa2d115580f6392f9bf311bda12bb559..5196bd7f6cf3e51c1071d4af0b205a9fa2aa8c07 100644 (file)
@@ -2,4 +2,4 @@ SCHEMA = 'http://'
 URL = '%snhentai.net' % SCHEMA
 DETAIL_URL = '%s/g' % URL
 IMAGE_URL = '%si.nhentai.net/galleries' % SCHEMA
-SEARCH_URL = '%s/search/' % URL
\ No newline at end of file
+SEARCH_URL = '%s/search/' % URL
index 8d9afaaedf5bad5c940eb58739fee47bd9db69b4..a954b80770b51ac504a762d82b41f45119a7ff22 100644 (file)
@@ -4,7 +4,7 @@ from constant import DETAIL_URL, IMAGE_URL
 from logger import logger
 
 
-class Dojinshi(object):
+class Doujinshi(object):
     def __init__(self, name=None, subtitle=None, id=None, img_id=None, ext='jpg', pages=0):
         self.name = name
         self.subtitle = subtitle
@@ -16,17 +16,17 @@ class Dojinshi(object):
         self.url = '%s/%d' % (DETAIL_URL, self.id)
 
     def __repr__(self):
-        return '<Dojinshi: %s>' % self.name
+        return '<Doujinshi: %s>' % self.name
 
     def show(self):
-        logger.info('Print dojinshi information')
-        print('Dojinshi: %s' % self.name)
+        logger.info('Print doujinshi information')
+        print('Doujinshi: %s' % self.name)
         print('Subtitle: %s' % self.subtitle)
         print('URL: %s' % self.url)
         print('Pages: %d' % self.pages)
 
     def download(self):
-        logger.info('Start download dojinshi: %s' % self.name)
+        logger.info('Start download doujinshi: %s' % self.name)
         if self.downloader:
             download_queue = []
             for i in xrange(1, self.pages + 1):
@@ -37,7 +37,7 @@ class Dojinshi(object):
 
 
 if __name__ == '__main__':
-    test = Dojinshi(name='test nhentai dojinshi', id=1)
+    test = Doujinshi(name='test nhentai doujinshi', id=1)
     print(test)
     test.show()
     try:
index 9c51a879d770e67fc60fe1887093cbfe0082b1f4..7585a2950c88198a818dcd0524fb670b43915cf8 100644 (file)
@@ -9,13 +9,13 @@ from logger import logger
 from tabulate import tabulate
 
 
-def dojinshi_parser(id):
+def doujinshi_parser(id):
     if not isinstance(id, (int, )) and (isinstance(id, (str, )) and not id.isdigit()):
-        raise Exception('Dojinshi id(%s) is not valid' % str(id))
+        raise Exception('Doujinshi id(%s) is not valid' % str(id))
     id = int(id)
-    logger.debug('Fetching dojinshi information of id %d' % id)
-    dojinshi = dict()
-    dojinshi['id'] = id
+    logger.debug('Fetching doujinshi information of id %d' % id)
+    doujinshi = dict()
+    doujinshi['id'] = id
     url = '%s/%d/' % (DETAIL_URL, id)
 
     try:
@@ -25,54 +25,54 @@ def dojinshi_parser(id):
         sys.exit()
 
     html = BeautifulSoup(response)
-    dojinshi_info = html.find('div', attrs={'id': 'info'})
+    doujinshi_info = html.find('div', attrs={'id': 'info'})
 
-    title = dojinshi_info.find('h1').text
-    subtitle = dojinshi_info.find('h2')
+    title = doujinshi_info.find('h1').text
+    subtitle = doujinshi_info.find('h2')
 
-    dojinshi['name'] = title
-    dojinshi['subtitle'] = subtitle.text if subtitle else ''
+    doujinshi['name'] = title
+    doujinshi['subtitle'] = subtitle.text if subtitle else ''
 
-    dojinshi_cover = html.find('div', attrs={'id': 'cover'})
-    img_id = re.search('/galleries/([\d]+)/cover\.(jpg|png)$', dojinshi_cover.a.img['src'])
+    doujinshi_cover = html.find('div', attrs={'id': 'cover'})
+    img_id = re.search('/galleries/([\d]+)/cover\.(jpg|png)$', doujinshi_cover.a.img['src'])
     if not img_id:
         logger.critical('Tried yo get image id failed')
         sys.exit()
-    dojinshi['img_id'] = img_id.group(1)
-    dojinshi['ext'] = img_id.group(2)
+    doujinshi['img_id'] = img_id.group(1)
+    doujinshi['ext'] = img_id.group(2)
 
     pages = 0
-    for _ in dojinshi_info.find_all('div', class_=''):
+    for _ in doujinshi_info.find_all('div', class_=''):
         pages = re.search('([\d]+) pages', _.text)
         if pages:
             pages = pages.group(1)
             break
-    dojinshi['pages'] = int(pages)
-    return dojinshi
+    doujinshi['pages'] = int(pages)
+    return doujinshi
 
 
 def search_parser(keyword, page):
-    logger.debug('Searching dojinshis of keyword %s' % keyword)
+    logger.debug('Searching doujinshis of keyword %s' % keyword)
     result = []
     response = requests.get(SEARCH_URL, params={'q': keyword, 'page': page}).content
     html = BeautifulSoup(response)
-    dojinshi_search_result = html.find_all('div', attrs={'class': 'gallery'})
-    for dojinshi in dojinshi_search_result:
-        dojinshi_container = dojinshi.find('div', attrs={'class': 'caption'})
-        title = dojinshi_container.text.strip()
+    doujinshi_search_result = html.find_all('div', attrs={'class': 'gallery'})
+    for doujinshi in doujinshi_search_result:
+        doujinshi_container = doujinshi.find('div', attrs={'class': 'caption'})
+        title = doujinshi_container.text.strip()
         title = (title[:85] + '..') if len(title) > 85 else title
-        id_ = re.search('/g/(\d+)/', dojinshi.a['href']).group(1)
+        id_ = re.search('/g/(\d+)/', doujinshi.a['href']).group(1)
         result.append({'id': id_, 'title': title})
     return result
 
 
-def print_dojinshi(dojinshi_list):
-    if not dojinshi_list:
+def print_doujinshi(doujinshi_list):
+    if not doujinshi_list:
         return
-    dojinshi_list = [i.values() for i in dojinshi_list]
-    headers = ['id', 'dojinshi']
+    doujinshi_list = [i.values() for i in doujinshi_list]
+    headers = ['id', 'doujinshi']
     logger.info('Search Result\n' +
-                tabulate(tabular_data=dojinshi_list, headers=headers, tablefmt='rst'))
+                tabulate(tabular_data=doujinshi_list, headers=headers, tablefmt='rst'))
 
 if __name__ == '__main__':
-    print(dojinshi_parser("32271"))
+    print(doujinshi_parser("32271"))
index 6d113e0c00d8cc5cf50b2819f028fe364c80a6ae..b48abcf8fe1259e9637e709787ac29e7401f1b4b 100644 (file)
@@ -1,4 +1,4 @@
 requests>=2.5.0
 BeautifulSoup4>=4.0.0
 threadpool>=1.2.7
-tabulate>=0.7.5
\ No newline at end of file
+tabulate>=0.7.5
index 199b3ca2429833b1b8d07b30a7e809b9b4137186..00eb63502179638f47c217396fa20320a98b955a 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -11,8 +11,8 @@ setup(
 
     author=__author__,
     author_email=__email__,
-    keywords='nhentai, dojinshi',
-    description='nhentai.net dojinshis downloader',
+    keywords='nhentai, doujinshi',
+    description='nhentai.net doujinshis downloader',
     url='https://github.com/RicterZ/nhentai',
     include_package_data=True,
     zip_safe=False,
@@ -24,4 +24,4 @@ setup(
         ]
     },
     license='MIT',
-)
\ No newline at end of file
+)