Report errors when an account has been terminated

This commit is contained in:
Cadence Ember 2022-01-10 13:02:08 +13:00
parent 0a13ab88cb
commit 36ae18c12f
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17
1 changed files with 8 additions and 0 deletions

View File

@ -29,6 +29,11 @@ def extract_channel(ucid):
"error": alert_text, "error": alert_text,
"identifier": "NOT_FOUND" "identifier": "NOT_FOUND"
} }
elif alert_text.startswith("This account has been terminated"):
return {
"error": alert_text,
"identifier": "ACCOUNT_TERMINATED"
}
else: else:
print("Seen alert text '{}'".format(alert_text)) print("Seen alert text '{}'".format(alert_text))
@ -165,6 +170,9 @@ def extract_channel_latest(ucid):
with requests.get("https://www.youtube.com/feeds/videos.xml?channel_id={}".format(ucid)) as r: with requests.get("https://www.youtube.com/feeds/videos.xml?channel_id={}".format(ucid)) as r:
if r.status_code == 404: if r.status_code == 404:
cherrypy.response.status = 404 cherrypy.response.status = 404
# write out page data for debugging
with open("channel_not_found_{}.xml".format(ucid), "wb") as f:
f.write(r.content)
return { return {
"error": "This channel does not exist.", "error": "This channel does not exist.",
"identifier": "NOT_FOUND" "identifier": "NOT_FOUND"