matjaz / homey-youtube

Search Youtube, play playlists
https://apps.athom.com/app/com.youtube
9 stars 7 forks source link

no youtubeinmp3 but convertmp3io #19

Open bvdbos opened 7 years ago

bvdbos commented 7 years ago

http://www.youtubeinmp3.com/ redirects, see https://www.convertmp3.io/api/

bvdbos commented 7 years ago

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...

bvdbos commented 7 years ago

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

matjaz commented 7 years ago

there are more challenges here

* 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.

bvdbos commented 7 years ago

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...

matjaz commented 7 years ago

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.

Povlov commented 7 years ago

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... :-)

bvdbos commented 7 years ago

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

matjaz commented 7 years ago

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.

bvdbos commented 7 years ago

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

matjaz commented 7 years ago

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

bvdbos commented 7 years ago

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.

matjaz commented 7 years ago

see #18