Posts: 7
Joined: Aug 2015
Reputation:
0
My intention is to write a script that would save the music playlist selected, current track and seek time when Kodi exits and resume playback from where left off when Kodi is lauched once again. Inability to fetch the name of currently selected playlist has proven to be a show stopper for me.
I have spent hours and hours trying to find a way to get the name of the current playlist, there just don't seem to be an answer. In the process I learned that this was possible with HTTP API, which is deprecated now. I also searched for a way to resume playback, I can see a lot of people asking and trying for it but none have been successful ?! I have explored the venues of JSON RPC, built-in functions, commands etc. but to no avail, unless I missed something. The whole process has been quite frustrating not to mention the hours wasted to get silly something done !
Can any one help shed some light on this, please ? If this is the wrong forum could you please suggest a right one ? I wasn't sure if I should post this on the developer's forum so, I thought I'd try here first.
Thanks.
Posts: 7
Joined: Aug 2015
Reputation:
0
Thanks a lot for the response Karnagious.
I had already explored the possibility of obtaining playlist name through JSON and had tried the methods you listed. Apparently Playlist.GetProperties returns a Playlist.Property.Name, the name of which is misleading. It actually supports an enum of two members - "size" and "type".
Unfortunately playlistid returned by Player.GetProperties is always "0" regardless of which playlist is current and thus cannot be used.
What I learned through googling is that it was possible with HTTP API which was deprecated and not supported anymore.
The "XBMC Resume" seemingly is outdated and extinct as the download links are dead. I found a few others which are either outdated or do not save and resume playlist.
I even tried creating a service addon which would monitor Kodi and save the name of the playlist that was playing before Kodi shuts down. I gave up as I couldn't find any built in functions or the action id that would get me the playlist name.
Seems like I have hit a dead end. It is shocking as, this is something very much possible with only a few lines of code and yet it was never felt as a necessity.
I guess I will have to settle with hitting buttons on my remote to manually load and play the playlist I need.
Any other ideas ?
Posts: 7
Joined: Aug 2015
Reputation:
0
You and I think alike, Karnagious !
I actually thought of that, that is use Playlist.GetItems on all playlists and unique sort the paths and cache them in a file and everytime shutdown.py is called, call Playlist.GetItems once again and unique sort the list and compare it with one of the previously cached lists and figure out which one is playing.
I actually have some playlists in which the same artist duplicated as I am creating playlists by genre and also by my favourite artists. So the above will take care of this but, will fall short if I add new playlists unless I run my script to recreate the cache.
Being mostly a C/C++ guy and with very limited python skills, this will take some effort which I will have to defer.
The developers should seriously consider adding this feature.
Thanks again.
Posts: 1,088
Joined: Nov 2012
Reputation:
51
Did you know you can pass Files.GetDirectory a Playlist and it will return to you the contents?
Posts: 7
Joined: Aug 2015
Reputation:
0
I am guessing that, you are suggesting to use Files.GetDirectory to get the list of files to use for the cache. Yes, I am aware of it, but I'd rather use the Agent Ransack to copy paste the directories list to create my cache. But then, I will have to use the Playlist.GetItems to get contents of the currently playing playlist as, using Files.GetDirectory requires knowing the name of the current playlist.
I was talking about the script that actually uses Playlist.GetItems and creates a unique and sorted list of directories and compare it against the cached lists. That is going to take a bit of effort which I will defer.
Posts: 12
Joined: May 2015
Reputation:
0
jblook
Junior Member
Posts: 12
Hi AlexBw,
I'm trying to do the exact same thing as you are (and experiencing the exact same issue, by the way...).
Just curious - did you by chance managed to make it work?
If so, could you please share the result?
Thanks in advance...