You get your results, now hover on the link to one of the videos you're thinking of watching, and copy the link. Paste that :
https://www.youtube.com/watch?v=9h3lByx59ns
Now, hack that to be
https://www.youtube.com/embed/9h3lByx59ns
That's it! "watch?v=" becomes "/"
No more torture! Wait! When I try this, I see "Error 153". Aha - good old ad network got you :) Easy - just open up a new window using CTRL-SHIFT-N - for incognito and try the paste again (yes, you should have a shortcut that takes xyz/watch to xyz/embed :) and... See? :)
How about this for a cool one - did you want to listen to a YouTube video and not have to waste power on the screen? Now you can :
You go to Safari and put in youtube.com. Good. Now, the site comes up and, you then tap on the AA on the left of the address bar. That brings up a menu on which you can select "Request Desktop Website". That's it! You're now in business. Yes, it's harder to read stuff because it's your tiny screen and you've "asked for it," but, now, once you start playing the video and it pauses after you lock the screen. You just swipe and tap play to get it rolling again! Nice?
Help, I just want to download the audio for a YouTube video. No problem, mate, this script got your back:
#!/usr/bin/env python3
"""
Download the audio track of a YouTube video.
Usage:
python3 script.py
The may include (or omit) an extension.
If no extension is given, “.mp3” is added automatically.
Example:
python3 script.py https://youtu.be/dQw4w9WgXcQ rickroll
→ creates rickroll.mp3
"""
import sys
from pathlib import Path
from yt_dlp import YoutubeDL
def main() -> None:
if len(sys.argv) != 3:
sys.exit("Usage: python3 script.py ")
url = sys.argv[1]
target = Path(sys.argv[2])
# Ensure filename has an extension
if target.suffix == "":
target = target.with_suffix(".mp3") # default extension
# yt-dlp options: best audio, save exactly to the requested path,
# and convert/encode to MP3 (needs FFmpeg in PATH)
ydl_opts = {
"format": "bestaudio/best",
"outtmpl": str(target), # absolute path allowed too
"postprocessors": [
{
"key": "FFmpegExtractAudio",
"preferredcodec": target.suffix.lstrip("."),
"preferredquality": "192",
}
],
# supress noisy progress printing if you like:
# "quiet": True,
# "no_warnings": True,
}
with YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
print(f"✅ Saved as {target}")
if __name__ == "__main__":
main()
No comments:
Post a Comment