XBMC Library Updater Addon

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
pkscuot Offline
Fan
Posts: 600
Joined: Jan 2011
Reputation: 10
Location: Honolulu, HI
Post: #41
robweber Wrote:Did you use the current XBMC updater addon as the base for the additions you made? Sounds like you did so this may be something I could easily merge and add to the main repo for this addon. If you could make a diff that would be the easiest

I did base it off the current code. I put a patch file in my github repository along with all the code. I've never done diff files before, but it looks reasonable to me.

https://github.com/pkscout/service.libra...e.advanced

I've branched my github repo, as I'm also working on a way to have separate timers for music and video. I might be able to finish it today or early tomorrow if you'd rather wait to see that.
find quote
pkscuot Offline
Fan
Posts: 600
Joined: Jan 2011
Reputation: 10
Location: Honolulu, HI
Post: #42
pkscuot Wrote:I've branched my github repo, as I'm also working on a way to have separate timers for music and video. I might be able to finish it today or early tomorrow if you'd rather wait to see that.

FYI, that's done now and been through testing on both my dev and prod machines. The URL in the last post points to the most up-to-date code. The v2 patch file takes you from 0.4.2 to what I labeled 0.6.0. No need to use the first patch, although it's still there if you want to look at it.

If you do decide to go with the 0.5.0 stuff, there are two bugs in the 0.5.0 patch. First, I had some non-localized strings the in the enums in settings.xml. Second, there is a "drift" bug on time of day and part of hour timers. Because the timer didn't get reset until after the library updates were done, over time the timer drifted (i.e. if you had something running at a quarter past each hour, over the course of a few days it became more like 17 past). Both those things are fixed in the 0.6.0 patch.
find quote
pkscuot Offline
Fan
Posts: 600
Joined: Jan 2011
Reputation: 10
Location: Honolulu, HI
Post: #43
OK, this morning I found a bug with the timers I haven't been able to track down. I'll work on it today and let you know tomorrow if it's ready.
find quote
robweber Offline
Fan
Posts: 598
Joined: Sep 2009
Reputation: 15
Post: #44
pkscuot Wrote:OK, this morning I found a bug with the timers I haven't been able to track down. I'll work on it today and let you know tomorrow if it's ready.

I'm looking over the changes from the git repo you posted. No comments yet, just getting into it. Thanks for working on this.
find quote
pkscuot Offline
Fan
Posts: 600
Joined: Jan 2011
Reputation: 10
Location: Honolulu, HI
Post: #45
robweber Wrote:I'm looking over the changes from the git repo you posted. No comments yet, just getting into it. Thanks for working on this.

Good enough. I'm still working on it. What's in the main branch should all be working, so I branched it yesterday to start something else. Basically I noticed that 95% of the plugin is timer logic, and 5% is actually doing the updates and logging stuff. I have another project that needs timers, so I'm trying to abstract out the "do the updates" stuff into another class so that if you want to use the timer framework someplace else you only have to change the action file rather than hump through all the timer logic.
find quote
robweber Offline
Fan
Posts: 598
Joined: Sep 2009
Reputation: 15
Post: #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.
find quote
pkscuot Offline
Fan
Posts: 600
Joined: Jan 2011
Reputation: 10
Location: Honolulu, HI
Post: #47
robweber Wrote: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.

Oh good. Another project. I was running out of programming projects anyway. Big Grin
find quote
robweber Offline
Fan
Posts: 598
Joined: Sep 2009
Reputation: 15
Post: #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?
find quote
pkscuot Offline
Fan
Posts: 600
Joined: Jan 2011
Reputation: 10
Location: Honolulu, HI
Post: #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
(This post was last modified: 2012-02-11 21:18 by pkscuot.)
find quote
rflores2323 Offline
Posting Freak
Posts: 1,950
Joined: Jan 2009
Reputation: 2
Post: #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.

ATV1 with crystalbuntu V1 (11.eden). Theater remote URC MX-810, droidx wtih xbmc remote, or transformer tf101 with YATSE. 2 x ATV2 (V12.0 Eden).

find quote
Post Reply