How to access 'limit bandwidth' from python
#1
I'd like to supply a setting to limit the bandwidth for m3u8 streams (without downloading the file). I noticed that xbmc/Kodi has an option
under System->Internet access->'Internet connection bandwidth limitation'.
When enabling this bandwidth limitation it successfully applies to streaming quality, nonetheless there are many users
(including me until a few days ago) who don't know about this and often request such quality limitation options for addons.

Now my aim is to add such an option to my settings menu that either directly sets this value or lets me set this value from the python side.
I tried to track the builtin function behind this using debug logging but didn't succeed.

Has anyone a solution for this?
Reply
#2
JSON-RPC can be used to get this value, with the method "Settings.GetSettingValue" and param "setting": "network.bandwidth".

Plugins can use the following function which returns a number in Kbps, 0 meaning unlimited.

Code:
def get_bandwidthlimit():
    json_result = xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.GetSettingValue","params":{"setting":"network.bandwidth"},"id":1}')
    data_object = json.loads(json_result)
    return data_object['result']['value']
Reply
#3
Thank you very much, now I see there is also "Settings.SetSettingValue" to change it!
Reply
#4
(2016-10-30, 10:46)tim619 Wrote: Thank you very much, now I see there is also "Settings.SetSettingValue" to change it!

Which you shouldn't do because that will limited everything in Kodi and not just your plugins
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
#5
Yes, I noticed that. Can you than tell me the proper way like passing bandwidth parameter to xbmc.player.
I have an url which has to be stacked from parts. I cannot load every part of this and than rebuild the stacked url, users would wait a minute...
Reply
#6
(2016-10-30, 10:48)Martijn Wrote:
(2016-10-30, 10:46)tim619 Wrote: Thank you very much, now I see there is also "Settings.SetSettingValue" to change it!

Which you shouldn't do because that will limited everything in Kodi and not just your plugins

Wouldn't it be possible to get, and store, the original setting prior to changing it via the add-on, and then revert to the original when exiting the add-on?
Kodi Nexus (20.2) on Dell Optiplex 980 Lubuntu 22.04 | Kodi Matrix (19.3) on HTPC Lubuntu 20.04 | My Add-ons | Legacy Repo | Matrix Repo
>>>>> Newest MetalChris Addons: Local Now | Redbox | NEWSnet| NHL Radio | Weather Unlocked
Reply
#7
Sure.... however as always if the addon errors out for some reason it can't put original value back
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
#8
(2016-10-30, 17:57)Martijn Wrote: Sure.... however as always if the addon errors out for some reason it can't put original value back


Ah, yes. I knew there was a good reason for asking instead of just proceeding on my own.

Thanks.
Kodi Nexus (20.2) on Dell Optiplex 980 Lubuntu 22.04 | Kodi Matrix (19.3) on HTPC Lubuntu 20.04 | My Add-ons | Legacy Repo | Matrix Repo
>>>>> Newest MetalChris Addons: Local Now | Redbox | NEWSnet| NHL Radio | Weather Unlocked
Reply

Logout Mark Read Team Forum Stats Members Help
How to access 'limit bandwidth' from python0