Cron XBMC - Help Wanted

  Thread Rating:
  • 1 Votes - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
backspace Offline
Senior Member
Posts: 112
Joined: Mar 2012
Reputation: 1
Wink  RE: Cron XBMC - Help Wanted Post: #11
I think this needs to be finished by some of the skilled skinner's out there Wink
I keep breaking xbmc trying different playlist options etc Confused

Anyone out there keen to finish the GUI?
find quote
robweber Offline
Fan
Posts: 599
Joined: Sep 2009
Reputation: 15
Post: #12
(2012-04-03 03:54)backspace Wrote:  I think this needs to be finished by some of the skilled skinner's out there Wink
I keep breaking xbmc trying different playlist options etc Confused

Anyone out there keen to finish the GUI?

I agree, someone with some skinning talent is definitely needed here. I keep hoping as this thread gets bumped someone will notice it eventually and be willing to devote some time.

How are you breaking xbmc with the playlist options? Just trying stuff out and finding it isn't working?
find quote
backspace Offline
Senior Member
Posts: 112
Joined: Mar 2012
Reputation: 1
Post: #13
How I break xbmc... by changing stuff I have no knowledge about Big Grin... I must have deleted a line of code or something by accident and it would hang, but went back to the original version and it worked fine. And over lapping playlist ie 7am-11pm = playlist1, 3pm-5pm = playlist2, 8pm-10pm = playlist3 etc didn't seam to work. not sure why?
find quote
backspace Offline
Senior Member
Posts: 112
Joined: Mar 2012
Reputation: 1
Post: #14
Is there a way to make this clear the music play list before timing another?

Also still hoping that someone jumping and finish the GUI (please)
find quote
robweber Offline
Fan
Posts: 599
Joined: Sep 2009
Reputation: 15
Post: #15
(2012-11-01 21:51)backspace Wrote:  Is there a way to make this clear the music play list before timing another?

Also still hoping that someone jumping and finish the GUI (please)

Since this is more of a timer and not something that reacts to an event (like a playlist finishing) I would say 'no'. I guess I need a better example of what you are trying to do though. It may be possible to write a script and call that on a timer to check for certain conditions, really just depends. If you can provide more info I'd be glad to make a suggestion.
find quote
backspace Offline
Senior Member
Posts: 112
Joined: Mar 2012
Reputation: 1
Post: #16
Hi Rob,
Yes a script would work. But it is more to change the genre of music according to the time. When I last was playing around I found that I would be adding songs to the end of the queue.
I guess executing two commands in one timer would work. ie timer1 (at say 3pm) play playlist1. Timer2 (at say 5pm) clear queue (playlist1 could still have songs/videos to play) Then play playlist2.
Does that make sense?
find quote
robweber Offline
Fan
Posts: 599
Joined: Sep 2009
Reputation: 15
Post: #17
Oh, ok. I think I know what you mean. Basically you want a script that you can call at different times of day that will queue up different types of music, while also clearing out the current playlist.

The way you describe it is how I would do it. When the timer starts I would stop the currently playing song (if player is playing), then clear the playlist, load new playlist, and then start playing. Let me know if you need any help with the script.
find quote
backspace Offline
Senior Member
Posts: 112
Joined: Mar 2012
Reputation: 1
Post: #18
Hi Rob,
I dont know much about python (actually all I know is that is code) so a point or two in the right direction would be greatly appreciated Smile
(I learn best by taking some code that works and pulling it apart and seeing why it works, maybe changing a bit here and there to see what happens)

(as I don't know much about py) would something like this work?
<job name="Test" expression="30 * * * *"command="Playlist.Clear","(Partymode(special://profile/playlists/music/playlist1.xsp))" show_notification="true" />
find quote
robweber Offline
Fan
Posts: 599
Joined: Sep 2009
Reputation: 15
Post: #19
(2012-11-05 01:03)backspace Wrote:  Hi Rob,
I dont know much about python (actually all I know is that is code) so a point or two in the right direction would be greatly appreciated Smile
(I learn best by taking some code that works and pulling it apart and seeing why it works, maybe changing a bit here and there to see what happens)

(as I don't know much about py) would something like this work?
<job name="Test" expression="30 * * * *"command="Playlist.Clear","(Partymode(special://profile/playlists/music/playlist1.xsp))" show_notification="true" />

It's a little more complicated than the command you have written. The CronXBMC addon can only run 1 command at a time, and it must be a built in XBMC method - not a JSON RPC method. In order to accomplish what you want you'll need both a python script, and a Cron call. The Cron call would look like this:

Code:
<job name="Playlist" command="RunScript(ABSOLUTE PATH TO/playlist.py)" expression="30 * * * *" show_notification="true" />

This would then call the playlist.py file somewhere on your system (for testing I just threw it in the music playlist folder) . This script kills the current music, loads up a new xsp playlist and starts it using JSON methods. I tried it out and it works just fine. Do notice that in the Player.Open call you need to provide the path to the smart playlist without the .xsp extension on it. This threw me off the first time testing it.

Code:
import xbmc
import json
import urllib

#function to execute the JSON calls
def getJSON(query,params):
    #execute the json request
    json_response = xbmc.executeJSONRPC('{ "jsonrpc" : "2.0" , "method" : "' + query + '" , "params" : ' + params + ' , "id":1 }')

    json_object = json.loads(json_response)

    #return nothing if there was an error
    if(json_object.has_key('result')):
        return json_object['result']
    else:
        return None


playlist_id = '0' #audio is always 0
player_id = '0' #audio player is always 0
playlist_file = 'Test'

#stop whatever is playing
getJSON('Player.Stop','{"playerid":' + player_id + '}')

#clear the playlist
getJSON('Playlist.Clear','{"playlistid" :' + playlist_id + '}')

#set partymode
getJSON('Player.SetPartymode','{"playerid":' + player_id + ',"partymode":true}')

#open the new playlist
getJSON('Player.Open','{ "item": { "partymode": "special://musicplaylists/' + playlist_file + '" } }')

#start the playlist (this may not be necessary, the OPEN method might call it for you)
getJSON('Player.PlayPause','{"playerid":' + player_id + '}')

Some modifications might be necessary to get it to work for you but this is a good working start.
find quote
backspace Offline
Senior Member
Posts: 112
Joined: Mar 2012
Reputation: 1
Post: #20
(2012-11-05 17:48)robweber Wrote:  Some modifications might be necessary to get it to work for you but this is a good working start.
A little fiddling to get it right but works like a charm Smile Thanks

Now to get someone to finish the GUI for this... Smile
find quote