• Operand
  • # (b)ring mi - belles.

gram:build

> ./config/nushell/media.nu

Lenses
(coming soon!)


source ./day.nu
def channels [] { echo "needs encoding!" }

def "media place" [address: string, --base: string] {
  let normal = "~/disc/nvme0n1p5/media" | path expand
  if not ($normal | path exists) { disc bind nvme0n1p5 }
  let base = $normal
#  if ($base == 'harbor') { bind media ~/media; echo ~/media | path expand
#  } else { }

  [ $base youtube.com (basename $address) ] | path join | path expand }

def "media base" [place?: path, --base: string] { (media place --base $base $place) | path dirname }

def "media address" [address: string, place?: path, --base: string] {
  let place = if ($place | is-empty) { media place --base $base $address } else { $place }
  mkdir $place; cd $place;
  print; print; print "----"
  print $"# [media address] Pulling ($address) -> ($place)"

  (nsh yt-dlp yt-dlp

    --break-per-input # ... see `help yt-dlp`.
    --check-all-formats # ... see `help yt-dlp`.
    --check-formats # ... see `help yt-dlp`.
    --embed-thumbnail # ... see `help yt-dlp`.
    --no-resize-buffer # ... see `help yt-dlp`.
# --yes-playlist # ... see `help yt-dlp`.
    --prefer-free-formats # ... see `help yt-dlp`.
    --live-from-start # ... see `help yt-dlp`.

# log all enabled media encodings
# and capción languages.
# --list-formats
# --list-subs
# --sub-langs all # ... see `help yt-dlp`.
# --write-auto-subs # ... see `help yt-dlp`.

# slice open media packages,
# and pull an audio copy.
    --extract-audio
    --keep-video

    --lazy-playlist # ... see `help yt-dlp`.

# ensure copies are made using closed capcións
# include as many languages as possible.
# [chec] are dubbed audio copies included as an opción?
    --write-pages # ... see `help yt-dlp`.
    --write-subs # ... see `help yt-dlp`.

# log each, and record names and hashes in a cache.
    --download-archive $"(media base --base $base $place)/arc.log"

# signal dials - message packaging.
    --retries 24
# --http-chunk-size 8M
# --buffer-size 16384 # ... see `help yt-dlp`.
    --retry-sleep 12 # ... see `help yt-dlp`.
# --limit-rate 300M
# --throttled-rate 128M

    $address # a generic online media address;
    # many domains are already enrolled.

  ) | tee { save $"($place)/(day local).pull.log" } | print;
  $place
}

def "media channel" [...channels: string, --base: string] {
  $channels | each {|channel| media address --base $base $"https://youtube.com/@($channel)" }
}