Introduction: Download YouTube Videos or Extract MP3s on IPhone Using A-Shell and Yt-dlp

If you want to download YouTube videos or extract MP3 audio directly to your iPhone, you can do so using the free a-Shell app and the open-source yt-dlp tool. This method works without jailbreaking and provides flexibility similar to a desktop terminal.

Tips

  1. Use only for personal, fair-use downloads.
  2. Some videos may be restricted due to region or age limitations.
  3. Keep yt-dlp updated by re-downloading it from GitHub occasionally.


Supplies

Sources:

  1. a-Shell: https://apps.apple.com/app/id1473805438
  2. yt-dlp: https://github.com/yt-dlp/yt-dlp
  3. iPhone or iPad: Requires iOS 14.0 or later

Step 1: Installing Yt-dlp in A-Shell

  1. Install the a-Shell app
  2. Open the App Store and install a-Shell, a local terminal emulator for iOS.
  3. Launch a-Shell and set up the directory
  4. Open the app and run the following commands one by one:
mkdir ~/Documents/bin
cd ~/Documents/bin
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O
chmod +x yt-dlp
cd ~/Documents
  1. Test yt-dlp functionality
  2. Try downloading a video:
yt-dlp "https://www.youtube.com/watch?v=G1oxqQj8tuI"
  1. Try extracting MP3:
yt-dlp -x --audio-format mp3 --audio-quality 0 -P ~/Documents/ "https://www.youtube.com/watch?v=G1oxqQj8tuI"
  1. Your files will appear in the a-Shell directory under Files > On My iPhone > a-Shell. If playback fails in the default player, try using VLC or IINA.


Step 2: Creating an IOS Shortcut to Automate Downloads

Open the Shortcuts app and create a new shortcut

Add an input step

  1. Add "Ask for Input", set the prompt to YouTube URL.

Add a menu to choose download type

  1. Add "Choose from Menu" with two options:
  2. Extract MP3
  3. Download Video

For "Extract MP3" option

  1. Use the "Execute Command" action (becomes available with the installation of a-Shell):
yt-dlp -x --audio-format mp3 --audio-quality 0 -P ~/Documents/ "Ask for Input"

For "Download Video" option

  1. Similarly (note that "Ask for Input" is a Selectable Variable):
yt-dlp -P ~/Documents/ "Ask for Input"

Finish the menu and save your shortcut

  1. Label it something like "YT-DLP"

Optionally add Home Screen widget "Shortcuts" to have a quick way of accessing your latest shortcuts!