nymsalt.nekoweb.org

how to make youtube hate you

youtube hates her! see how to do so too with one weird trick! (downloading a whole lot of youtube videos)

da problem

i hav an ipod.

and i want to put music on it, but there isn't any third-party program to do it (i think that's the case for the nano 7g), and the itunes app is windows only, so, on linux, i have to go through a vm. unfortunately (or fortunately, depending on the perspective), i have to go through a tedious process.

it kinda sucks putting music onto this ipod; so much so that i didn't add to it for a few months.

part of that process is downloading youtube videos, but it takes so long. find a video, get the url, yt-dlp, rename the file through my file manager, find a video, get the url, yt-dlp, rename the file through my file manager, find a video, get the url, yt-dlp, rename the file through my file manager...

the process works! but it gets tiring pretty quick. i picked up a standard format of [artists] - [name] because i wanna go back to them again. if only there was a solution...

da solution

let's make a script :3

i don't want it to be overengineered (like being made with rust), and i don't want to implement a lot of logic. and i'd like a way to quickly add songs. just quick and easy.

so i chose nushell. and csv.

# download.nu

def main [] {}

def "main music" [csv: path, hq: bool = false] {
  let table = cat $csv | from csv
  mut x = 0;
  while $x < ($table | length) {
    let v = $table | get $x
    let artists: string = $v | get artists
    let name: string = $v | get name
    let yturl: string = $v | get yturl
    let filename = $"($artists) - ($name)"

    if ($"("./out" | path expand)/($filename).m4a" | path exists) {
      $x += 1
      continue
    }

    yt-dlp --ppa "ThumbnailsConvertor+FFmpeg_o:-c:v mjpeg -vf crop=\"'if(gt(ih,iw),iw,ih)':'if(gt(iw,ih),ih,iw)'\"" --convert-thumbnail jpg --embed-thumbnail -o ($"("./out" | path expand)/($filename)" | append '.%(ext)s' | str join "") -f 140 $yturl
    $x += 1
  }
}

(the yt-dlp line is from two people on github i think (one for the low quality download, one for the thumbnail)? i forgot the source.)

it's a bit odd (e.g., hq isn't used), and a bit bad, but it works really well.

(at some points youtube blocks the thing because adblock and stuff and what not but i can just rerun the script again since it skips over the files that already exists)

nushell is really good for handling data and also making me stay sane (bash does not make me feel the same way). and csv is good because it's really simple.

i can edit a csv file (through some spreadsheet software) like:

artists,name,yturl
vivivivivi,demonic little grey cat theme song,https://youtu.be/-vJ0NMOH2vA

and feed it in like:

nu download.nu music batch0.csv

and voila. an m4a file, cropped into a square, and auto-renamed for my naming style. i mean, it's great; i just added 100 songs to my ipod lol.

a number showing 101, the number of rows in the csv

whoops.

extra: rockbox

STILL NO PROGRESS GWAHHHH

(but they did just have a release for the first time in years so that's cool i guess)