• 1
  • 2
  • 3
  • 4(current)
  • 5
  • 6
  • 32
Library Auto Updater - Version 1.1.0
#46
I just posted a pull request for the main XBMC repo with a few updates - thanks to pkscuot for the basis for a lot of what went into this one.

A few small things that I liked from pskcout's code got merged in some form. Basically the ability to run the update even while the player is running, checking for setting changes during each run so settings can be modified without an XBMC restart, and some better log formatting.

I did like the idea behind making the timers a little more flexible but letting the user kind of build their own timer through the gui seemed kind of painful. Instead I opted for a cron style scheduler. In the 'Advanced' Timer mode you can specify a cron expression that the updater will run on instead of using the basic hourly timer interval. This should be a lot more flexible for people and give them almost endless options for configuring the timers. Cron knowledge is necessary but that can be picked up using Google in about 1 min.

As a side note, it has occurred to me that by using the cron expression timers this addon could be easily modified to not only do updates, but allow a host of XBMC built in functions to run via a cron scheduler. The 'program' function could let a user setup multiple timers for XBMC functions and the 'service' part could execute them accordingly. Probably not something I'll get to anytime soon though.
Reply
#47
[quote=robweber]I did like the idea behind making the timers a little more flexible but letting the user kind of build their own timer through the gui seemed kind of painful. Instead I opted for a cron style scheduler. In the 'Advanced' Timer mode you can specify a cron expression that the updater will run on instead of using the basic hourly timer interval. This should be a lot more flexible for people and give them almost endless options for configuring the timers.[/QUOTE ]

I'm looking forward to seeing how that got implemented. That's really want I wanted to do, but I couldn't figure out a good way to do it. Did separate timers for each update make it into this update as well? I'm finding that's important for me.

[quote]
As a side note, it has occurred to me that by using the cron expression timers this addon could be easily modified to not only do updates, but allow a host of XBMC built in functions to run via a cron scheduler. The 'program' function could let a user setup multiple timers for XBMC functions and the 'service' part could execute them accordingly. Probably not something I'll get to anytime soon though.[/quote]

Oh good. Another project. I was running out of programming projects anyway. Big Grin
Reply
#48
pkscuot Wrote:I'm looking forward to seeing how that got implemented. That's really want I wanted to do, but I couldn't figure out a good way to do it. Did separate timers for each update make it into this update as well? I'm finding that's important for me.

You can check the code for more details but I was lucky enough to find a public domain CronExpression python class online. I thought the original author had his name on that class file but I see now it isn't, I'll add that for the next commit so he gets credit. This class parsed a regular cron string and then let you check via a check_trigger() command if it should run or not.

As far as the separate timers I did not include them into this update. To be honest I have mixed opinions on this one and thought maybe some other users might be able to comment. I think the updates run fast enough that running both on the same schedule shouldn't be a problem; on the other hand if enough people really want to run things on different schedules than it is worth offering that flexibility.

Any thoughts from the community on this one?
Reply
#49
I've got updated code based on 0.5.0 that will allow you to run any command that can be run by xbmc.executebuiltin. You can run as many as you want with separate lines in a cron.txt file. The code as well as a patch file for service.py is available at https://github.com/pkscout/service.libra...update.exp. The readme was updated as well just to add an explanation of what I did.

Basically, service.py now looks for cron.txt in the addon's data folder. If it finds one, it loops through each line and runs it through the same logic as the library update and then runs whatever command you stick at the end.

Here's the cron.txt I have right now:
Code:
45 6 * * * RunPlugin(plugin://plugin.video.hulu/?mode='QueueLibrary')
30 6 * * * UpdateLibrary(music)
15 * * * * UpdateLibrary(video)
That runs the Hulu queue update at 6:45am, a music library update at 6:30am, and video library updates 15 minutes after every hour.

This is set as an easter egg right now. There is no setting to enable or disable it, and no way to set a different path for the cron.txt file. That could certainly be done, but for now enabling advanced timers gets you the extra functionality.

I'm pretty sure I could get this to run any command, but given the number of platform specific ways to run native commands, I wasn't sure it was worth it.

I also included some code to create the addon datadir if it doesn't exist. This might not matter if you install the plugin through the XBMC repo (or a zip file), but when I created the plugin directory by hand and put the code in, it generated an error that the datadir wasn't there until I went into the settings. Lastly, I truncated the last_run seconds down to the minute. By doing that, the updates run at the top of the minute rather than sometime during that minute. That's an ADD thing with me. I'll live if that doesn't get incorporated into an actual release. Big Grin
Reply
#50
Does this work with an atv2 on eden beta3? Also is it possible to update a different profile when in another profile? I have a master profile and then a kids profile. I would like to update both profile libraries (at different times).

Thanks.
Nvidia Shield with Kodi 18
Reply
#51
pkscuot Wrote:I've got updated code based on 0.5.0 that will allow you to run any command that can be run by xbmc.executebuiltin. You can run as many as you want with separate lines in a cron.txt file. The code as well as a patch file for service.py is available at https://github.com/pkscout/service.libra...update.exp. The readme was updated as well just to add an explanation of what I did.

Basically, service.py now looks for cron.txt in the addon's data folder. If it finds one, it loops through each line and runs it through the same logic as the library update and then runs whatever command you stick at the end.

Here's the cron.txt I have right now:
Code:
45 6 * * * RunPlugin(plugin://plugin.video.hulu/?mode='QueueLibrary')
30 6 * * * UpdateLibrary(music)
15 * * * * UpdateLibrary(video)
That runs the Hulu queue update at 6:45am, a music library update at 6:30am, and video library updates 15 minutes after every hour.

This is set as an easter egg right now. There is no setting to enable or disable it, and no way to set a different path for the cron.txt file. That could certainly be done, but for now enabling advanced timers gets you the extra functionality.

I'm pretty sure I could get this to run any command, but given the number of platform specific ways to run native commands, I wasn't sure it was worth it.

I also included some code to create the addon datadir if it doesn't exist. This might not matter if you install the plugin through the XBMC repo (or a zip file), but when I created the plugin directory by hand and put the code in, it generated an error that the datadir wasn't there until I went into the settings. Lastly, I truncated the last_run seconds down to the minute. By doing that, the updates run at the top of the minute rather than sometime during that minute. That's an ADD thing with me. I'll live if that doesn't get incorporated into an actual release. Big Grin

Thanks for the work on this. I actually did a clean install from the repo in XBMC and noticed the addon directory does not get created unless you modify the settings so that piece of code is something that needs to be added for sure. I'll merge most of this into the main release when I get a spare minute (maybe tonight or tomorrow). I like the reading in of the cron.txt file but I think I might just spin that off into a new addon. I'm thinking of some type of GUI interface via the programs area to create the commands - maybe even pre-populate a drop down of xbmc commands.

rflores2323 Wrote:Does this work with an atv2 on eden beta3? Also is it possible to update a different profile when in another profile? I have a master profile and then a kids profile. I would like to update both profile libraries (at different times).

Thanks.

As far as I know this should work like any other addon for the atv2 - it doesn't rely on any additional libraries or anything. I'm using it on Eden Beta 3 as well with no issues. As far as the multiple profile thing I really don't know. I think the UpdateLibrary() built in command will run for whatever user is logged in at the time it runs, but I'll have to check on that one. I read through the wiki quick and couldn't see any additional parameters to specify which profile to run the update for. I'll see what else I can find.

Any devs have any insight into this?
Reply
#52
Filled in the basics from the readme on the wiki page for your addon:
http://wiki.xbmc.org/index.php?title=Add...uto_Update
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#53
Martijn Wrote:Filled in the basics from the readme on the wiki page for your addon:
http://wiki.xbmc.org/index.php?title=Add...uto_Update

Awesome! Thanks. I'll make a note to update this if anything major changes in way of configuration for the future.
Reply
#54
hi Rob,

can you tell me how to edit Library Auto Update to edit/increase the frequency options. I'm running it on appletv so no cron option as far as I know.
Reply
#55
pacific88 Wrote:hi Rob,

can you tell me how to edit Library Auto Update to edit/increase the frequency options. I'm running it on appletv so no cron option as far as I know.

You don't need cron on the actual device. The plugin just uses a cron expression to determine the update schedule. You can run this every minute if you really wanted to by using:

* * * * *

Check out the readme and do a search for cron to see all the different ways you can setup a schedule.
Reply
#56
thanks, pkscuot...

i still couldn't get a cron solution to work so i ended up using this:

http://forum.xbmc.org/showthread.php?p=6...post617324 - a scheduled batch file running on a windows box
Reply
#57
pacific88 Wrote:thanks, pkscuot...

i still couldn't get a cron solution to work so i ended up using this:

http://forum.xbmc.org/showthread.php?p=6...post617324 - a scheduled batch file running on a windows box

What part of it couldn't you get to work - did the addon simply not use your cron expression?

Having to do crazy hacks, like schedule tasks on another machine, is exactly why this addon exists so getting it to work within XBMC would be a more ideal solution. If you wouldn't mind explaining a little more what you tried; or better yet posting a debug log that would be great. If you do post a log please change the correct settings (ie, switch to 'Advanced' in the timer settings and create your cron expression) then wait for it to run at least 2 cycles before posting the log that would be a big help.

Thanks.
Reply
#58
Um, I think there is a missing import in the plugin that just got pushed out. After I updated it and restarted I got a script error. Checking the log, it was complaining that the global variable os didn't exist (where you check for the addon data directory's existence). Once I added "import os" to the top of the script the problem went away.
Reply
#59
pkscuot Wrote:Um, I think there is a missing import in the plugin that just got pushed out. After I updated it and restarted I got a script error. Checking the log, it was complaining that the global variable os didn't exist (where you check for the addon data directory's existence). Once I added "import os" to the top of the script the problem went away.

I noticed that too. I was all pumped to see the addon update and then I saw the error and was ticked that it snuck through like that. I sent a request to the repo for an update so hopefully it gets pushed out soon.

Thanks.
Reply
#60
I can't get it working either. I get this error in the log:
Code:
20:12:13 T:94728192   ERROR: Error Contents: global name 'timer_amounts' is not defined
20:12:13 T:94728192   ERROR: Traceback (most recent call last):
                                              File "/var/mobile/Library/Preferences/XBMC/addons/service.libraryautoupdate/default.py", line 6, in <module>
                                                AutoUpdater().runProgram()
                                              File "/var/mobile/Library/Preferences/XBMC/addons/service.libraryautoupdate/service.py", line 31, in runProgram
                                                if(time.time() >= self.last_run + (timer_amounts[self.Addon.getSetting('timer_amount')] * 60 * 60)):
                                            NameError: global name 'timer_amounts' is not defined
Reply
  • 1
  • 2
  • 3
  • 4(current)
  • 5
  • 6
  • 32

Logout Mark Read Team Forum Stats Members Help
Library Auto Updater - Version 1.1.00