support Fakku works using first page as thumbnail for now
This commit is contained in:
parent
a76e3eec83
commit
3efee8fe05
|
@ -22,6 +22,7 @@ NUMBER_REGEX = re.compile('[0-9]+')
|
||||||
|
|
||||||
DLSITE_ID_REGEX = re.compile('^[BR]J[0-9]+$')
|
DLSITE_ID_REGEX = re.compile('^[BR]J[0-9]+$')
|
||||||
FANZA_ID_REGEX = re.compile('^d_[0-9]+$')
|
FANZA_ID_REGEX = re.compile('^d_[0-9]+$')
|
||||||
|
FAKKU_ID_REGEX = re.compile('.*_FAKKU$')
|
||||||
|
|
||||||
IMAGE_FILE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.tiff']
|
IMAGE_FILE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.tiff']
|
||||||
|
|
||||||
|
@ -108,17 +109,26 @@ async def fetch_async(args):
|
||||||
}
|
}
|
||||||
authors = dlsite_metadata.author or []
|
authors = dlsite_metadata.author or []
|
||||||
tags = dlsite_metadata.genre or []
|
tags = dlsite_metadata.genre or []
|
||||||
|
thumbnail_local = False
|
||||||
thumbnail_url = dlsite_metadata.work_image
|
thumbnail_url = dlsite_metadata.work_image
|
||||||
if thumbnail_url.startswith('//'):
|
if thumbnail_url.startswith('//'):
|
||||||
thumbnail_url = 'https:' + thumbnail_url
|
thumbnail_url = 'https:' + thumbnail_url
|
||||||
elif FANZA_ID_REGEX.fullmatch(work_id):
|
else:
|
||||||
db_row = manual_input_metadata(work_id)
|
db_row = manual_input_metadata(work_id)
|
||||||
authors = db_row.pop('authors')
|
authors = db_row.pop('authors')
|
||||||
tags = db_row.pop('tags')
|
tags = db_row.pop('tags')
|
||||||
thumbnail_url = f'https://doujin-assets.dmm.co.jp/digital/comic/{work_id}/{work_id}pl.jpg'
|
if FANZA_ID_REGEX.fullmatch(work_id):
|
||||||
else:
|
thumbnail_local = False
|
||||||
print(f"Don't know how to fetch metadata for {work_id}, skipping")
|
thumbnail_url = f'https://doujin-assets.dmm.co.jp/digital/comic/{work_id}/{work_id}pl.jpg'
|
||||||
continue
|
elif FAKKU_ID_REGEX.fullmatch(work_id):
|
||||||
|
thumbnail_local = True
|
||||||
|
thumbnail_path = min(work_path.iterdir())
|
||||||
|
if not thumbnail_path.is_file():
|
||||||
|
print(f'Fakku thumbnail path {thumbnail_path} is not a file! Skipping {work_id}')
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
thumbnail_local = False
|
||||||
|
thumbnail_url = input('Thumbnail image URL: ')
|
||||||
|
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"INSERT INTO works(id, title, circle, date, description, series) VALUES(:id, :title, :circle, :date, :description, :series)",
|
"INSERT INTO works(id, title, circle, date, description, series) VALUES(:id, :title, :circle, :date, :description, :series)",
|
||||||
|
@ -133,13 +143,18 @@ async def fetch_async(args):
|
||||||
[{ "tag": tag, "work": work_id } for tag in tags],
|
[{ "tag": tag, "work": work_id } for tag in tags],
|
||||||
)
|
)
|
||||||
|
|
||||||
ext = url_file_ext(thumbnail_url)
|
if thumbnail_local:
|
||||||
dest_file = thumbnails_dir / (work_id + ext)
|
ext = thumbnail_path.suffix
|
||||||
print(f'Downloading thumbnail for {work_id} from {thumbnail_url}')
|
dest_path = thumbnails_dir / (work_id + ext)
|
||||||
with open(dest_file, 'wb') as fd:
|
dest_path.symlink_to(relpath(thumbnail_path, thumbnails_dir))
|
||||||
with requests.get(thumbnail_url, stream=True) as r:
|
else:
|
||||||
for chunk in r.iter_content(chunk_size=16384):
|
ext = url_file_ext(thumbnail_url)
|
||||||
fd.write(chunk)
|
dest_file = thumbnails_dir / (work_id + ext)
|
||||||
|
print(f'Downloading thumbnail for {work_id} from {thumbnail_url}')
|
||||||
|
with open(dest_file, 'wb') as fd:
|
||||||
|
with requests.get(thumbnail_url, stream=True) as r:
|
||||||
|
for chunk in r.iter_content(chunk_size=16384):
|
||||||
|
fd.write(chunk)
|
||||||
|
|
||||||
con.commit()
|
con.commit()
|
||||||
|
|
||||||
|
@ -368,6 +383,9 @@ def generate(args):
|
||||||
continue
|
continue
|
||||||
authors = [author for (author,) in cur.execute('SELECT author FROM authors WHERE work = ?', (work_id,))]
|
authors = [author for (author,) in cur.execute('SELECT author FROM authors WHERE work = ?', (work_id,))]
|
||||||
tags = [tag for (tag,) in cur.execute('SELECT tag FROM tags WHERE work = ?', (work_id,))]
|
tags = [tag for (tag,) in cur.execute('SELECT tag FROM tags WHERE work = ?', (work_id,))]
|
||||||
|
thumbnail_filename = next(
|
||||||
|
f for f in (args.destdir / 'site' / 'thumbnails').iterdir() if f.stem == work_id
|
||||||
|
).name
|
||||||
work = {
|
work = {
|
||||||
'id': work_id,
|
'id': work_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
|
@ -377,6 +395,7 @@ def generate(args):
|
||||||
'series': series,
|
'series': series,
|
||||||
'authors': authors,
|
'authors': authors,
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
|
'thumbnail_filename': thumbnail_filename,
|
||||||
}
|
}
|
||||||
works.append(work)
|
works.append(work)
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,12 @@ body {
|
||||||
gap: 30px;
|
gap: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.work-preview {
|
||||||
|
flex-basis: 40%;
|
||||||
|
flex-grow: 1;
|
||||||
|
min-width: min(300px, 100%);
|
||||||
|
}
|
||||||
|
|
||||||
.work-preview img {
|
.work-preview img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
card.appendChild(link);
|
card.appendChild(link);
|
||||||
|
|
||||||
const thumb = document.createElement('img');
|
const thumb = document.createElement('img');
|
||||||
thumb.src = `${ROOT}/thumbnails/${work.id}.jpg`;
|
thumb.src = `${ROOT}/thumbnails/${work.thumbnail_filename}`;
|
||||||
link.appendChild(thumb);
|
link.appendChild(thumb);
|
||||||
|
|
||||||
const creators = document.createElement('div');
|
const creators = document.createElement('div');
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
{{ cat }}
|
{{ cat }}
|
||||||
</div>
|
</div>
|
||||||
{% if samples[cat] %}
|
{% if samples[cat] %}
|
||||||
<img src="{{ root() }}/thumbnails/{{ samples[cat]['id'] }}.jpg">
|
<img src="{{ root() }}/thumbnails/{{ samples[cat]['thumbnail_filename'] }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
{% for work in works %}
|
{% for work in works %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<a href="{{ root() }}/works/{{ work['id'] }}/{{ index() }}">
|
<a href="{{ root() }}/works/{{ work['id'] }}/{{ index() }}">
|
||||||
<img src="{{ root() }}/thumbnails/{{ work['id'] }}.jpg">
|
<img src="{{ root() }}/thumbnails/{{ work['thumbnail_filename'] }}">
|
||||||
<div class="card-creators">
|
<div class="card-creators">
|
||||||
[{% if work['circle'] %}{{ work['circle'] }}{% endif %}{% if work['circle'] and work['authors'] %} ({% endif %}{{ ', '.join(work['authors']) }}{% if work['circle'] and work['authors'] %}){% endif %}]
|
[{% if work['circle'] %}{{ work['circle'] }}{% endif %}{% if work['circle'] and work['authors'] %} ({% endif %}{{ ', '.join(work['authors']) }}{% if work['circle'] and work['authors'] %}){% endif %}]
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="work-container">
|
<div class="work-container">
|
||||||
<div class="work-preview">
|
<div class="work-preview">
|
||||||
<a href="view/{{ index() }}">
|
<a href="view/{{ index() }}">
|
||||||
<img src="{{ root() }}/thumbnails/{{ work['id'] }}.jpg">
|
<img src="{{ root() }}/thumbnails/{{ work['thumbnail_filename'] }}">
|
||||||
<div class="start-link">Start Reading</div>
|
<div class="start-link">Start Reading</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue