Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 8
Cron for Kodi - Support Thread (formally CronXBMC)
#1
I've started writing an addon that will be a growth of the current XBMC Library Updater addon. Basicaly rather than just update your library, I want to make an addon that will let you schedule multiple XBMC functions to run via a cron-like scheduler. All of your timers can now be handled directly within XBMC.

Examples include:

Rebooting
Restart XBMC
Take a Screenshot
Run another Addon or Script
Play Media
Refresh RSS
Send a Notification
Set XBMC Volume
Update Music/Video Libraries

Additionally you can specifiy your timers to display an XBMC notification when they run. With most of the pieces were already in place from the updater addon I didn't think this would be too difficult.

What It Can Do So Far:

The cron jobs themselves are in an xml format

Code:
<job name="Job Name" expression="* * * * *" command="XBMCCommand()" show_notification="true/false" />

This will also allow some growth if we want to include other things via the GUI in time.

I also have a basic GUI started (see screenshot). I tried to modify the the RSS Editor addon dialog to serve as a job creator/editor, but this is where I got stuck.

Update - 01/08/2017

After growing rather frustrated with the dated GUI code I started over. New version is for Jarvis+ and uses Kodi integrated GUI elements for the display. Not quite as pretty as the old one but all the functionality is there.

Update - 4/22/2012

I've moved all the code for this addon to Github. I'm trying to consolidate all my projects there, plus it will be easier for someone to pick up with should anyone ever be interested. Everything in the release is exactly the same, just a new location.

Cron XBMC on Github - https://github.com/robweber/cronxbmc

Update - 3/02/2015

Due to some interest by third party developers I've updated this addon for Helix to use some more updated service addon functions. I've also added a module extension point so you can import the service.cronxbmc module in your own addons. To interface with the cron.xml file via the CronManager to so as follows:

Code:
from cron import CronManager,CronJob

manager = CronManager()

#get jobs
jobs = manager.getJobs()

#delete a job
manager.deleteJob(job.id)

#add a job
job = CronJob()
job.name = "name"
job.command = "Shutdown"
job.expression = "0 0 * * *"
job.show_notification = "false"

manager.addJob(job)

#Please be aware that adding or removing a job will change the job list (and change job ids) so please refresh your job list each time by using:

jobs = manager.getJobs()

#This will also pull in any new jobs that may have been added via other methods
Reply
#2
I have to say I'm a little disappointed. Three days and over 100 views later no one seems interested in this type of idea; even after all the "how to automate" type requests that seem to pop up in the forum.

I'm posting a link to what I have coded so far. Hopefully someone will stumble on this and have the know-how to finish up the GUI portion and make it user friendly. As of right now (as reported above) you can certainly add your timers manually via the cron.xml file and view them in the Programs area of XBMC. I added a nextRun() function that will figure out how long until the next run time - may be useful for the GUI or some pop-up notifications.


If anyone is seeing this for the first time and finds it interesting I'd be happy to collaborate on making it better. If downloading - view the README document for information on how to setup the cron.xml file with the correct formatting.
Reply
#3
I'm just getting familiar with modifying a few skins now, so I would be of limited use to you on the GUI. I am more adept at the coding side of things but you seem to have that covered.

Have you considered adding the ability to schedule an update for just one source? As an example, my tv shows are all set to update almost instantaneously based on that one directory getting an update. It would be nice, however, to update just the source I use for new movies. My other sources (older movies, tv shows, music videos) are larger and/or take longer to update with very little upside. Being able to schedule an update for just one directory/source would be of huge benefit.
Reply
#4
Code:
<job name="Job Name" expression="* * * * *" command="XBMCCommand()" show_notification="true/false" />
How about
Code:
<job name="Job Name" minute="*" hour="*" day="*" month="*" weekday="*" command="XBMCCommand()" show_notification="true/false" />
as you shouldn't have to consult a manual to use it.
Reply
#5
@GIjones

That is exactly the type of thing this would be useful for. The UpdateLibrary command takes the type of library and can also take a path as parameters. You could set a task to update your active directories more often using that command.

@HansMayer

My intent with this was to have the GUI be good enough that the format of the xml filewas something the user will never see. Since I couldnt finish the GUI this code is released as is in the hopes of getting some people interested. I would not try such submitting this to the xbmc repo for users at large like this.

Having the user interface have options for minute, second, etc would work. The power of cron is really what drives this so I wouldn't want to make it too simple and lose that.
Reply
#6
robweber Wrote:@HansMayer

My intent with this was to have the GUI be good enough that the format of the xml filewas something the user will never see. Since I couldnt finish the GUI this code is released as is in the hopes of getting some people interested. I would not try such submitting this to the xbmc repo for users at large like this.

Having the user interface have options for minute, second, etc would work. The power of cron is really what drives this so I wouldn't want to make it too simple and lose that.
I don't understand. What exact functionality would be lost if you would divide the options to make the arguments more obvious? You could still use hour="*/1" and stuff like that.
Reply
#7
HansMayer Wrote:I don't understand. What exact functionality would be lost if you would divide the options to make the arguments more obvious? You could still use hour="*/1" and stuff like that.

No functionality would be lost, but there really isn't anything to be gained either. In short, if the "common user" is never really going to interact with the cron.xml file; why do I care if they understand how a cron expression is put together. Separating out the minute,hour,day,month,day of week isn't really helping them any. If they don't understand cron (have to refer to consult another manual) they probably won't know enough to understand that minute="*/5" is any different than expression="*/5 * * * *", either way you have to know how cron works.

When referring to "lost functinoality" I meant the GUI interface should abstract the inner works enough that the user can easily setup their schedules, but yet be complicated enough that more complex situations can be handled. Below I used the settings.xml file to mock-up how a "create schedule" type window could work within the addon. I was dealing with the skinning limitations of the addon settings window here so it could look a lot nicer and possibly have more options.

The point here again being that this is what the typical user would see - the format of cron.xml doesn't matter. After hitting 'OK' to add the schedule it would be put into the correct expression format and saved.

Image

Image

Hopefully this makes sense. I'm not trying to say that modifying the xml structure is a bad idea, just that it wasn't ever meant to be something the typical person would go mucking around with. It doesn't give any bonuses coding-wise either so there isn't really an upside.
Reply
#8
Would love a addon like this for easy setup of tasks

Sadly tho I am of none to little use in any of the parts you need help
Reply
#9
I'm really liking this idea. The least one has to drop to a terminal to configure things
the better. Keeping it simple for the average person, and leaving the rest to those
of us that enjoy making our lives a little more complicated..
Reply
#10
Just wanna say thx for this addon, works allready for me!
Hopefully for others it gets futher developed Wink

Was actually about to try and change your "XBMC Auto Library Updater" to auto restart my system... then found this Wink

Thx, LoL Wink
Reply
#11
Wink 
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?
Reply
#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?
Reply
#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?
Reply
#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)
Reply
#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.
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 8

Logout Mark Read Team Forum Stats Members Help
Cron for Kodi - Support Thread (formally CronXBMC)1
This forum uses Lukasz Tkacz MyBB addons.