Open tfabris opened 6 months ago
Checkin 010619b should detect when the variable is the wrong format, and print an error message to the log.
To do:
The variable thisStreamId was the wrong length
. See if you can determine the root cause by looking at the full error message. Hopefully the log won't truncate it too much so that you can't see enough of the API response string for diagnosis.Issue could be in the parser, or, it could be that sometimes (intermittently) youTube doesn't put the XML results in pretty print on multiple lines. The log entry contained this:
The liveBroadcastOutput was { "kind": "youtube#liveBroadcastListResponse", "etag": "nnnnnnnnnnnnnnnn", "nextPageToken": "CAUQAA", "pageInfo": { "totalResults": 36, "resultsPerPage": 5 }, "items": [ { "kind": "youtube#liveBroadcast", "etag": "nnnnnnnnnnnnnnnn", "id": "EOPfl7R69mc", "snippet": { "publishedAt": "2024-05-25T20:03:01Z", "channelId": "UCUxIqdJJpXBnjaEy5yq1wZQ", "title": "CrowCam", "description": "Here is a permanent link to the most current live stream: https://www.youtube.com/channel/UCUxIqdJJpXBnjaEy5yq1wZQ/liveVideo history highlights: http://vixyandtony.com/crowcam.html--- Live view of backyard crows and squirrels, Seattle, Washington. The video feed is only live from sunrise to sunset each day, since crows and squirrels are diurnal. The most common species we see at t
The log condenses multiple lines when it prints the log, so I don't know if the liveBroadcastOutput was on multiple lines or not. But I think the behavior indicates that it was indeed on just one line so it grabbed the first variable it found instead of the variable "id" by itself on a line.
To do:
No, looks like the code already uses sed to split the string. I think it's because the "sed" command intermittently fails to split the string at the "id" string. Wow.
Intermittently, when there is some kind of problem with the stream and it has to be bounced or re-created, I sometimes see an error message in the log output that looks similar to this:
Somehow, in the code, after creating the new video ID. we see that the system has the value
youtube#liveBroadcastListResponse
in the variable `$thisStreamId which should be containing the video ID instead. This likely means that the code mis-parsed some response from the YouTube API. Check and see if it somehow blindly accepted an errored-out API response (likely a query to liveBroadcast - List) and didn't do enough bullet-proofing on the response.This appears to be a very similar bug, possibly the same bug, as issue #88 - But I thought I fixed that one with some code changes. Review the changes you made in 88 and see if there's a flaw in your thinking or if perhaps it needs to be improved. For example, at line 1534 we're retrieving
$thisStreamId
thusly:We test to see if the value is empty, but we don't test to ensure that it looks like a YouTube Video ID before pushing onward. I could simply test that and error out if it doesn't match the style of a video ID, but that would be a bandaid on the problem without knowing the root cause.
I'm going to start with the bandaid but then I will add a log entry with the details of the entire
$liveBroadcastOutput
variable printed to the log and see if I can identify the root cause.