Skip to content

Instantly share code, notes, and snippets.

@conoro conoro/
Last active Feb 3, 2018

What would you like to do?
Get YouTube. Tiny wrapper on youtube-dl for running on Android and prompting for URL
# Wrapper around youtube-dl for Android
# Grabs URL from clipboard if it's a YouTube one. Otherwises prompts for URL
# See for instructions
# Copyright Conor O'Neill 2018. Apache License 2.0:
from __future__ import unicode_literals
from androidhelper import Android
droid = Android()
import youtube_dl
def input_default(prompt, default):
return raw_input("%s [%s] " % (prompt, default)) or default
# If clipboard URL is a YouTube one, grab it and automatically download
if droid.getClipboard().result.startswith('https://youtu'):
url = droid.getClipboard().result
# Either the clipboard is empty or it has a non-YouTube URL. User must paste the required URL.
url = raw_input("YouTube URL?: ")
ydl_opts = {
'nocheckcertificate': True,
'outtmpl': '%(title)s.%(ext)s'
with youtube_dl.YoutubeDL(ydl_opts) as ydl:[url])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.