4 ms·
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).
by marmaduke 8y ago
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.
- seddin 8y agoThis is great! Does it also support play background music that you download as a .m4a ?
- marmaduke 8y agoVLC does yes. That said the real issue is that the download part can’t run in background for more than 4 minutes, so you can’t download big videos.
- d0mine 8y agoyou could pass a video url retrieved by youtube-dl to VLC instead of downloading the video.
- Game_Ender 8y agoAnything you can share code wise, curious to learn more.
- d0mine 8y agoHere's an example: #!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))
- marmaduke 8y agoWow 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.