``` #!/bin/bash
pip install --upgrade youtube-dl cd storage/movies youtube-dl "${1}" ```
Works a treat!
[1] Termux (Terminal emulator with packages) - https://f-droid.org/app/com.termux, https://play.google.com/store/apps/details?id=com.termux
This can be triggered from YouTube app by pressing Share, then Pythonista script then the custom script, wait for download then select VLC.
It’s not great for big videos but was extremely satisfying to set up.
To watch I use NewPipe instead of the official YouTube client.
https://github.com/frou/yt2pod
If you find yourself often having your phone in your pocket with the screen blazing, just to be able to listen to YT content, you might like it.
(it's on the todo list to Dockerize it)
I’ve thought that it would be a great way to avoid the algorithm addiction and only see my subs.
https://github.com/frou/yt2pod/blob/31b55410c38dbf655b641eee...
Add this per-podcast in the config file:
"vidya": true
I hear you about not wanting to spend too much time in the circus.
How is this handled here? Is periodically kill / restart the container enough?
I was thinking it could be better if the utility would be more useful if it integrated with mythtv, but I might start as a standalone.
1. Baby needs her white noise to sleep
2. No other sites have those "8 hours womb sounds" as good as YouTube
3. The YouTube app refuses to cast to Google Home mini
Came across ydls[1] which uses youtube-dl and ffmpeg to download then transcode media on-the-fly. It's not very effective but works great! We no longer have to turn on the TV in our baby room. Check out the source code[2] if you are also a new parent.
Is this something you've trained yourself to do...? Like deliberately?
Nowadays i even watch movies at 1.5x speed and it looks very normal to me. Once you get used to it you can't have it any other way (especially documentaries and slow movies)
They're not about to make their method public though, and last I read up on it I don't think they can do 4k? But SD/720p/1080p is all there.
Unfortunately, easier to stick to YouTube and VLC for documentary watching.
In the UK, it's only legal if it's for 'time-shifting' with the expectation the recording is only watched once and then deleted:
https://www.gov.uk/guidance/exceptions-to-copyright#time-shi...
And yes, there will be arguments about how you're just saving to a file what otherwise comes in via the player. I honestly don't know the definitive answer. :)
Edit: I had written a post about youtube-dl describing its use a bit, and also a quick look at its code:
youtube-dl, a YouTube downloader in Python:
https://jugad2.blogspot.com/2013/03/youtube-dl-yourube-downl...
Also check out: pafy - Python API for YouTube:
https://jugad2.blogspot.com/2014/06/pafy-python-api-for-yout...
Edit 2: And this might be of use:
How to download PyCon US 2013 videos for offline viewing using youtube-dl:
https://jugad2.blogspot.com/2013/04/how-to-download-pycon-us...
https://github.com/rg3/youtube-dl/commits/master/youtube_dl/...
So if you ever run into issues you would just pull the latest container.
#!python3
"""Open url in VLC — Pythonista for iOS app extension.
1. take media url from appex(share)/clipboard/command-line
2. open it in VLC iphone app
e.g., to listen to Youtube video in the background.
It accepts a media url from any site supported by youtube_dl
https://rg3.github.io/youtube-dl/supportedsites.html
"""
import sys
from urllib.parse import quote
import youtube_dl
import appex
import clipboard
import console
import appex_webbrowser as webbrowser
def open(webpage_url):
"""Play media on *webpage_url* in VLC"""
with youtube_dl.YoutubeDL(dict(forceurl=True)) as ydl:
r = ydl.extract_info(webpage_url, download=False)
media_url = r['formats'][-1]['url']
# play the url in VLC
# vlc:// + url leads to a popup
# https://wiki.videolan.org/Documentation:IOS/#x-callback-url
webbrowser.open('vlc-x-callback://x-callback-url/stream?url=' + quote(media_url) )
def main():
if not appex.is_running_extension():
if len(sys.argv) == 2:
url = sys.argv[1]
else:
url = clipboard.get()
else:
url = appex.get_url() or appex.get_text()
if url:
open(url)
console.hud_alert('Done.')
else:
console.hud_alert('No input URL found.')
if __name__ == '__main__':
console.show_activity()
try:
main()
finally:
console.hide_activity()
where appex_webbrowser.py is: """webbrowser.open() replacement for app extensions in Pythonista for iOS.
"""
from objc_util import nsurl,UIApplication
def open(url):
app = UIApplication.sharedApplication()
app.openURL_(nsurl(url))except for those times it downloads a youtube-dl binary.
https://github.com/przemyslawpluta/node-youtube-dl/blob/mast...