tfabris / CrowCam

A set of Bash scripts to control and maintain a YouTube live cam from a Synology NAS.
GNU General Public License v3.0
3 stars 3 forks source link

Investigate if you can leverage "recordingDate" for uploaded videos. #58

Closed tfabris closed 4 years ago

tfabris commented 4 years ago

CrowCam Archives playlist is mostly populated with live videos. Live videos, have this part:

 "liveStreamingDetails": {
    "actualStartTime": datetime,
    "actualEndTime": datetime,

I have stuck a few hand-edited videos into the playlist. Those do not have that part. They have a different part that the first one does not have:

  "recordingDetails": {
    "recordingDate": datetime

Notes:

I can query for both sets at the same time by doing this, and then parsing the results: curlUrl="https://www.googleapis.com/youtube/v3/videos?part=liveStreamingDetails,recordingDetails&id=$oneVideoId&access_token=$accessToken"

See if you can get both working. The trick is that there's no "end time" for the second one, and you need to be able to handle special cases, and handle the caching. Not sure if this is feasible.

Alternative idea: See if there is a way to force-insert the "actualStartTime" and "actualEndTime" into an uploaded video. Then the code doesn't have to change, you just have to edit the video (perhaps with a side piece of new code). (Edit: I looked. No, you can't update those values, you can only update recordingDate.)

tfabris commented 4 years ago

I am in-process now, with checking in code, which addresses this. It works in my localhost tests.

The code works like this:

To do:

tfabris commented 4 years ago

I think the code as-checked-in will have a bug if run in production.

The way it caches the time stamps, if it caches a “live in-progress” livestream, then it will be caching a start time with no end time. Then, when the live stream is done and it gets an end time, the cache won’t be re-updated because it contains a value in that slot. The video will be destined to never register as having an end time in the cache.

Solution will be to always recheck for an end time if the start time doesn’t look like a recordingDate value. (recordingDate values look like a good date but time stamp of 0Zulu).

This solution will have a drawback, which is that, if a video livestream in-progress comes along, which really did start at 0Zulu (about 4pm pst during winter), then the cache won’t get refreshed for that item and it’ll be stuck. Consider if this is a rare enough problem. Consider always re-querying items with no actualEndTime at the cost of some quota.

tfabris commented 4 years ago

Idea: if there is a real live-in-progress video that really started at 0Zulu, then it’s end time will be updated within 24 hours. So if you want to requery the 0Zulu entries, only do so for entries which are less than 24h old.

tfabris commented 4 years ago

Checked in:

To do:

tfabris commented 4 years ago

Code is checked in which should theoretically fully address all remaining issues.

To do: