playing a youtube song

Hey guys.
How the can I make a lua script that reads a youtube link, and starts playing the link?
I’ll need to ‘collect’ the youtube music data some how…

The YouTube Data API can be used to grab the metadata of YouTube videos.

you can use http.Fetch to parse a url from (check the advanced API section) and get an mp3 link that you can play with sound.PlayURL

You get the Title, Duration and mp3 link in JSON or Plaintext format.

emm it doesn’t exist for lua :S


Yes it does.

So just to do:
And then how do i get the mp3 link? i didn’t quite get that.

  1. Fetch the JSON link
  2. Convert the returned data from JSON into a table
  3. The data you want is the table[1][“link”] value
  4. use sound.PlayURL to play the mp3 link from table[1][“link”]

sorry for being such a noob, how will I convert the JSON to a table?
And thanks for helping me ^^.



I just found out that sometimes, sound.PlayURL will time out if youtubeinmp3 takes too long to respond to the mp3 link. To solve this, wrap the sound.playurl in http.Fetch, and fetch for the same link. This will wait for youtubeinmp3 to respond before attempting to play the link.

Hello i have tried doing this but the URL doesn’t seem to work the one on the JSON

[editline]8th August 2017[/editline]

As this does download the file it doesn’t have the .mp3 and it just breaks. Do you have any alternatives?

(User was banned for this post ("Dumb bump - 3 year old thread m8" - Reagy))