인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

diadld32249's profile image
diadld32249

asked

Introduction to Python and Creating Various Automated Applications Using Web Crawling

[ Wait a minute! ] Download YouTube videos with Python and automate conversion to mp3!

에러가 뜨네여..

Written on

·

197

0

import pytube

import os

import subprocess

yt = pytube.YouTube("https://www.youtube.com/watch?v=1ag0HMg0sHU")

videos =yt.streams.all()

for i in range(len(videos)) :

    print(i,' , ',videos[i])

down_dir = "Users/diadld3naver.com/Desktop/youtube-download"

cNum = int(input("다운로드 받을 화질?(0~16 입력)")) 

videos[cNum].download(down_dir)

newFilename = input("변환 할 mp3 파일명은?")

oriFilename = videos[cNum].default_filename

subprocess.call(['ffmpeg','-i',os.path.join(down_dir,oriFilename),os.path.join(down_dir,newFilename)])

print("동영상 다운로드 밑 mp3 변환 완료")

코드 똑같이 사용했는데 에러가 나와여..

Traceback (most recent call last):

  File "youtube-download.py", line 15, in <module>

    videos[cNum].download(down_dir)

  File "/Users/diadld3naver.com/opt/anaconda3/envs/section1/lib/python3.8/site-packages/pytube/streams.py", line 245, in download

    with open(fp, 'wb') as fh:

FileNotFoundError: [Errno 2] No such file or directory: 'Users/diadld3naver.com/Desktop/youtube-download/Lauv - Paris In The Rain [Cover by YELO].mp4'

cNum 없이 인덱스 0으로할때는 비디오가 저장이 잘됬지만 cNum변수 설정후 비디오 저장이 안되며 위와 같이 에러코드가 나옵니다.. 도와주세요ㅠㅠ

python웹-크롤링

Answer

This question is waiting for answers
Be the first to answer!
diadld32249's profile image
diadld32249

asked

Ask a question