Skip to content

Commit

Permalink
douban import: handling more parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Their Name authored and alphatownsman committed Nov 20, 2023
1 parent 59aaec8 commit 0d5613a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions journal/importers/douban.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,19 @@ def import_mark_sheet(self, worksheet, shelf_type, sheet_name):
url = cells[3]
time = cells[4]
rating = cells[5]
rating_grade = int(rating) * 2 if rating else None
try:
rating_grade = int(rating) * 2 if rating else None
except:
rating_grade = None
tags = cells[6] if len(cells) >= 7 else ""
tags = tags.split(",") if tags else []
comment = cells[7] if len(cells) >= 8 else None
self.processed += 1
if time:
try:
if type(time) == str:
time = datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
time = time.replace(tzinfo=_tz_sh)
else:
except:
time = None
r = self.import_mark(url, shelf_type, comment, rating_grade, tags, time)
if r == 1:
Expand Down Expand Up @@ -319,7 +322,7 @@ def get_item_by_url(self, url):
except Exception as e:
logger.error(f"fetching exception: {url} {e}")
if item is None:
self.failed.append(url)
self.failed.append(str(url))
return item

def import_review(self, entity_title, rating, title, review_url, content, time):
Expand Down

0 comments on commit 0d5613a

Please sign in to comment.