Created
November 26, 2017 01:26
-
-
Save nenodias/82683be2a63bbafcbb266330de2e9a02 to your computer and use it in GitHub Desktop.
YoutubePython
This file contains hidden or 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
| import sys | |
| from pytube import YouTube | |
| ''' | |
| yt = YouTube("https://www.youtube.com/watch?v=JGXi_9A__Vc") | |
| ''' | |
| if __name__ == '__main__': | |
| url = sys.argv[1] | |
| yt = YouTube(url) | |
| if yt: | |
| print('Downloading {0}'.format(yt.title)) | |
| yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download() | |
| lista_linguagens = ['pt-BR', 'pt-PT', 'en'] | |
| for linguagem in lista_linguagens: | |
| caption = yt.captions.get_by_language_code(linguagem) | |
| if caption: | |
| with open(yt.title+'.srt', 'w') as f: | |
| f.write(caption.generate_srt_captions()) | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment