Skip to content

Commit

Permalink
Add 'limit bitrate' setting
Browse files Browse the repository at this point in the history
  • Loading branch information
emilsvennesson committed Sep 8, 2016
1 parent d01bc77 commit fa349bb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
12 changes: 12 additions & 0 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,19 +568,31 @@ def ask_bitrate(bitrates):
ret = dialog.select(language(30026), options)
if ret > -1:
return bitrates[ret]
else:
return None


def select_bitrate(manifest_bitrates=None):
"""Returns a bitrate while honoring the user's preference."""
bitrate_setting = int(addon.getSetting('preferred_bitrate'))
if bitrate_setting == 0:
preferred_bitrate = 'highest'
elif bitrate_setting == 1:
preferred_bitrate = 'limit'
else:
preferred_bitrate = 'ask'

manifest_bitrates.sort(key=int, reverse=True)
if preferred_bitrate == 'highest':
return manifest_bitrates[0]
elif preferred_bitrate == 'limit':
allowed_bitrates = []
max_bitrate_allowed = int(addon.getSetting('max_bitrate_allowed'))
for bitrate in manifest_bitrates:
if max_bitrate_allowed >= int(bitrate):
allowed_bitrates.append(str(bitrate))
if allowed_bitrates:
return allowed_bitrates[0]
else:
return ask_bitrate(manifest_bitrates)

Expand Down
8 changes: 8 additions & 0 deletions resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,11 @@ msgstr ""
msgctxt "#30034"
msgid "The PIN code you have entered is incorrect."
msgstr ""

msgctxt "#30035"
msgid "Limit bitrate"
msgstr ""

msgctxt "#30036"
msgid "Max bitrate allowed (Kbps)"
msgstr ""
8 changes: 8 additions & 0 deletions resources/language/Swedish/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,11 @@ msgstr "Barnlås"
msgctxt "#30034"
msgid "The PIN code you have entered is incorrect."
msgstr "PIN-koden du angav är felaktig."

msgctxt "#30035"
msgid "Limit bitrate"
msgstr "Begränsa bitrate"

msgctxt "#30036"
msgid "Max bitrate allowed (Kbps)"
msgstr "Max tillåtna bitrate (Kbps)"
3 changes: 2 additions & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<setting id="email" type="text" label="30001" default=""/>
<setting id="password" type="text" label="30002" option="hidden" enable="!eq(-1,)" default=""/>
<setting id="subtitles" type="bool" label="30012" default="true"/>
<setting id="preferred_bitrate" type="enum" label="30023" lvalues="30024|30025" default="0"/>
<setting id="preferred_bitrate" type="enum" label="30023" lvalues="30024|30035|30025" default="0"/>
<setting id="max_bitrate_allowed" type="number" label="30036" default="5000" subsetting="true" visible="eq(-1,1)"/>
</category>
<category label="30004">
<setting id="debug" type="bool" label="Add-on debugging" default="false"/>
Expand Down

0 comments on commit fa349bb

Please sign in to comment.