-_-;; 4k 다운로더 쓰는게 훨씬 낫겠다. 장점이 없뜨아....
https://pytube.io/en/latest/user/streams.html#filtering-by-streaming-method
yt = YouTube(url)
stream = yt.streams.get_highest_resolution()
stream.download(DOWNLOAD_FOLDER)
print("제목 : ", yt.title)
print("길이 : ", yt.length)
print("게시자 : ", yt.author)
print("게시날짜 : ", yt.publish_date)
print("조회수 : ", yt.views)
print("키워드 : ", yt.keywords)
print("설명 : ", yt.description)
print("썸네일 : ", yt.thumbnail_url)
p = Playlist('https://www.youtube.com/watch?v=ea7hkgs9DJo&list=PLsBObkGU9zQMirwoCV2lgHOl5fqXIlcxI')
for video in p.videos:
video.streams.first().download(DOWNLOAD_FOLDER)
실제 코드
import moviepy.editor as mpe
import os
import pytube
vname = "clip.mp4"
aname = "audio.mp3"
# Download video and rename
video = pytube.YouTube("https://www.youtube.com/watch?v=kJQP7kiw5Fk").streams.filter(
subtype='mp4', res="1080p").first().download()
os.rename(video, vname)
# Download audio and rename
audio = pytube.YouTube(
"https://www.youtube.com/watch?v=kJQP7kiw5Fk").streams.filter(only_audio=True).first().download()
os.rename(audio, aname)
# Setting the audio to the video
video = mpe.VideoFileClip(vname)
audio = mpe.AudioFileClip(aname)
final = video.set_audio(audio)
# Output result
final.write_videofile("video.mp4")
# Delete video and audio to keep the result
os.remove(vname)
os.remove(aname)
'파일 관리 - 이미지 처리 - pdf' 카테고리의 다른 글
mp3 붙이기 (0) | 2023.04.08 |
---|---|
(포토스케이프 일괄변환 위치 문제) -_- 해결 (0) | 2022.10.21 |
pdf <-> jpg 변환 및 편집 툴 개발 중... (0) | 2022.10.20 |
자작4. 탐색기에서 파일 홀짝 분리, 필터 (0) | 2022.10.10 |
자작3. zip 이미지 반띵 후 다시 zip으로 (망가 분할 추가 좌<-우) (0) | 2022.10.10 |
자작 2) 두 쪽 보기에서 바깥쪽/안쪽 여백 trim+빈페이지 삽입 (0) | 2022.10.10 |
exe 실행파일 만들기 (0) | 2022.10.09 |
Pillow 총 정리 (0) | 2022.10.09 |
댓글