Skip to content

Commit

Permalink
Update x_scheduler.py
Browse files Browse the repository at this point in the history
Fix issues where db column is none and trying to +1
  • Loading branch information
frankyrumple authored Aug 27, 2023
1 parent d10e7b7 commit cbb9b48
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions web2py/applications/smc/models/x_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ def process_youtube_queue(run_from=""):
r = pull_youtube_video(next_row) #next_row.youtube_url, next_row.media_guid)
except Exception as ex:
# Had issues downloading from youtube.
next_row.download_failures = next_row.get("download_failures", 0) + 1
next_row.download_failures = next_row.get("download_failures", 0) or 0 + 1
# if next_row.download_failures > 5:
# next_row.needs_downloading = False
next_row.update_record()
Expand Down Expand Up @@ -1374,15 +1374,15 @@ def pull_youtube_video(media_file, force_video=False, force_captions=False):
log_to_video(media_file, f"Failed to download video from {yt_url}, will stop trying.")
media_file.needs_downloading = False
media_file.needs_caption_downloading = False
media_file.download_failures = media_file.get("download_failures", 0) + 1
media_file.download_failures = media_file.get("download_failures", 0) or 0 + 1
media_file.update_record()
db.commit()
return True
elif return_code == "Termporary Error":
print(f"Temporary Error - Unable to get video {yt_url}.")
log_to_video(media_file, f"Failed to download video from {yt_url}, will keep trying.")
media_file.needs_downloading = True
media_file.download_failures = media_file.get("download_failures", 0) + 1
media_file.download_failures = media_file.get("download_failures", 0) or 0 + 1
media_file.update_record()
db.commit()
return True
Expand All @@ -1392,7 +1392,7 @@ def pull_youtube_video(media_file, force_video=False, force_captions=False):
print(f"Unknown HTTP error pulling yt video? {yt_url}\n{ex}")
log_to_video(media_file, f"Unknown Error - Failed to download video from {yt_url}, will keep trying.\n{ex}")
media_file.needs_downloading = True
media_file.download_failures = media_file.get("download_failures", 0) + 1
media_file.download_failures = media_file.get("download_failures", 0) or 0 + 1
media_file.update_record()
db.commit()
return False
Expand Down Expand Up @@ -1512,15 +1512,15 @@ def pull_youtube_video(media_file, force_video=False, force_captions=False):
print(f"Permanent Error - Unable to get captions {yt_url}.")
log_to_video(media_file, f"Failed to download captions from {yt_url}, will stop trying.")
media_file.needs_caption_downloading = False
media_file.download_failures = media_file.get("download_failures", 0) + 1
media_file.download_failures = media_file.get("download_failures", 0) or 0 + 1
media_file.update_record()
db.commit()
return True
elif return_code == "Termporary Error":
print(f"Temporary Error - Unable to get captions {yt_url}.")
log_to_video(media_file, f"Failed to download captions from {yt_url}, will keep trying.")
media_file.needs_caption_downloading = True
media_file.download_failures = media_file.get("download_failures", 0) + 1
media_file.download_failures = media_file.get("download_failures", 0) or 0 + 1
media_file.update_record()
db.commit()
return True
Expand All @@ -1530,7 +1530,7 @@ def pull_youtube_video(media_file, force_video=False, force_captions=False):
print(f"Unknown HTTP error pulling yt captions? {yt_url}\n{ex}")
log_to_video(media_file, f"Unknown Error - Failed to download captions from {yt_url}, will keep trying.\n{ex}")
media_file.needs_caption_downloading = True
media_file.download_failures = media_file.get("download_failures", 0) + 1
media_file.download_failures = media_file.get("download_failures", 0) or 0 + 1
media_file.update_record()
db.commit()
return False
Expand Down

0 comments on commit cbb9b48

Please sign in to comment.