matjaz/homey-youtube

no youtubeinmp3 but convertmp3io

Opened this issue · 12 comments

And though that one worked yesterday, now the convertmp3.io doesn't work anymore... Don't know if there's alternatives. Otherwise we should delete the Homey-Music part for now...

Or we should try using:
https://github.com/audiocogs/ogg.js

there are more challenges here

  • get url of YT video (get_video_info is simple but not robust, better is youtube-dl package)
  • convert video to mp3 (did't find any examples of audiocogs converting mp4 to mp3), what performance impact would that have on Homey?
  • play mp3 on homey (Homey accepts only stream_url, so we should create streaming server for that...)

* codecs can be any combination Homey support (better quality preferred)

I suggest if you have some time, let's first explore converting mp4 to mp3 and see if we can create a POC that actually works on Homey.

Audiocogs won't work, uses web-api so we need a browser for that if I understand the code correctly.
So indeed first get the audio-info from youtube-dl in node:
https://www.npmjs.com/package/youtube-dl / https://github.com/przemyslawpluta/node-youtube-dl
Then download the stream (there's an example downloading the mp4). We could do that to a user-directory. The stream contains a Vorbis audio so Homey should be able to play that directly?
https://apps.developer.athom.com/tutorial-Media-Codecs.html
But not all players support ogg so we might need to convert to mp3, this is possible in node:
https://github.com/sopel39/audioconverter.js
But this one will be a challenge regarding performance ;-) Running from my synology using my normal laptop works fast (some seconds per song).

Why would Homey only accept stream_url? Soundboard works too...

Off course cleanup of the download/convert fs-directory is needed after that...

Soundboard must first "upload" audio file to Homey system and you can't play your files directly. There is no option of streaming local audio files.
https://github.com/athombv/com.athom.soundboard/blob/d7d021246c8cae07f506153762c3f9d5a374bee2/app.js#L41
Also I haven't found sdk 2 version of this functionality.

Nice bringing his up for improvements Bas, and Matjaz for looking into this.
Maybe in a later stage I can contribute; atm its a bit too technical I'm afraid... :-)

stream-url audio from a youtube url:
https://github.com/fent/node-ytdl-core

Streaming doesn't actually solve anything, since we need to transcode to Homey supported audio codec.

I've found another service that 'works', but it requires passing cookies. So we'll see how long that works. Please test if you have time. In master and in on apps store review version 0.6.3.

a webm audio stream is vorbis. I think all YT-movies have webm with vorbis in them.

yeah, but vorbis can't be played on Homey.

The new mp3-service doesn't work on Chromecast? Different errors: invalid media-id, media request timed out etc. Music seems to be playing but no sound (the artwork appears however, using chromecast video.

see #18