Open fjebaker opened 5 years ago
As per the discussion with the development group, my suggested plan of action is (please read in full):
get request URL from user
validate URL is okay and website exists
pass to server and wait for a reply before redirect
when URL comes in to the specified endpoint (e.g. /request
), ensure site is valid (this may involve repeating some of what the client ensures, however with the specific goal of validating that the resource in the URL is available - e.g. the correct .mp3u8
file is loaded)
if site is okay, return a redirect to the client and spawn the API thread, else return 400 status
in the API thread, call a defined method (we'll discuss exactly what, but for example api.get(url)
) to start the download and wait for the returned file path
convert (probably using FFMPEG) the file into .wav
with correct meta-data, and store in correct directory (will be config defined). Off the top of my head, meta-data needed is duration, artist, song title, album.
load .wav
file into the music database
Since this will be user defined in the config.ini
, we'll provide a test API in the github, which will mock all of the desired applications.
If, as we plan to, we want this to work with spotify, we'll have to be able to add songs into the database where the path
column has a spotify:{PATH}
prefix - from when I messed about with the spotify API ages ago, the songs have paths much as a local file does, but they are related to how spotify stores songs.
For the client side, this would involve also interfacing with the spotify API for the search ability. I'm pretty sure npm can provide a library to make this more straight forward.
As discussed, client side will be handled by @JrTheDragon01, the server side by @sambnh, and I'll work on the test api and help out where needed.
Comment here what exactly you want to implement if it needs someone else to be wary of it.
As of 80ec21aa141a5e8e8710995aa72829cb6f939ec8 the client side exists. It validates that the URL is in the correct form, though not that it exists (this is handled on flask side anyway so is it necessary?) and deals with the relevant POST request response.
Do we want the success behaviour to be some configable redirect?
I don't think we need to validate whether the website exists on the client side.
As long as there is feedback to the user when it both fails and succeeds I can't think of any reason for any redirecting is necessary.
How close are we to completion of this - does anything else in the big post above still need doing?
I'm on holiday and I'm halfway though database stuff, I'll be able to finish it at some point soon
@Dustpancake @sambnh can I get an update on what needs doing on this now that the db is ORM
... I don't really get your question.
The ORM was just a quality-of-life upgrade really, makes everything a bit more scalable and easy to use. So I still need to do the test API, I think you still have most of your JS stuff done, and Sam I think has pushed his contribution?
So is this issue closable, are song requests done?
Well, not really. At the moment you can't request and fetch a song from somewhere :/ There's still a bit of work to be done, especially with respect to automated conversion to .wav and adding to database.
@JrTheDragon01 is the JS side done? Do you have a box I can paste a URL into and does it send the request to the server? If so, I can probably get the API done tomorrow (I'll just put off writing unit tests for a bit haha).
iirc at the moment you can fetch a song from a valid url (though I think Sam was working on getting the song info saving how we want it in the database) and yeah the JS side /should/ be done iirc
Testing right now to double check that downloads happen
Testing right now to double check that downloads happen
You can currently request and fetch a song from a valid URL pointing to an audio file via the frontend, the frontend needs visually cleaning up and imo the save location should be an item in the config file, but it does download and convert to WAV. The only part of the request and fetch missing is that the database is not updated with info about the newly downloaded song.
I've made a project for tracking the development of this.
In brief, we need to make the config parsers first, decide on what request API we want to use, and then implement it both front and backend.
I've made this part of Milestone 0.2.0 for now, and I think it's the last feature we need to implement before release.