Hack Forums
[.NET] Youtube to mp3 converter for skype bot. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Youtube to mp3 converter for skype bot. (/showthread.php?tid=5425264)



Youtube to mp3 converter for skype bot. - FunctionDev - Oct 5, 2016

So I'm currently working on my skype bot and I am having one hell of a time trying to figure out how to make a youtube to mp3 converter for my skype bot. Here is my code so far:

Code
ElseIf message.StartsWith("!convert") Then
            Dim list() As String = Split(message)
            Dim request As HttpWebRequest = HttpWebRequest.Create("https://www.youtubeinmp3.com/fetch/?format=text&video=" & list(1))
            Dim response As HttpWebResponse = request.GetResponse
            Dim source As String = New IO.StreamReader(response.GetResponseStream).ReadToEnd
            If source = "" Then
                Skype.SendMessage(user, "Link invalid. Enter command like this: !convert https://www.youtube.com/watch?v=UnfrLaQj-rk")
            Else
                Skype.SendMessage(user, source & " Thank you for your support")
            End If

I don't know what else to do or how to make it automatically change into an mp3 and spit out a download link. Please help!


* - Specs - Oct 6, 2016

I've knocked up something for you that should work well. I must admit the way you have your bot setup to read the commands and split it from the trigger is pretty messy doing it within each command but i kept it to your setup.

I know this is the NET section, but i made you a little php file that will navigate to the site you was using, but handle all the trimming and return just the download link. It will be much easier for you. You will need to save the code as "yt2mp3.php" & upload it onto a webserver somewhere. You can get free ones if you don't want to pay or something.

PHP Code:
http://pastebin.com/60rSZUyr

And here is the code that will send a request to the file on your server and return the link to your user. replace "yourdomain.com" with your one obviously.

.NET Code:
http://pastebin.com/HKRb0GkT

I didn't test it, but I do alot of work with this kind of stuff so i'm pretty confident it'll do what you want just fine. Enjoy :)