PDA

View Full Version : Scanning tracks with custom protocols into the DB



torarnv
2010-03-23, 15:32
Hey,

Looking at the DB track schema I noticed the files are listed by a file:// url.

Does that mean that I can add tracks with custom protocols (provided by a plugin) to the DB, and they will then automatically show up in searches and browsedb as if they were normal tracks, and when playing that track the protocol handler of my plugin will take over and play the track?

If so, hurray! :)

If not, which parts would likely work, which parts would not, are there any extra bits I have to set apart from just feeding lots of tracks into the DB?

Thanks!

andyg
2010-03-23, 15:42
It may work, but some things probably assume that values in tables other than tracks refer to local files. Historically the tracks table used to store remote URLs but this was removed recently. Make sure you set remote=1 and audio=0 for anything you add to the tracks table. Also realize your data can be wiped out at any time so you must have a method to quickly repopulate the data from the remote library. You will probably run into a lot of problems doing this so I would advise against it.

torarnv
2010-03-23, 15:55
It may work, but some things probably assume that values in tables other than tracks refer to local files. Historically the tracks table used to store remote URLs but this was removed recently. Make sure you set remote=1 and audio=0 for anything you add to the tracks table. Also realize your data can be wiped out at any time so you must have a method to quickly repopulate the data from the remote library. You will probably run into a lot of problems doing this so I would advise against it.

Ah, thanks for the heads up!

My usecases for this was allowing people to mark any Spotify album as "part of my library", so that :

1). It would show up when you browse for albums of that particular artists, that year, "browse by related", etc

2). It would show up in the normal built-in search

The first usecase I guess I can solve using the CustomBrowse plugin. The second might require hacking into the search and provide a few extra hits of my own (unless there are hooks I can use).

Anyways, that's why I was hoping I could just add a bunch of spotify:track:12334 to the db :)

Suggestions on how to solve this differently appreciated :)

The goal is for the user to have a library that contains albums from different sources, both local (on disk), and remote (Spotify), and that browsing and searching these items work the same way, regardless of the source. Basically, you shouldn't care where the music is coming from.

torarnv
2010-03-23, 16:22
A quick test showed that the track had to have remote=0 to be listed as one of the tracks of the album i associated it with, but that resulted in the meta-data not being fetched from the protocol handler when trying to play the track (the stream itself played fine).

If remote=1 it would not be listed with the album, but still turned up in search results (and had proper meta data from the protocol handler).

andyg
2010-03-23, 16:26
On Mar 23, 2010, at 7:22 PM, torarnv wrote:

>
> A quick test showed that the track had to have remote=0 to be listed as
> one of the tracks of the album i associated it with, but that resulted
> in the meta-data not being fetched from the protocol handler when trying
> to play the track (the stream itself played fine).
>
> If remote=1 it would not be listed with the album, but still turned up
> in search results (and had proper meta data from the protocol handler).

Yeah that's the sort of thing I was afraid of.

awy
2010-03-24, 02:36
Yes, it is only allowed in the DB if it is local. The protocol handler will only be used for metadata if it is remote.