Skip to content

Commit

Permalink
Merge pull request #1148 from dipu-bd/dev
Browse files Browse the repository at this point in the history
Version 2.28.9
  • Loading branch information
dipu-bd authored Oct 15, 2021
2 parents abbda70 + 54e38db commit 0408e9b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ $ lncrawl -h
┃┃╱╭╋┫╭╮┃╭╮┃┃┃╭╮┫╭╮┃╰╯┃┃━┫┃╱┃┃╱╭┫╭┫╭╮┃╰╯╰╯┃┃┃┃━┫╭╯
┃╰━╯┃┃╰╯┃┃┃┃╰┫┃┃┃╰╯┣╮╭┫┃━┫╰╮┃╰━╯┃┃┃╭╮┣╮╭╮╭┫╰┫┃━┫┃
╰━━━┻┻━╮┣╯╰┻━┻╯╰┻━━╯╰╯╰━━┻━╯╰━━━┻╯╰╯╰╯╰╯╰╯╰━┻━━┻╯
╱╱╱╱╱╭━╯┃ v2.28.8
╱╱╱╱╱╭━╯┃ v2.28.9
╱╱╱╱╱╰━━╯ 🔗 https://github.com/dipu-bd/lightnovel-crawler
--------------------------------------------------------------------------------
usage: lncrawl [options...]
Expand Down Expand Up @@ -1147,12 +1147,12 @@ We are supporting 203 sources and 221 crawlers.
</tr>
<tr><td><span title="Contains machine translations"></span><span title="Supports searching">🔍</span><span title="Supports login"></span><span title="Contains manga/manhua/manhwa"></span></td>
<td><a href="https://www.lightnovelpub.com/" target="_blank">https://www.lightnovelpub.com/</a></td>
<td><a href="https://github.com/dipu-bd/lightnovel-crawler/blob/master/sources/en/l/lightnovelpub.py" title="01 October 2021 04:52:32 AM">11</a></td>
<td><a href="https://github.com/dipu-bd/lightnovel-crawler/blob/master/sources/en/l/lightnovelpub.py" title="15 October 2021 02:14:01 AM">12</a></td>
<td><a href="https://github.com/dipu-bd"><img src="https://avatars.githubusercontent.com/u/5158124?v=4&s=24" alt="dipu-bd" height="24"/></a> <a href="https://github.com/SirGryphin"><img src="https://avatars.githubusercontent.com/u/36343615?v=4&s=24" alt="SirGryphin" height="24"/></a> <a href="https://github.com/Galunid"><img src="https://avatars.githubusercontent.com/u/10298730?v=4&s=24" alt="Galunid" height="24"/></a></td>
</tr>
<tr><td><span title="Contains machine translations"></span><span title="Supports searching">🔍</span><span title="Supports login"></span><span title="Contains manga/manhua/manhwa"></span></td>
<td><a href="https://www.lightnovelworld.com/" target="_blank">https://www.lightnovelworld.com/</a></td>
<td><a href="https://github.com/dipu-bd/lightnovel-crawler/blob/master/sources/en/l/lightnovelpub.py" title="01 October 2021 04:52:32 AM">11</a></td>
<td><a href="https://github.com/dipu-bd/lightnovel-crawler/blob/master/sources/en/l/lightnovelpub.py" title="15 October 2021 02:14:01 AM">12</a></td>
<td><a href="https://github.com/dipu-bd"><img src="https://avatars.githubusercontent.com/u/5158124?v=4&s=24" alt="dipu-bd" height="24"/></a> <a href="https://github.com/SirGryphin"><img src="https://avatars.githubusercontent.com/u/36343615?v=4&s=24" alt="SirGryphin" height="24"/></a> <a href="https://github.com/Galunid"><img src="https://avatars.githubusercontent.com/u/10298730?v=4&s=24" alt="Galunid" height="24"/></a></td>
</tr>
<tr><td><span title="Contains machine translations"></span><span title="Supports searching">🔍</span><span title="Supports login"></span><span title="Contains manga/manhua/manhwa"></span></td>
Expand Down Expand Up @@ -1237,8 +1237,8 @@ We are supporting 203 sources and 221 crawlers.
</tr>
<tr><td><span title="Contains machine translations"></span><span title="Supports searching"></span><span title="Supports login"></span><span title="Contains manga/manhua/manhwa"></span></td>
<td><a href="https://www.oppatranslations.com/" target="_blank">https://www.oppatranslations.com/</a></td>
<td><a href="https://github.com/dipu-bd/lightnovel-crawler/blob/master/sources/en/o/oppatranslations.py" title="27 July 2021 10:03:56 PM">4</a></td>
<td><a href="https://github.com/dipu-bd"><img src="https://avatars.githubusercontent.com/u/5158124?v=4&s=24" alt="dipu-bd" height="24"/></a> <a href="https://github.com/amritoo"><img src="https://avatars.githubusercontent.com/u/45586379?v=4&s=24" alt="amritoo" height="24"/></a></td>
<td><a href="https://github.com/dipu-bd/lightnovel-crawler/blob/master/sources/en/o/oppatrans.py" title="16 July 2021 02:11:58 PM">61</a></td>
<td><a href="https://github.com/dipu-bd"><img src="https://avatars.githubusercontent.com/u/5158124?v=4&s=24" alt="dipu-bd" height="24"/></a> <a href="https://github.com/SirGryphin"><img src="https://avatars.githubusercontent.com/u/36343615?v=4&s=24" alt="SirGryphin" height="24"/></a> <a href="https://github.com/yudilee"><img src="https://avatars.githubusercontent.com/u/7065691?v=4&s=24" alt="yudilee" height="24"/></a> <a href="https://github.com/AncientCatz"><img src="https://avatars.githubusercontent.com/u/69200720?v=4&s=24" alt="AncientCatz" height="24"/></a></td>
</tr>
<tr><td><span title="Contains machine translations"></span><span title="Supports searching"></span><span title="Supports login"></span><span title="Contains manga/manhua/manhwa"></span></td>
<td><a href="https://www.ornovel.com/" target="_blank">https://www.ornovel.com/</a></td>
Expand Down
2 changes: 1 addition & 1 deletion lncrawl/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.28.8
2.28.9
6 changes: 3 additions & 3 deletions lncrawl/binders/epub.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def make_cover_image(app):
logger.info('Creating cover: %s', app.book_cover)
# ext = app.book_cover.split('.')[-1]
cover_image = epub.EpubImage()
cover_image.file_name = 'cover.png'
cover_image.media_type = 'image/png'
cover_image.file_name = 'cover.jpg'
cover_image.media_type = 'image/jpeg'
with open(app.book_cover, 'rb') as image_file:
cover_image.content = image_file.read()
# end with
Expand Down Expand Up @@ -154,7 +154,7 @@ def bind_epub_book(app, chapters, volume=''):

# Create book spine
try:
book.set_cover('book-cover.png', open(app.book_cover, 'rb').read())
book.set_cover('book-cover.jpg', open(app.book_cover, 'rb').read())
book.spine = ['cover', intro_page, 'nav']
except Exception:
book.spine = [intro_page, 'nav']
Expand Down
8 changes: 4 additions & 4 deletions lncrawl/core/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def download_image(app, url) -> Image.Image:

def download_cover(app):
filename = None
filename = os.path.join(app.output_path, 'cover.png')
filename = os.path.join(app.output_path, 'cover.jpg')
if os.path.exists(filename):
return filename

logger.info('Downloading original cover image...')
image_url = app.crawler.novel_cover
try:
img = download_image(app, image_url)
img.save(filename, 'PNG')
img.convert('RGB').save(filename, "JPEG")
logger.debug('Saved cover: %s', filename)
return filename
except Exception as ex:
Expand All @@ -47,10 +47,10 @@ def download_cover(app):
# end try

logger.info('Downloading fallback cover image...')
image_url = 'https://source.unsplash.com/featured/1200x1550?abstract'
image_url = 'https://source.unsplash.com/featured/800x1032?abstract'
try:
img = download_image(app, image_url)
img.save(filename, 'PNG')
img.convert('RGB').save(filename, "JPEG")
logger.debug('Saved cover: %s', filename)
return filename
except Exception as ex:
Expand Down
2 changes: 1 addition & 1 deletion sources/_index.json

Large diffs are not rendered by default.

27 changes: 13 additions & 14 deletions sources/en/l/lightnovelpub.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
import logging
import re
from urllib.parse import urlparse

from bs4.element import Tag

from lncrawl.core.crawler import Crawler

logger = logging.getLogger(__name__)
Expand All @@ -25,10 +25,12 @@ def search_novel(self, query):
results = []
for a in soup.select('.novel-list .novel-item a'):
assert isinstance(a, Tag)
possible_info = a.select_one('.novel-stats')
info = possible_info.text.strip() if isinstance(possible_info, Tag) else None
results.append({
'title': str(a['title']).strip(),
'url': self.absolute_url(a['href']),
'info': a.select_one('.novel-stats').text.strip(),
'info': info,
})
# end for
return results
Expand All @@ -40,22 +42,19 @@ def read_novel_info(self):
logger.debug('Visiting %s', self.novel_url)
soup = self.get_soup(self.novel_url)

self.novel_title = soup.select_one('.novel-info .novel-title').text.strip()
possible_title = soup.select_one('.novel-info .novel-title')
assert isinstance(possible_title, Tag)
self.novel_title = possible_title.text.strip()
logger.info('Novel title: %s', self.novel_title)

try:
self.novel_cover = self.absolute_url(
soup.select_one('.glass-background img')['src'])
except Exception as err:
logger.debug('Failed to parse novel cover. Error: %s', err)
# end try
possible_image = soup.select_one('.glass-background img')
if isinstance(possible_image, Tag):
self.novel_cover = self.absolute_url(possible_image['src'])
logger.info('Novel cover: %s', self.novel_cover)

try:
self.novel_author = soup.select_one('.author a[href*="/author/"]')['title']
except Exception as err:
logger.debug('Failed to parse novel author. Error: %s', err)
# end try
possible_author = soup.select_one('.author a[href*="/author/"]')
if isinstance(possible_author, Tag):
self.novel_author = possible_author['title']
logger.info('Novel author: %s', self.novel_author)

logger.info('Getting chapters...')
Expand Down

0 comments on commit 0408e9b

Please sign in to comment.