PM4K / PlexMod for Kodi (18, 19, 20, 21, 22+)

Haha, as if you smelled it. I announced an auto updater functionality a couple of weeks ago.

0.8.0-beta4: script.plexmod.zip (3.0 MB)

Auto Updater!

I’ve built a relatively simple updater loop into the service component of PM4K, which usually just makes sure PM4K is run on startup. Some details:

Update source:

Its default is “Repository”, which is the same has it has always been. If you’ve added PM4K via the Don’t Panic repository, Kodi will make sure to keep you up to date with it. It will only download stable updates and it can take some time until it does. The auto updater is essentially disabled in this mode.

Then there’s “Stable”, which uses the Don’t Panic repository’s releases directly and checks for stable updates more often, and it doesn’t do so in the background while you can decide when/if to install the update. If you’ve never installed the repository or want more control over the updates, you can now uninstall Don’t Panic, disable it, or whatever, and let PM4K handle it on its own.

The third and most interesting option is “Beta”, which fetches the newest addon.xml from the develop-kodi21 branch, which effectively is the same as installing the beta zips from this thread, automatically.

The other options should be self-explanatory:

Check for updates on start

Checks for an update immediately, once, when PM4K is started, and not just in a periodic interval.

Functionality

In general, once set to a specific source, the updater will check for new updates every 4 hours. When it finds one and you visit the Home view again, it will notify you about the update allowing you to immediately install it, or postpone it (it will ask again on the next interval).

Note: Due to the way the inter process communication is currently implemented, you might not be on the home view when the updater tells the main plugin that there’s an update available, and it waits up to 10 hours for a user response (e.g., you visit Home again). This means, that you can miss an update. It will ask again in the next cycle, though, so that shouldn’t be much of an issue.

Source switch, Downgrade/Sidegrade

When you switch update sources, let’s say, from Repository to Beta, it will immediately check for an update once you exit Settings and offer it to you.

When you switch update sources from beta to stable, it will allow a downgrade/sidegrade and it offers it to you exactly once, immediately after you switch the update source. Afterwards it will only offer real updates compared to your currently installed version.

Attention: If you downgrade below 0.8.0-beta4, you’ll lose the update functionality, obviously.

Non-intrusiveness (kind of)

Well, it is intrusive, as it prompts you when there’s an update available, yes. But other than that, it doesn’t affect the UI or playback in any way.

The update check tick rate is normally at 10 seconds, where it only checks whether it’s time to check for an update. Only when you’re in the settings or home view, it does that every 2 seconds, to catch the inter process communication between the UI process (plugin.py) and the service process (service.py).

The updater stops completely when the system receives a sleep event and wakes up when the system wakes up again.

When video playback is detected, the update check is paused.

Upgrade procedure

When you confirm the update, PM4K will exit on its own and the service will download the correct zip, verify it, unpack it, and replace your current PM4K installation (settings and data will be kept, of course). Then it will start PM4K again on its own. This is only true for minor updates, because:

Before it replaces the installation, it hashes the language file that you currently use, and checks whether it differs from the new one. If it does, or the updater itself has changed, it will warn you that you can still simply re-run PM4K automatically, but that you might run into errors or unexpected behaviour. The safe route at this point is to restart Kodi, as we can’t tell Kodi to reload language files and we can’t tell it to re-run a service at the moment.

If you decide to run it anyways, in most cases, you might just encounter untranslated strings in certain areas, which will default to English.

Note

Update: beta4 has been reuploaded and the latest update test is 0.8.0-beta4b!
The updater has been introduced with 0.8.0-beta4. 0.8.0-beta4.1c has been pushed already, which is a blank release, so we can catch any issues and you can test the update process. You will be prompted for the 0.8.0-beta4.1 update once you change the update source to Beta.

Changes:

  • Implement updater service
  • Core: Fix possible import (and reactivate) issues by reducing the import stack in update_checker via phasing out settings utils into settings_util.py
  • Updater: Fix service/install crashing with missing language file for selected language

If you’re interested in the core implementation, see updater.py and update_checker.py.

Edit: Reuploaded zip (01:35 CEST)
Edit 2: Reuploaded zip (02:00 CEST)
Edit 3: Reuploaded zip (03:01 CEST)
Edit 4: Reuploaded zip (04:44 CEST) (yes, it’s too late, I know)

12 Likes