Updating the SQLAlchemyPipeline to use properly TvShowDB and LinkDB

This commit is contained in:
edipretoro 2026-01-02 15:10:56 +01:00
parent d8d8109cdc
commit 1d0cb8ed5d

View File

@ -117,11 +117,20 @@ class SQLAlchemyPipeline:
show = session.scalars(stmt).first() show = session.scalars(stmt).first()
print(f"{show=}") print(f"{show=}")
if not show: if not show:
show = TvShowDB(**item) show = TvShowDB(
post_id=item["post_id"],
post_title=item["post_title"],
title=item["title"],
date=item["date"],
summary=item["summary"],
image_url=item["image_url"],
links=[LinkDB(link=url) for url in item["download_url"]]
)
session.add(show) session.add(show)
else: else:
for key, value in item.items(): for key, value in item.items():
setattr(show, key, value) if key != "download_url":
setattr(show, key, value)
session.commit() session.commit()
except Exception as e: except Exception as e:
session.rollback() session.rollback()