Author Topic: Insert a SmartPlaylist in a Playlist  (Read 2937 times)

0 Members and 1 Guest are viewing this topic.

claymic

  • $upporter
  • Sr. Member
  • *****
  • Posts: 152
  • Karma: 0
    • View Profile
Insert a SmartPlaylist in a Playlist
« on: May 22, 2013, 07:48:36 AM »
Ok, before anyone say...i am not crazy :bonk...maybe just a little ;D
Smartplaylist its nice but when we generate a smartplaylist the xbmc dont insert the items in the playlist, since the smartplaylist its more like a filter then a true playlist.
I need to insert all the items from a smartplaylist in a playlist, in this way i can easy get this items and show in my ipad interface (to use without have to turn on the tv or play the files in another player like Dune...just an example).
For now i tried to modify the VoxTools to insert the smartplaylist in the playlist using Playlist.add, this works but the xbmc dont insert the items, it insert only the path for the smartplaylist. I tried with the Playlist.load too.
If anyone have a tip to help me with this i will appreciate.
Thanks

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Insert a SmartPlaylist in a Playlist
« Reply #1 on: May 22, 2013, 10:58:45 AM »
What are you trying to get back, a list of IDs ?

claymic

  • $upporter
  • Sr. Member
  • *****
  • Posts: 152
  • Karma: 0
    • View Profile
Re: Insert a SmartPlaylist in a Playlist
« Reply #2 on: May 23, 2013, 07:03:06 AM »
I am trying to create a true playlist with a smartplaylist. In this way i can control with my ipad.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Insert a SmartPlaylist in a Playlist
« Reply #3 on: May 23, 2013, 10:28:19 PM »
Hmmmmmm.....  :-\

Do you have to use a smart playlist though?  Would it be possible to use Json with some filters or something?  The API really sucks for this type of thing, which is sad since the old one could do it easily, but it may still be doable.  The only thing is you probably need to add items to the playlist, one by one, with a Json call for each one.

claymic

  • $upporter
  • Sr. Member
  • *****
  • Posts: 152
  • Karma: 0
    • View Profile
Re: Insert a SmartPlaylist in a Playlist
« Reply #4 on: May 24, 2013, 09:18:35 AM »
Do you know...the xbmc sometimes its very weird  ;D
So, i was trying to use Vox to create the smartplaylist, like you do for the unwatched episodes, then i tried to insert in a playlist, dont work, but if we use the method Player.Open works, the xbmc will start to play the smartplaylist and then insert all the files in the playlist, we just need to insert the smartplaylist in the params:
Code: [Select]
"item":{"file":"special://profile/playlists/mixed/voxsmart.xsp" }So, with that i can play the smartplaylist using vox  and then see all the files in my interface, i just need to get the items in the playlist.
Thanks for your help
Clayton

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Insert a SmartPlaylist in a Playlist
« Reply #5 on: May 24, 2013, 10:37:28 AM »
The default config for Frodo comes with some commands that do this.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="183" name="Play Hits by {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString>Spinning up some hits by {1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.SmartPL</cmdType>
    <cmdString>smarts\ArtistHits.xsp&amp;&amp;{1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>GUI.ActivateWindow&amp;&amp;"window": "video", "parameters": [ "special://profile/playlists/mixed/voxsmart.xsp" ]</cmdString>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>Player.Open&amp;&amp;"item":{"file":"special://profile/playlists/mixed/voxsmart.xsp"}, "options": { "shuffled": true}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>GUI.ActivateWindow&amp;&amp;"window": "musicplaylist"</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>play, listen to, q up</phrase>
  <phrase optional="true">some</phrase>
  <phrase>hits, good songs, good tracks</phrase>
  <phrase>by, from</phrase>
  <payloadFromXML phraseOnly="True" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone">XbmcPayloads\xbmcArtists.xml</payloadFromXML>
</command>

I think what you are saying is that "once xbmc starts playing the smart playlist it becomes the currently playing playlist, and it behaves like a normal playlist".  

Is that right?  Does that mean your problem is solved?

claymic

  • $upporter
  • Sr. Member
  • *****
  • Posts: 152
  • Karma: 0
    • View Profile
Re: Insert a SmartPlaylist in a Playlist
« Reply #6 on: May 24, 2013, 12:00:14 PM »
Yes, its right, this solve my problem.
But i insert this in my script to let me get at least the unwatched episodes of a tvshow in a playlist
Code: [Select]
def _unWatchedEpisodes(self):
        log("playlist insert")
        playlist = xbmc.PlayList(1)
        playlist.clear()
        tvshowid  = int(self.UNWATCHEDEPISODES)
        json_filter  = '"filter":{"field": "playcount", "operator": "is", "value": "0"}'
        json_params  =  '"params": {"sort": {"order": "ascending", "method": "episode"},"properties": ["episode", "season", "playcount","file"], "tvshowid":%s,%s }' % (tvshowid,json_filter)
        json_request = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes",%s , "id": 1}'% json_params)   
        json_request = unicode(json_request, 'utf-8', errors='ignore')
        json_response = simplejson.loads(json_request)
        if json_response.has_key('result') and json_response['result'] != None and json_response['result'].has_key('episodes'):
           for episodesList in json_response['result']['episodes']:
              #if episodesList.has_key('playcount'):
              playcount = int(episodesList['playcount'])
              if playcount==0:
                 file = episodesList['file']
                 fileReplace = file.replace("\\","/")
                 episodeid = int(episodesList['episodeid'])
                 xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Playlist.Add","params":{"playlistid":1, "item": {"episodeid": %d}}}'%episodeid)
                 #playlist.add(url=file)
Since my functions (in CAV) are asynchronous  i cant use a "loop" to insert the files in the playlist, i will get a out of order episodes, the only way to solve that is use a setTimeout, its a waist of time.
So now i can use smartplaylist with Vox or call my script to fill the playlist with the episodes.
Thanks for your help.
Clayton