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

Find out if CrowCamKeepAlive is even still needed. Either fix or remove it (and YouTube-DL) #70

Closed tfabris closed 5 months ago

tfabris commented 5 months ago

There is a possibility that, since it's been a few years since I wrote it, YouTube might have potentially fixed the bug that required me to write CrowCamKeepAlive in the first place.

The bug was: If nobody is watching the stream, then the "DVR functionality" of the stream (being able to scroll back in time) doesn't work until after somebody joins the stream. It's almost like YouTube doesn't bother caching the past video chunks if there's nobody actively watching them at the time.

To Do:

If CrowCamKeepAlive is no longer needed:

If CrowCamKeepAlive is needed:

The CrowCam instructions currently say to get the latest version of Youtube-DL with these commands:

Get YouTube-dl:

YouTube-dl is a third party program which downloads video streams and other information from YouTube. We use it for checking and connecting to the YouTube live stream in an automated fashion. It is used for checking whether the stream is up, and for making sure that the stream's DVR cache stays functional at all times. Obtain the Linux and Windows binary executables of youtube-dl (one file each, "youtube-dl" and "youtube-dl.exe") and place them in the same folder as these scripts. Youtube-dl is obtained either by grabbing both files from the YouTube-dl web site, or by issuing these commands at the Bash shell prompt in the same directory as these script files:

 wget https://yt-dl.org/downloads/latest/youtube-dl -O ./youtube-dl
 wget https://yt-dl.org/downloads/latest/youtube-dl.exe -O ./youtube-dl.exe

Under the hood, the CrowCam code periodically does something similar, keeping the tool updated. However, this stopped working at some point in late 2021, and now, if you try to download youtube-dl using the commands above, you get an error, saying, "Access denied - Due to a ruling of the Hamburg Regional Court, access to this website is blocked."

To work around this, try to update the CrowCam code and instructions to use YT-DLP instead of YouTube-DL, which can still be retrieved. Here is some powershell code (ganked from a different project of mine) which shows how to retrieve the latest one of these files. You will need to convert this code into Bash code:

  # 2023-08-03 - I discovered that yt-dlp is better than yt-dl and I am switching to that one.
  $nightlyBuilds = "https://github.com/yt-dlp/yt-dlp/releases/latest/"

  # The nightly build URL above redirects to something like
  #     https://github.com/ytdl-org/ytdl-nightly/releases/tag/2023.07.21
  # Retrieve it into a string.
  $nightlyRedirect = ([System.Net.WebRequest]::Create($nightlyBuilds)).GetResponse().ResponseUri.OriginalString
  Write-Host "Latest nightly build of yt-dlp is at: $nightlyRedirect"

  # The URL has to be modified in order to actually download the file itself.
  #    https://github.com/ytdl-org/ytdl-nightly/releases/tag/2023.07.21
  #    https://github.com/ytdl-org/ytdl-nightly/releases/download/2023.07.21/youtube-dl
  $nightlyRedirect = $nightlyRedirect.replace('/yt-dlp/releases/tag/','/yt-dlp/releases/download/')

  # Download the EXEs directly for Unix and Windows.
  # 2023-08-03 - Changing to YT-DLP instead of Youtube-DL.
  $nightlyDownloadUrl = $nightlyRedirect + "/yt-dlp"
  UpdateInternetFile $nightlyDownloadUrl "yt-dlp"
  $nightlyDownloadUrl = $nightlyRedirect + "/yt-dlp.exe"
  UpdateInternetFile $nightlyDownloadUrl "yt-dlp.exe"

Of course, you need to make sure that YT-DLP will function for your purposes first. Not sure if it will.

tfabris commented 5 months ago

This morning I was able to jump onto the stream about 1-2 hours after the stream had started. There was no one else watching the stream and I was its only viewer. The DVR functionality worked fine all the way back to the sunrise moment. I think this issue is fixed on YouTube's side and we no longer need CrowCamKeepAlive or YouTube-dl. I have removed CrowCamKeepAlive with 646a78c.

I've got the script squirreled away on my personal hard disk in a folder named "CrowCam\Old Script Versions" if I ever need it later.