augustohp / catra

Stream mp3 from torrents, on your console.
MIT License
1 stars 0 forks source link

Music library (.m3ut proposal) #1

Open augustohp opened 8 years ago

augustohp commented 8 years ago

We need a better way to manage a music library than explicitly asking the stream of a torrent through magnet links. The most simple iteration of a library is a playlist, which for us is a list of files from a torrent.

There are many playlist formats available: M3U, XSPF, PLS, among others, M3U considered to be the main one.

As all formats rely on local file paths which we don't have, we need to create an extension to M3U using magnet URI with an application-specific parameter to it (with the specific song we want). An example of valid M3U file for us:

#EXTM3U

#EXTINF:334, Tesseract - Utopia
magnet:?xt=urn:btih:BB280972A8AAEBF3079E7AA67AA896930D67509F&dn=tesseract+polaris+2015+320ak&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&x.musicFile=05.%20Utopia.mp3

#EXTINF:281,Animals as Leaders - Physical Education
magnet:?xt=urn:btih:3C40A7025C8501C6A70556193722568550B44811&dn=animals+as+leaders+discography+2009+2014+cbr+320&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&x.musicFile=Albums%2F2014%20-%20The%20Joy%20of%20Motion%2F05%20-%20Physical%20Education.mp3

Note that the local file path is completely replaced by a magnet URI address, that is the only difference from a regular M3U file.

The x.musicFile parameter

x.musicFile should point to the relative path of the song provided by the torrent file. The parameter should be comprised of ASCII characters as M3U is, so the path should comply to URI Generic Syntax (as provided by PHP's rawurlencode() function).

Examples of valid parameters on magnet URIs:

We need to formalize the P2P nature of the file so we don't mess with current implementations, we have to:

  1. [ ] Define the internet media type (e.g: application/vnd.catra+x-mpegurl).
  2. [ ] Agree on the extension name (.m3u for the obvious reasons and t suffix for torrent).
  3. [ ] Provide a formal, open/public, draft of the format.
  4. Allow inclusion of other .m3ut files inside a playlist, allowing us to create huge playlists easily.
  5. Formalize where to cache items in the local file system, preventing the download of the same file multiple times (from different .m3ut files).
  6. Support HTTP along with magnets as a file location.

Consider them as a prioritised list, where the formalisation of the first draft separates what is really necessary from what we could want.

Thoughts

Given we have those, we can share .m3ut files among us as well as publish them as torrents. Catra would then accept these files instead of magnet URIs which would keep us from creating a full fledged visual player for our MVP.

Our previous idea (@augustohp and @alganet) was to create a torrent of torrents format and share it, although this is a completely different idea (solving a different problem) I consider it to be an easier and smaller step towards it.

With .m3ut files we wouldn't care for a library for a quite long time, we just need to shift our mindset towards P2P playlists instead of music libraries. One could make as its personal project to provide the .m3ut file of all available songs so other people could use to create their own playlists, for example.

wesleyvicthor commented 8 years ago

Sweet. I like the .m3u approach. :+1: Just asking why not .m3u.torrent instead of creating or own extension .m3ut ? With that we can avoid the draft for the format and other headaches that might appear.

Cache items you mean, the songs downloaded ? If so, I think we could give this choice to the user to where store the songs and create a hidden folder or file in the root user folder or Catra installed folder with the already downloaded infos.

augustohp commented 8 years ago

Sweet. I like the .m3u approach.
Just asking why not .m3u.torrent instead of creating or own extension .m3ut ?

Because they are different things. a .torrent extension is a... wait for it... torrent. The idea of having a different extension is for people not to get frustrated when trying to open a m3u that doesn't open.

Cache items you mean, the songs downloaded ?

Yes.

If so, I think we could give this choice to the user to where store the songs and create a hidden folder or file in the root user folder or Catra installed folder with the already downloaded infos.

That is the idea. The main idea is to allow configuration but do everything we can without user intervention. We can define a directory for us to use and keep it tidy at a pre-defined size.