INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: MCWS: Playlist Item Timestamps  (Read 4359 times)

max096

  • MC Beta Team
  • Galactic Citizen
  • *****
  • Posts: 363
MCWS: Playlist Item Timestamps
« on: July 26, 2019, 11:31:47 am »

Code: [Select]
http://192.168.1.111:52199/MCWS/v1/Playlist/Files

Only returns timestamps regarding the actual music file.

For what I'm currently working on having a timestamp for when a song was added to the playlist as opposed of when it was added to the library would be very helpful.

Furthermore I'm assuming I'm correct in the assumtion that all the timestamps are UTC?

I'm currently working on an android app that synchronizes music from various musicplayers without plugging the device into the PC. This already sort of works with JRiver and Plex. Playlists as well, but only from the PC to the phone. Now I want Playlists to be synchronized both ways. If I have added a song in my music player of choice on Android (for me that's Phonograph). I want my app to add the song to my JRiver library in that very same Playlist.

But that leaves me having the need to figure out wether a song in JRiver should be copied to the device or deleted from the playlist in JRiver. In case of doubt I'll be prioritizing whatever the remote library sais (in this case JRiver) the playlists content should be. But without a date at all I cannot really do that. Ofc, an actual history would be ideal. But I can make it work with a single timestamp of when the song was added. A 'poke' function of sorts would also be appriciated. Some way to bump up the timestamp of a playlist item to UTC now, but could be worked around by combining add and delete. The timestamp is the only thing I'd really need.

And another thing when a song is deleted from the playlist on JRiver it would also be good to know when it went away. So that kinda is why a full history would be good. Knowing what happened when. Three things Action ("remove/delete/add") and ID of the song at the time with another timestamp. Its not strictly require, since as I said Im gonna prioritize the remote library, so the song would just be deleted from your phone even if you added it back after you deleted it in jriver and then did a sync.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10931
Re: MCWS: Playlist Item Timestamps
« Reply #1 on: July 26, 2019, 03:10:37 pm »

Playlists really don't carry any of that information. Its just a list of files without any additional data attached - any actual data is always on the files.
I would recommend to just store your own playlist seperate from the last MC playlist that you retrieved. That way you can determine what changed on your side and what changed on MCs side, and apply any kind of smart merging of changes.
Logged
~ nevcairiel
~ Author of LAV Filters

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: MCWS: Playlist Item Timestamps
« Reply #2 on: July 26, 2019, 04:18:05 pm »

The only other thing I'd add to what Hendrick said is you can of course check the file system timestamps on the playlist files themselves.  That way you will at least know which was most recently modified and holds the most recent data.  File timestamps will be in the format defined at you OS level.
Logged

max096

  • MC Beta Team
  • Galactic Citizen
  • *****
  • Posts: 363
Re: MCWS: Playlist Item Timestamps
« Reply #3 on: July 26, 2019, 06:15:54 pm »

The problem with that is that i'm never seeing the playlist files. I get a XML from MCWS. File system access is not an option. Or at least a bad one imo. I want other people to be able to just install the app and have it work when they enter the IP of JRiver. Also it's not really what Hendrik suggested.

It's possible that I may write a server side software. Kinda a man in the middle that you could ALSO (but not as your only option) use instead of the MCWS/Plex/or whatnot and then I'd also have file system access. (but I probably will never use that to access JRiver files...) I already though about it that I might have to do this at some point to support features that a api of a certain program might not. But I did not think it would be because of playlists. But it would make it feasable to ping JRiver every now and then to get the latest playlist information at that point in time and figure out changes over time by long polling apis that don't give out that information essentially. And it would make it possible to implement a good authentication and so forth for remote access that is consistent across whatever you end up using. And it would allow things like converting music files on the server when the api cannot do that and so forth. So it's possible at some point I'll do that. But that will take quite som time for me to even actually be able to truly think about doing that. Well... I'm thinking about doing that. But I'm also thinking it's not the time to do that yet at all.
Logged

max096

  • MC Beta Team
  • Galactic Citizen
  • *****
  • Posts: 363
Re: MCWS: Playlist Item Timestamps
« Reply #4 on: July 26, 2019, 06:32:11 pm »

Playlists really don't carry any of that information. Its just a list of files without any additional data attached - any actual data is always on the files.
I would recommend to just store your own playlist seperate from the last MC playlist that you retrieved. That way you can determine what changed on your side and what changed on MCs side, and apply any kind of smart merging of changes.

I don't need to store my own playlists. Androids Media Store stores playlists system wide and I insert into it. Witch is also kind of important or this kind of app would be useless. I do not intend to write a music player on top of it. I already store playlists with the ID they have in JRiver and in the MediaStore in my own database as well as witch entries within that playlist where synced by my app at what time. But that does not change that I still know absolutely nothing about when JRiver added or removed songs. So the "smart merging" will be destent to fail in many situations.

It can work, sort of. But not perfectly well without screwing up ever. It will mess up the moment you change the same playlist on both ends and then hit sync at the very least. The rest is possible to mostly get working ok'ish.

---

Even if it's just files without having that version yet. You could always add another place to store that information in. Just how you do it with all the other stuff you persist. I don't know what your concern is about adding that. It's more whether you think it's important enough to actually do it, or not?

Either way you have some time to think about it. I have a boat load of other things that I want to implement in that same app.

I'd be very thankful though, if you could make this a thing at some point!  :)

----------------------------------------

Rough, abstract examples how I think the solution could be as I have no idea how exactly JRiver works internally.

If I understood that correctly what you are doing is probably something like

playlist1.txt
path
path
path

"path" could be a file path or effectively the ID of sorts the song has in JRiver or some internal link to it. But let's call it path, path is fine. Path always works.
Probably not a good idea to add the timestamp to that I agree. Since it would break the playlist should you move down a JRiver version. But nobody would ever notice if instead of writing only to that one file you create another.

playlist1.info
path or song id  | timestamp | maybe something else someone might want at some point

I'm just saying it's file for now. But it could be a DB whatever you use a lot in JRiver. Then you can add it as a field to the already existing playlist endpoint, or another one should you choose to do so, since your API is versioned (is it actually?) it seems like you'd want do that instead maybe. But it seems like the format you went with for the XML makes breakage by adding more fields very unlikely.

I would prefer a log type of situation where whenever a song is added, removed or moved in a playlist you just add that to a playlist history type of file or db,then that could be returned by a new playlist history endpoint. Would give out more information. Would be more to parse, but that's fine with me. When syncing my 2515 file library, the XML parsing currently takes a little more than half a second (on my phone). That includes reading the 78.571 lines of XML with all the songs listed in it. The history DB cannot be that big I don't think and you could add a TTL to those history entries or a maximum size.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10931
Re: MCWS: Playlist Item Timestamps
« Reply #5 on: July 26, 2019, 07:01:48 pm »

I don't think the way we handle playlists is going to change anytime soon. Sorry. I can imagine many ways already how you can catch changes in the MC database on your end to know the actual delta since you last synced, which is what you should be really after and your timestamps are just one way to get it, but many don't require complex (and incompatible) changes to storage on our end.
Logged
~ nevcairiel
~ Author of LAV Filters
Pages: [1]   Go Up