Save progress information from imports.

This commit is contained in:
Adam Kelly
2020-04-15 12:13:38 +01:00
parent 60f0aa207d
commit 53ff28b5dc
3 changed files with 27 additions and 2 deletions

View File

@ -2,9 +2,10 @@
import re
import csv
import itertools
import dateutil.parser
from fedireads import books_manager
from fedireads.models import Edition
from fedireads.models import Edition, ReadThrough
# Mapping goodreads -> fedireads shelf titles.
@ -99,6 +100,25 @@ class GoodreadsItem:
def rating(self):
return int(self.line['My Rating'])
@property
def date_added(self):
if self.line['Date Added']:
return dateutil.parser.parse(self.line['Date Added'])
@property
def date_read(self):
if self.line['Date Read']:
return dateutil.parser.parse(self.line['Date Read'])
@property
def reads(self):
return [ReadThrough(
# Date added isn't the start date, but it's (perhaps) better than nothing.
start_date=self.date_added,
finish_date=self.date_read,
pages_read=None,
)]
def __repr__(self):
return "<GoodreadsItem {!r}>".format(self.line['Title'])