Before asking, I would like to clarify, youtube-dl is not available to me as I'm on shared web hosting. Is there any way to download a Youtube video using PHP WITHOUT youtube-dl?
Yes you can use curl to do this. If it is a very large video then you will probably have to increase memory on your PHP installation or you can crash the server
if your php locks and can't close the connection. Being on shared hosting I would not attempt this. Your host techs will notice it almost immediately through bandwidth tranfers.
If you want to really do this, then you will need to be hosted in a cloud or a dedicated server and you will have direct access to your server.
And yes be careful about copyrights or you can end up with a hefty fine.
I wrote a simple class that can tap the youtube API for the audio extraction and then covert to MP3. It is using cURL.
Unfurtunately, I cannot share that script because it violates the section 11 of the Google's TOS. MP3 still remains a component of the youtube audio visual..
Besides, If I ever slipped and accidentally paste the codes here, they can easily come to my house and tickle me to death or until all of feathers are literally flocked out my little penguin body :).
To answer your other question from the other thread, video has to be downloaded before the ffmpeg-php can extract the audio and then transcode it to MP3 format.
Now, the legal stuffs.. Please believe me on this one... I have a family member working for the Big G in Mountain View, CA.., and they are pretty ( I mean VERY strict in implementing their TOS).
Youtube's TOS on a fine line..
This is legal ( example of my pervious API application)
This is legal ( example 2 )
This is a violation (example 3 ) Did you see the reason why it is illegal? Check the video player....not an actual youtube player.
One violation (video to mp3), and one legal below the page..
Sounds good. I will kill this project then.
That's a good decision... writing the script is not a problem at all. I even wrote the script that will take out the ACC audio with the highest bitrate possible for MP3 conversion, but I can't get around with the TOS.
Although downloading the video first, will not make google block your domain in the first few months of operation, but as your site becomes more popular, the request will become noticeable to them to investigate the cause of excessive requests from your site.
There are few sites out there that are offering MP3 download, but most of them are hosted overseas and they can pretty much disappear at any time if any trouble with youtube arises. Unlike us, who are within the reach of the Big G, our options to play around -- or rather --> experiment with this type of programminng exploration is pretty much limited.
Here are the links just for reading.. Regardless which sides we take, it is a good read.
1. Google blocks MP3 rippers from YouTube