I use Android and have Termux[1] installed. If you create a shell script named '~/bin/termux-url-opener' and share URLs to Termux, it'll invoke that script. Here's the contents of mine:
```
#!/bin/bash
pip install --upgrade youtube-dl
cd storage/movies
youtube-dl "${1}"
```
On iOS I’ve installed Pythonista with Stash, pip installed YouTube-dL, set up a script to take a link and download it to mp4 and share it an app (usually VLC).
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.
#!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))
Wow that’s way better than mine. I still find coding with two thumbs on an iPhone se does not fully make use of Pythonista. But there’s no way I’d buy an iPad that doesn’t have BT mouse support.
Did you know iOS podcasts supports video podcasts? Haven’t looked at your code but maybe wouldn’t be too much work to make video work too. I’ll talk a look. Thanks!
I’ve thought that it would be a great way to avoid the algorithm addiction and only see my subs.
I don't know if it applies to the web server, but for the command-line version of youtube-dl, it has a -U option that updates itself. One could create a batch file or shell script that runs that each time, before downloading a video, or do it manually once in a while. Like someone else said, I think the creator updates the app fairly often.
Edit: I had written a post about youtube-dl describing its use a bit, and also a quick look at its code:
It looks like they're installing youtube-dl via apt, from the Ubuntu 16.04 repos (which is what the docker image uses as a base), do even rebuilding wouldn't cut it. I wonder if this will even work out of the box, because YouTube changed something that required youtube-dl to fix a month or two ago.
I was just thinking the other day of writing a small utility to download a YouTube video and metadata, stuff the metadata in a database, and be able to have a local, searchable copy of videos and channels I'd like to have for a while -- I don't trust they'll be around forever.
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.
Having a local, searchable version of some channels would be great, especially if it can be configured to download new videos automatically. Some channels are notorious for having videos deleted (e.g. commentary channels that have to fight with contentid or educational channels that have videos involving gunpowder or uranium). Manually backing them up and organizing the videos is very cumbersome.
Just yesterday I built an Android app to cast audio-only (ogg format) from YouTube to Chromecast. Had to do it because:
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 there a way to download Netflix videos too? My reason is I just can't watch anything at less than 1.5X speed nowadays and Netflix has no such option on mobile (there is a chrome extension though). Any ideas how to do either (dl or increase playback speed on mobile)
Yes I have. I often watch video tutorials at 4X speed (chrome used to cut off audio after that so I couldn't go over that limit).
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)
It it's not uncommon to habitually listen to podcasts at that speed, and after a while you get used to it and everything else just sounds slow. Not exactly intentional, rather a side effect of something that made sense by itself.
This is fine for podcasts, lectures and books where the purpose is to take in information. Timing in movies and TV shows is important; silences and slow pans are placed there for a reason. I can't imagine why one would watch a movie or TV show at 1.5x when the purpose isn't to take in information, but to enjoy artwork.
SD/720p/1080p netflix can be de-drm'd losslessly, there's no capture/re-encode step needed (...if you know the technique, I don't but assume it involves the download to watch offline feature).
+1. The lack of 2x playback speed makes documentaries on Netflix unwatchable. Third-party Chrome extensions of unknown origin doesn't seem like a good idea.
Unfortunately, easier to stick to YouTube and VLC for documentary watching.
Get Greasemonkey and you can limit the video speed controller to certain websites or turn it off when you're not using it. (And also disable auto update of the script).
For instance if you run this on your desktop you could bookmark "http://local-desktop-ip:3000" on your mobile device and be able to download videos while on mobile.
built a simple MacOS Safari extension that sends the current url to my server, which then runs a simple script to download using youtube-dl. I then use my iPad to view the videos using the nPlayer which can read NFS shares. very useful for downloading and viewing videos from variety of "alternate" video sites
How could it not be? You "download" the stream every time you watch it. It's to everyone's benefit to cache it if you want to watch it more than once. That way you don't use that much bandwidth. You might be served less ads, but you shouldn't be watching them anyway.
The law can make a distinction between bits you downloaded to cache the video as you streamed it, and bits you downloaded to keep a copy offline. Of course, the result is similar- you have a copy of it on your hard drive somewhere- but the actions you took are different, your intentions are different, and the law can look at those things if it wants (which it does, all the time).
Probably only on creative commons-licensed videos (there are some). Otherwise, it might be an unlawful replication.
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. :)
Despite all the comments pretending this is all super ok scrapers are obviously not aboveboard. Sites may try to place limits on you or your account but it is unlikely you will go to court over a TOS violation unless you're really abusive.
Streamed bits might have different Colour than bits downloaded through youtube-dl, even if they're the same bits. It depends on your legal jurisdiction.
``` #!/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