Learn R Programming

lares (version 5.1.0)

get_mp3: Download MP3 from URL

Description

This function downloads YouTube videos or Soundcloud or any other platform supported by the youtube-dl library, and converts them into high quality MP3 files. The URL can be for a single video or a whole playlist. It also returns metadata into an (invisible) list.

Usage

get_mp3(
  id,
  mp3 = TRUE,
  params = "",
  start_time = 0,
  end_time = NA,
  overwrite = TRUE,
  info = TRUE,
  cover = FALSE,
  quiet = FALSE
)

Arguments

id

Character. YouTube URL or ID to search for.

mp3

Boolean. Add mp3 optimal parameters?

params

Character. Additional parameters.

start_time, end_time

Numeric. Start and end time to trim the audio output in seconds.

overwrite

Boolean. Overwrite original file?

info

Boolean. Import and return metadata?

cover

Boolean. Google Search its squared cover?

quiet

Boolean. Keep quiet? If not, print messages.

Value

(Invisible) list with id's meta-data.

youtube-dl

More info from the original developers and its code: youtube-dl's Github

See Also

Other Scrapper: filesGD(), gtrends_related(), holidays(), ip_data(), readGS(), splot_etf(), stocks_quote()

Other Audio: trim_mp3()

Examples

Run this code
# NOT RUN {
# You must have "youtube-dl" installed in your OS:
# }
# NOT RUN {
# Download video from YouTube and convert to MP3
get_mp3("https://www.youtube.com/watch?v=lrlKcCdVw9Q")
# OR simply
get_mp3("lrlKcCdVw9Q")
# }

Run the code above in your browser using DataLab