made it so i just click file and paste YouTube url

Linux is amazing

#! /usr/bin/bash
echo "Enter a url"
read a

yt-dlp -x $a
  • hoppolito@mander.xyz
    link
    fedilink
    English
    arrow-up
    50
    ·
    16 hours ago

    Very happy you had fun making the little script! One thing that will become important pretty quick if you continue making these scripts is that it’s almost always better to wrap your variables in quotes - so it becomes yt-dlp -x “$a. It’s okay here but if you ever paste something that has a space in it, this will keep it together ‘as one’.

    If you want to expand your knowledge with this, some fruitful paths to go down are the following:

    • can you find a way to download multiple urls one after the other if you paste them all at once? (Multiple arguments)
    • can you find a way to ask the user for these multiple urls one after the other? (loops)
    • and can you find a way to have it ask until you hit enter without a url pasted and only then it starts? (conditionals and test)

    The last one is already quite a bit advanced but if you can do that you have enough of the ‘programming’ basics of the shell down to a degree that you can create many little helpers like this with ease.

    Of course don’t feel forced to do any of that - if you’re happy with the improvement as-is, that’s all you need to enjoy the fun of Linux!

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      12 hours ago

      One thing that will become important pretty quick if you continue making these scripts is that it’s almost always better to wrap your variables in quotes - so it becomes yt-dlp -x “$a.

      Oh man, this reminds me of the joke that any program that’s more complex than Hello World has bugs – and folks still don’t even agree how to spell “Hello, World!”.

      Of course, Bash is a particular minefield in this regard…

      • 18107@aussie.zone
        link
        fedilink
        English
        arrow-up
        13
        ·
        12 hours ago

        I once wrote a 2 line, 10 word script that had 9 bugs in it. I’m not overly proud of that one.

        • draco_aeneus@mander.xyz
          link
          fedilink
          arrow-up
          3
          ·
          7 hours ago

          I think you might have a career as an accomplished entymologist ahead of you with so much success finding bugs!