[books] Clean up koreader imports and data storage
This commit is contained in:
@ -89,12 +89,13 @@ def create_book_from_row(row: list):
|
||||
run_time = total_pages * Book.AVG_PAGE_READING_SECONDS
|
||||
book_title = row[KoReaderBookColumn.TITLE.value]
|
||||
if " - " in book_title:
|
||||
book_title = book_title.split(" - ")[0]
|
||||
if not author_str:
|
||||
author_str = book_title.split(" - ")[1]
|
||||
split_title = book_title.split(" - ")
|
||||
book_title = split_title[0]
|
||||
if (not author_str or author_str == "N/A") and len(split_title) > 1:
|
||||
author_str = split_title[1].split("_")[0]
|
||||
|
||||
book = Book.objects.create(
|
||||
title=book_title,
|
||||
title=book_title.replace("_", ":"),
|
||||
pages=total_pages,
|
||||
koreader_data_by_hash={
|
||||
str(row[KoReaderBookColumn.MD5.value]): {
|
||||
@ -142,7 +143,9 @@ def build_book_map(rows) -> dict:
|
||||
|
||||
if not book:
|
||||
book = Book.objects.filter(
|
||||
title=book_row[KoReaderBookColumn.TITLE.value].split(" - ")[0]
|
||||
title=book_row[KoReaderBookColumn.TITLE.value]
|
||||
.split(" - ")[0]
|
||||
.lower()
|
||||
).first()
|
||||
|
||||
if not book:
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
# Generated by Django 4.2.16 on 2024-10-17 20:08
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("books", "0020_author_comicvine_data_book_comicvine_data_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="book",
|
||||
name="koreader_authors",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="book",
|
||||
name="koreader_id",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="book",
|
||||
name="koreader_md5",
|
||||
),
|
||||
]
|
||||
@ -101,10 +101,6 @@ class Book(LongPlayScrobblableMixin):
|
||||
title = models.CharField(max_length=255)
|
||||
authors = models.ManyToManyField(Author, blank=True)
|
||||
goodreads_id = models.CharField(max_length=255, **BNULL)
|
||||
# All individual koreader fields are deprecated
|
||||
koreader_id = models.IntegerField(**BNULL)
|
||||
koreader_authors = models.CharField(max_length=255, **BNULL)
|
||||
koreader_md5 = models.CharField(max_length=255, **BNULL)
|
||||
koreader_data_by_hash = models.JSONField(**BNULL)
|
||||
isbn = models.CharField(max_length=255, **BNULL)
|
||||
pages = models.IntegerField(**BNULL)
|
||||
|
||||
Reference in New Issue
Block a user