Last active
August 29, 2015 14:15
-
-
Save gitcrtn/7dd47ef877e79cb529cd to your computer and use it in GitHub Desktop.
動画をDL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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