0

I'm trying to download a long list of podcasts, but when I use the download.file command in R it corrupts the audio file into a bunch of crackling noises.

Could any of you recommend a dedicated audio-downloading package, or recommend a download.file method that would be better suited for download audio. I went through the ones listed in the help file, but none worked. ("auto", "internal", "wininet", "libcurl", "wget" and "curl")

The downloading portion of the code looks similar to this:

url <- "http://play.podtrac.com/npr-510289/npr.mc.tritondigital.com/NPR_510289/media/anon.npr-mp3/npr/pmoney/2016/06/20160603_pmoney_podcast.mp3?
orgId=1&amp;d=1121&amp;p=510289&amp;story=480606726&amp;t=podcast&amp;e=480606726&amp;siteplayer=true&amp;dl=1"

download.file(url = url, destfile = "test.mp3")

I attempted different audio files from different sites and had similar results.

Edit: In response to the question by VC.One, this a url to the initial section of the Hex code. I added in more than the couple of lines he requested because the first section looked like file information which may or may not be relevant:

Community
  • 1
  • 1
  • Try an alternate library. Read this case for example. https://stackoverflow.com/questions/23028760/download-a-file-from-https-using-download-file/23029305#23029305 – phili_b Mar 08 '19 at 20:47
  • I had looked at RCurl, but the way I understood it, it is more catered towards extracting text from a large number of sites. If you have suggestions for other packages, I would love to hear them. – Pieter van der Veere Mar 08 '19 at 21:21
  • Use a **Hex editor** (download it or just use an online hex viewer) and select maybe 8 lines worth of byte values then copy/paste into your question. This will make it easier for us to see how the data (bytes) are corrupted and suggest a fix. – VC.One Mar 10 '19 at 23:45
  • Dear VC, thanks for the suggestion and my apologies to the late reply. I added in a section of the initial hex code of the file I downloaded using the code. – Pieter van der Veere Mar 31 '19 at 19:47

1 Answers1

1

Try mode = "wb" in download.file(). I had the same issue you mentioned and this solved it for me.

dyna
  • 26
  • 5