Skip to content

Commit

Permalink
Merge pull request #191 from deldesir/deldesir-patch-44
Browse files Browse the repository at this point in the history
Ensure error and live_status columns are created from the start
  • Loading branch information
holta authored Jul 23, 2024
2 parents 61fc505 + 86fa47a commit 52285cf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cps/tasks/metadata_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ def _fetch_requested_urls(self, conn):
try:
cursor = conn.execute("PRAGMA table_info(media)")
self.columns = [column[1] for column in cursor.fetchall()]
query = ("SELECT path, duration, live_status FROM media WHERE error IS NULL AND path LIKE 'http%'"
if "error" in self.columns
else "SELECT path, duration, live_status FROM media WHERE path LIKE 'http%'")
if "live_status" not in self.columns:
conn.execute("ALTER TABLE media ADD COLUMN live_status TEXT")
if "error" not in self.columns:
conn.execute("ALTER TABLE media ADD COLUMN error TEXT")
query = "SELECT path, duration, live_status FROM media WHERE path LIKE 'http%' AND (error IS NULL OR error = '')"
rows = conn.execute(query).fetchall()
requested_urls = {}
for path, duration, live_status in rows:
Expand Down

0 comments on commit 52285cf

Please sign in to comment.