Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pytube mp3

# Pytube dosent accept .mp3 format so the better way to do it is doing a 
# function with os

from pytube import YouTube, Playlist
import os

yt_url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'

def donwload_mp3():

  	audio = YouTube(yt_url).streams.get_audio_only()
    audio_download = audio.download(output_path='your path')
    base, ext = os.path.splitext(audio_download)
    new_file = base + '.mp3'
    os.rename(audio_download, new_file)
 
PREVIOUS NEXT
Tagged: #pytube
ADD COMMENT
Topic
Name
4+3 =