Liinkiing/youtube-mp3-downloader-api

Can you write an instructions?

Zakirzhan opened this issue · 3 comments

can you write an instruction on how to install this script
and work with Mercure?

You must have a working mercure server (it's not something related to this repo, that's why they are no instructions on the readme), but mercure.rocks has a great Getting started part: https://mercure.rocks/docs/getting-started

When you have a working mercure server, you must put in your .env.local file (or any relevant .env file) those variables

MERCURE_JWT_TOKEN=<your_mercure_token>
MERCURE_PUBLISH_URL=<your_mercure_endpoint> # generally http://localhost:4000/.well-known/mercure

About the MERCURE_JWT_TOKEN, you will have more informations in the mercure docs, but basically you can take this one as a exemple: https://jwt.io/#debugger-io?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOlsiKiJdLCJzdWJzY3JpYmUiOlsiKiJdfX0.XE-X1o8kJmx0v_t48ttHKjqROEscuLQSSLX3bK6okhM

The important part are that your token contains a "publish" and a "subscribe" key, that indicates the permissions to which topic you can subscribe / publish (the one I have shared with you have bascially access to everything) with the secret key aVerySecretKey (the default one I think in mercure).

So to be clear, you put a secret in your mercure server, then you generate a JWT token with the secret you defined in your mercure server, then when you have this token you set it in the .env.local file, and it should works!

Mercure works in DefaultController:
Снимок экрана 2020-08-25 в 14 44 21
But I can't download mp3
Снимок экрана 2020-08-25 в 14 45 20

Based on your error, it seems that the @ParamConverter (the fact that https://github.com/Liinkiing/youtube-mp3-downloader-api/blob/master/src/Controller/Api/AudioController.php#L23 in this line I typehint the Audio entity and have an {id} param in the route), which make automatically a query in your DB seems to not find your audio, Are you sure you have in your database an audio with the id j3lH6cA4Sls ? Also, for this to work locally and to correctly download the file, a S3 bucket needs to be setup, because I'm using S3 to store the converted mp3 files and give a signed link that is valid during 1 minute