Skip to content

Instantly share code, notes, and snippets.

@gitcrtn
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitcrtn/7dd47ef877e79cb529cd to your computer and use it in GitHub Desktop.
Save gitcrtn/7dd47ef877e79cb529cd to your computer and use it in GitHub Desktop.
動画をDL
# main.py
# クリップボードに動画のURLをコピーしておいてから、run.batをクリックするとDLが開始されます
import os
import win32clipboard
ytdl = '\"C:\\bin\\youtube-dl.exe\" -f best '
vdir = 'C:\\video'
def adjustURL(url):
splt = url.split('?')
prm = splt[1].split('&')
prm_v = None
for p in prm:
if p[:2] == 'v=':
prm_v = p
break
if prm_v:
url = splt[0] + '?' + prm_v
return url
def main():
win32clipboard.OpenClipboard()
url = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
if 'www.youtube.com' in url:
url = adjustURL(url)
cmd = ytdl + url
print 'URL:', url
print 'CMD:', cmd
os.chdir(vdir)
os.system(cmd)
if __name__=='__main__': main()
C:\Python27\python.exe main.py
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment