Better video quality support (#496)
* Better video quality support * Quality selector, preferences, and content task * Lint fix * web app --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
7c2cb5517a
commit
9e68decc88
24 files changed
+765
-171
No files matched your search
+3
-1
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
- Nothing worth mentioning yet.
|
### Added
|
||||||
|
|
||||||
|
- Support for better video quality selector
|
||||||
|
|
||||||
## [0.31.0] - 2024-11-24
|
## [0.31.0] - 2024-11-24
|
||||||
|
|
||||||
|
|||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
|
import "pkg:/source/utils/FocusManagement.bs"
|
||||||
|
import "pkg:/source/utils/Locale.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.top.focusable = true
|
||||||
|
m.top.itemSpacings = [8]
|
||||||
|
|
||||||
|
m.button = m.top.findNode("button")
|
||||||
|
m.button.observeField("buttonSelected", FuncName(OpenQualitySelector))
|
||||||
|
AdjustButtonLabel(m.button)
|
||||||
|
|
||||||
|
m.qualityToLabel = {
|
||||||
|
"auto": Tr(Locale.Settings.AutoQuality)
|
||||||
|
"1080p": "1080p"
|
||||||
|
"720p": "720p"
|
||||||
|
"480p": "480p"
|
||||||
|
"360p": "360p"
|
||||||
|
"240p": "240p"
|
||||||
|
"144p": "144p"
|
||||||
|
}
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnFocusChange() as void
|
||||||
|
if not m.top.focus
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
NodeSetFocus(m.button, true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function AdjustButtonLabel(button as object) as void
|
||||||
|
children = button.getChildren(-1, 0)
|
||||||
|
for each child in children
|
||||||
|
if child.isSubtype("Label") and child.hasField("horizAlign")
|
||||||
|
child.observeField("horizAlign", FuncName(OnButtonLabelHorizAlignChanged))
|
||||||
|
child.horizAlign = "left"
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnButtonLabelHorizAlignChanged(event as object)
|
||||||
|
label = event.getRoSGNode()
|
||||||
|
if label.horizAlign <> "left"
|
||||||
|
label.horizAlign = "left"
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function BindPreference(preferences as object, key as string)
|
||||||
|
if m.preferences <> invalid and m.key <> invalid
|
||||||
|
m.preferences.unobserveFieldScoped(m.key)
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.preferences = preferences
|
||||||
|
m.key = key
|
||||||
|
|
||||||
|
if preferences <> invalid and key <> invalid
|
||||||
|
preferences.observeFieldScoped(key, FuncName(OnPreferenceChange))
|
||||||
|
OnPreferenceChange()
|
||||||
|
end if
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OpenQualitySelector()
|
||||||
|
selector = CreateObject("roSGNode", "QualitySelector")
|
||||||
|
m.appController@.PushScreen(selector)
|
||||||
|
selector@.BindNode()
|
||||||
|
selector.value = m.top.value
|
||||||
|
selector.observeField("save", FuncName(OnSaveQualitySelector))
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnSaveQualitySelector(event as object)
|
||||||
|
editor = event.GetRoSGNode()
|
||||||
|
m.top.value = editor.value
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnPreferenceChange()
|
||||||
|
m.top.value = m.preferences[m.key]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnValueChange() as void
|
||||||
|
if m.preferences = invalid or m.key = invalid
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
value = m.top.value
|
||||||
|
m.preferences[m.key] = value
|
||||||
|
|
||||||
|
if StringUtils.IsNullOrEmpty(value)
|
||||||
|
m.button.text = Tr(Locale.Settings.AutoQuality)
|
||||||
|
else
|
||||||
|
qualities = value.split(",")
|
||||||
|
labels = []
|
||||||
|
for each quality in qualities
|
||||||
|
label = m.qualityToLabel[quality]
|
||||||
|
if StringUtils.IsNullOrEmpty(label)
|
||||||
|
label = quality
|
||||||
|
end if
|
||||||
|
labels.push(label)
|
||||||
|
end for
|
||||||
|
|
||||||
|
m.button.text = labels.join(", ")
|
||||||
|
end if
|
||||||
|
end function
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
<component name="EditQualityControl" extends="LayoutGroup" includes="AutoBind,Focus">
|
||||||
|
<interface>
|
||||||
|
<field id="displayText" type="string" alias="DisplayTextLabel.text" />
|
||||||
|
<field id="description" type="string" alias="DescriptionLabel.text" />
|
||||||
|
<field id="value" type="string" onChange="OnValueChange" />
|
||||||
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
|
<function name="BindPreference" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Label id="DisplayTextLabel" width="450" />
|
||||||
|
<Label id="DescriptionLabel"
|
||||||
|
width="450"
|
||||||
|
color="0xb4b4b4ff"
|
||||||
|
wrap="true">
|
||||||
|
<Font role="font" uri="font:SystemFontFile" size="18" />
|
||||||
|
</Label>
|
||||||
|
<Button id="Button"
|
||||||
|
iconUri=""
|
||||||
|
focusedIconUri=""
|
||||||
|
showFocusFootprint="true"
|
||||||
|
minWidth="420" />
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
|
import "pkg:/source/utils/Logging.bs"
|
||||||
|
import "pkg:/source/utils/MathUtils.bs"
|
||||||
|
import "pkg:/source/utils/RemoteKeys.bs"
|
||||||
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
|
function Init()
|
||||||
|
m.checkList = m.top.findNode("checkList")
|
||||||
|
m.closeButton = m.top.findNode("closeButton")
|
||||||
|
m.saveButton = m.top.findNode("saveButton")
|
||||||
|
|
||||||
|
SetNavigation(m.checkList, RemoteKeys.Down, m.saveButton)
|
||||||
|
SetNavigation(m.saveButton, RemoteKeys.Up, m.checkList)
|
||||||
|
SetNavigation(m.closeButton, RemoteKeys.Up, m.checkList)
|
||||||
|
SetNavigation(m.saveButton, RemoteKeys.Right, m.closeButton)
|
||||||
|
SetNavigation(m.closeButton, RemoteKeys.Left, m.saveButton)
|
||||||
|
|
||||||
|
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
||||||
|
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
||||||
|
|
||||||
|
m.lastCheckedState = [false, false, false, false, false, false, false]
|
||||||
|
m.checkList.observeField("checkedState", FuncName(OnCheckedStateChange))
|
||||||
|
|
||||||
|
SetButtonPositions()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function SetButtonPositions()
|
||||||
|
saveButtonWidth = m.saveButton.width
|
||||||
|
closeButtonWidth = m.closeButton.width
|
||||||
|
buttonsWith = closeButtonWidth + saveButtonWidth + 20
|
||||||
|
m.saveButton.translation = [780 / 2 - buttonsWith / 2, m.saveButton.translation[1]]
|
||||||
|
m.closeButton.translation = [780 / 2 + buttonsWith / 2 - closeButtonWidth, m.closeButton.translation[1]]
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnFocusChange() as void
|
||||||
|
if not m.top.focus
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
NodeSetFocus(m.checkList, true)
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnKeyEvent(key as string, press as boolean) as boolean
|
||||||
|
if NavigationKeyHandler(key, press).handled
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly
|
||||||
|
' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play
|
||||||
|
return false
|
||||||
|
end if
|
||||||
|
|
||||||
|
if key = RemoteKeys.Back and press
|
||||||
|
Close()
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
return true
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnValueChange() as void
|
||||||
|
content = m.checkList.content
|
||||||
|
value = m.top.value
|
||||||
|
|
||||||
|
if content = invalid or content.getChildCount() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
values = value.Split(",")
|
||||||
|
valuesDict = {}
|
||||||
|
for each value in values
|
||||||
|
valuesDict[value] = true
|
||||||
|
end for
|
||||||
|
|
||||||
|
checkboxes = content.getChildren(-1, 0)
|
||||||
|
checkedState = []
|
||||||
|
for i = 0 to checkboxes.Count() - 1
|
||||||
|
checkedState.push(valuesDict.DoesExist(checkboxes[i].id))
|
||||||
|
end for
|
||||||
|
m.checkList.checkedState = checkedState
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnCheckedStateChange() as void
|
||||||
|
content = m.checkList.content
|
||||||
|
if content = invalid or content.getChildCount() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
checkedState = m.checkList.checkedState
|
||||||
|
if checkedState = invalid or checkedState.Count() = 0
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
lastCheckedState = m.lastCheckedState
|
||||||
|
m.lastCheckedState = checkedState
|
||||||
|
|
||||||
|
autoChanged = lastCheckedState[0] <> checkedState[0]
|
||||||
|
hasAuto = checkedState[0]
|
||||||
|
|
||||||
|
if autoChanged
|
||||||
|
if hasAuto
|
||||||
|
checkedState = [true, false, false, false, false, false, false]
|
||||||
|
m.lastCheckedState = checkedState
|
||||||
|
m.checkList.checkedState = checkedState
|
||||||
|
m.top.value = "auto"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
checkedState = [false, true, true, true, true, true, true]
|
||||||
|
m.lastCheckedState = checkedState
|
||||||
|
m.checkList.checkedState = checkedState
|
||||||
|
m.top.value = "1080p,720p,480p,360p,240p,144p"
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
values = []
|
||||||
|
checkboxes = content.getChildren(-1, 0)
|
||||||
|
|
||||||
|
hasNonAuto = false
|
||||||
|
for i = 0 to checkboxes.Count() - 1
|
||||||
|
if not checkedState[i]
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
values.push(checkboxes[i].id)
|
||||||
|
if i <> 0
|
||||||
|
hasNonAuto = true
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
|
||||||
|
if values.Count() = 0
|
||||||
|
checkedState = [true, false, false, false, false, false, false]
|
||||||
|
m.lastCheckedState = checkedState
|
||||||
|
m.checkList.checkedState = checkedState
|
||||||
|
m.top.value = "auto"
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
if hasNonAuto and hasAuto
|
||||||
|
checkedState[0] = false
|
||||||
|
m.lastCheckedState = checkedState
|
||||||
|
m.checkList.checkedState = checkedState
|
||||||
|
values.shift()
|
||||||
|
end if
|
||||||
|
|
||||||
|
m.top.value = values.Join(",")
|
||||||
|
end function
|
||||||
|
|
||||||
|
function OnSaveButtonSelected()
|
||||||
|
OnCheckedStateChange()
|
||||||
|
m.top.save = true
|
||||||
|
Close()
|
||||||
|
end function
|
||||||
|
|
||||||
|
function Close()
|
||||||
|
m.appController@.PopScreen()
|
||||||
|
end function
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<component name="QualitySelector" extends="Group" includes="AutoBind,Focus">
|
||||||
|
<interface>
|
||||||
|
<field id="value" type="string" onChange="OnValueChange" />
|
||||||
|
<field id="save" type="boolean" alwaysNotify="true" />
|
||||||
|
<field id="appController" type="node" bind="/AppController" />
|
||||||
|
</interface>
|
||||||
|
<children>
|
||||||
|
<Rectangle
|
||||||
|
width="1280"
|
||||||
|
height="720"
|
||||||
|
color="#000000"
|
||||||
|
opacity="0.5">
|
||||||
|
</Rectangle>
|
||||||
|
<Rectangle
|
||||||
|
width="780"
|
||||||
|
height="600"
|
||||||
|
translation="[250,60]"
|
||||||
|
color="#242424">
|
||||||
|
<CheckList
|
||||||
|
id="checkList"
|
||||||
|
vertFocusAnimationStyle="floatingFocus"
|
||||||
|
translation="[220,70]">
|
||||||
|
|
||||||
|
<ContentNode role="content">
|
||||||
|
<ContentNode id="auto" title="Auto" />
|
||||||
|
<ContentNode id="1080p" title="1080p" />
|
||||||
|
<ContentNode id="720p" title="720p" />
|
||||||
|
<ContentNode id="480p" title="480p" />
|
||||||
|
<ContentNode id="360p" title="360p" />
|
||||||
|
<ContentNode id="240p" title="240p" />
|
||||||
|
<ContentNode id="144p" title="144p" />
|
||||||
|
</ContentNode>
|
||||||
|
</CheckList>
|
||||||
|
|
||||||
|
<ButtonEx
|
||||||
|
id="saveButton"
|
||||||
|
iconVisible="false"
|
||||||
|
text="Save"
|
||||||
|
padding="[30,30]"
|
||||||
|
translation="[340,500]" />
|
||||||
|
<ButtonEx
|
||||||
|
id="closeButton"
|
||||||
|
iconVisible="false"
|
||||||
|
text="Close"
|
||||||
|
padding="[30,30]"
|
||||||
|
translation="[496,500]" />
|
||||||
|
</Rectangle>
|
||||||
|
</children>
|
||||||
|
</component>
|
||||||
@@ -123,7 +123,9 @@ end function
|
|||||||
function CreateControl(item as object, container as object, startX as integer, startY as integer) as object
|
function CreateControl(item as object, container as object, startX as integer, startY as integer) as object
|
||||||
control = invalid
|
control = invalid
|
||||||
|
|
||||||
if item.type = "boolean"
|
if item.rokuComponent <> invalid
|
||||||
|
control = CreateRokuComponent(item, container)
|
||||||
|
else if item.type = "boolean"
|
||||||
control = CreateBooleanControl(item, container)
|
control = CreateBooleanControl(item, container)
|
||||||
else if item.type = "radio"
|
else if item.type = "radio"
|
||||||
control = CreateRadioControl(item, container)
|
control = CreateRadioControl(item, container)
|
||||||
@@ -131,8 +133,6 @@ function CreateControl(item as object, container as object, startX as integer, s
|
|||||||
control = CreateStringControl(item, container)
|
control = CreateStringControl(item, container)
|
||||||
else if item.type = "number"
|
else if item.type = "number"
|
||||||
control = CreateNumberComponent(item, container)
|
control = CreateNumberComponent(item, container)
|
||||||
else if item.rokuComponent <> invalid
|
|
||||||
control = CreateRokuComponent(item, container)
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if control = invalid
|
if control = invalid
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class DashManifest
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function fromVideoMetadata(metadata as object, local as boolean) as string
|
function fromVideoMetadata(metadata as object, qualityFilter as object, local as boolean) as string
|
||||||
adaptiveFormats = []
|
adaptiveFormats = []
|
||||||
adaptiveFormats.Append(metadata.adaptiveFormats)
|
adaptiveFormats.Append(metadata.adaptiveFormats)
|
||||||
|
|
||||||
@@ -43,7 +43,10 @@ class DashManifest
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
audioStreams = m.getAudioStreams(adaptiveFormats)
|
audioStreams = m.getAudioStreams(adaptiveFormats)
|
||||||
videoStreams = m.getVideoStreams(adaptiveFormats)
|
videoStreams = m.getVideoStreams(adaptiveFormats, qualityFilter)
|
||||||
|
if videoStreams.Count() = 0
|
||||||
|
videoStreams = m.getVideoStreams(adaptiveFormats, {})
|
||||||
|
end if
|
||||||
|
|
||||||
videoMimeTypes = m.getMimeTypes(videoStreams)
|
videoMimeTypes = m.getMimeTypes(videoStreams)
|
||||||
audioSets = m.getMimeTypeLanguageCombos(audioStreams)
|
audioSets = m.getMimeTypeLanguageCombos(audioStreams)
|
||||||
@@ -296,9 +299,13 @@ class DashManifest
|
|||||||
return audioStreams
|
return audioStreams
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function getVideoStreams(streams as object) as object
|
function getVideoStreams(streams as object, qualityFilter as object) as object
|
||||||
videoStreams = []
|
videoStreams = []
|
||||||
for i = 0 to streams.Count() - 1
|
for i = 0 to streams.Count() - 1
|
||||||
|
if not m.isVideoFormatIncluded(streams[i], qualityFilter)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
stream = streams[i]
|
stream = streams[i]
|
||||||
if stream.type.startsWith("video/")
|
if stream.type.startsWith("video/")
|
||||||
if stream.bitrate = invalid
|
if stream.bitrate = invalid
|
||||||
@@ -332,6 +339,46 @@ class DashManifest
|
|||||||
return videoStreams
|
return videoStreams
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function isVideoFormatIncluded(stream as object, qualityFilter as object) as boolean
|
||||||
|
if qualityFilter.Count() = 0
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
|
||||||
|
qualityLabel = stream.qualityLabel
|
||||||
|
if not StringUtils.IsNullOrEmpty(qualityLabel)
|
||||||
|
pIndex = qualityLabel.InStr("p")
|
||||||
|
if pIndex <> -1
|
||||||
|
qualityLabel = qualityLabel.Mid(0, pIndex)
|
||||||
|
end if
|
||||||
|
if qualityFilter[qualityLabel] = true
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
resolution = stream.resolution
|
||||||
|
if not StringUtils.IsNullOrEmpty(resolution)
|
||||||
|
pIndex = resolution.InStr("p")
|
||||||
|
if pIndex <> -1
|
||||||
|
resolution = resolution.Mid(0, pIndex)
|
||||||
|
end if
|
||||||
|
if qualityFilter[resolution] = true
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
size = stream.size
|
||||||
|
if not StringUtils.IsNullOrEmpty(size)
|
||||||
|
size = size.Split("x")
|
||||||
|
if size.Count() = 2
|
||||||
|
if qualityFilter[size[1]] = true
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
function getMimeTypes(streams as object) as object
|
function getMimeTypes(streams as object) as object
|
||||||
mimeTypes = {}
|
mimeTypes = {}
|
||||||
for i = 0 to streams.Count() - 1
|
for i = 0 to streams.Count() - 1
|
||||||
|
|||||||
@@ -184,15 +184,6 @@ namespace Invidious
|
|||||||
return request.Await()
|
return request.Await()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetVideoStreamUrl(videoId as string, itag = invalid as dynamic) as string
|
|
||||||
instance = m.GetInstance()
|
|
||||||
url = `${instance}/latest_version?id=${videoId}`
|
|
||||||
if itag <> invalid
|
|
||||||
url = `${url}&itag=${itag}`
|
|
||||||
end if
|
|
||||||
return url
|
|
||||||
end function
|
|
||||||
|
|
||||||
function MarkFeedPagination(feedContentNode as object) as object
|
function MarkFeedPagination(feedContentNode as object) as object
|
||||||
feedSources = feedContentNode.feedSources
|
feedSources = feedContentNode.feedSources
|
||||||
feedSourcesIndex = feedContentNode.feedSourcesIndex
|
feedSourcesIndex = feedContentNode.feedSourcesIndex
|
||||||
|
|||||||
@@ -109,10 +109,13 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
|
|||||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
|
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
' v1 -> v2 goes here (if needed)
|
if userPrefs.__version = 1
|
||||||
' if userPrefs.__version = 1
|
if ValidString(userPrefs["playback.preferred_quality"]) = "medium"
|
||||||
' 'do stuff
|
userPrefs["playback.preferred_quality"] = "480p,360p"
|
||||||
' end if
|
end if
|
||||||
|
userPrefs.__version = 2
|
||||||
|
isDirty = true
|
||||||
|
end if
|
||||||
|
|
||||||
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
|
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
|
||||||
return isDirty
|
return isDirty
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
user prefs saved need to be migrated. If the version is less than the
|
user prefs saved need to be migrated. If the version is less than the
|
||||||
current version, a migration is needed.
|
current version, a migration is needed.
|
||||||
-->
|
-->
|
||||||
<field id="__version" type="integer" value="1" />
|
<field id="__version" type="integer" value="2" />
|
||||||
<field id="prefsModel" type="array" />
|
<field id="prefsModel" type="array" />
|
||||||
<field id="preferenceFields" type="assocarray" />
|
<field id="preferenceFields" type="assocarray" />
|
||||||
<function name="GetUserPreferences" />
|
<function name="GetUserPreferences" />
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ function VideoContentTask(input as object) as object
|
|||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, playletServerPort)
|
streamUrls = CreateStreamUrls(metadata, service, preferencesNode, backend, playletServerPort)
|
||||||
contentNode.addFields({
|
contentNode.addFields({
|
||||||
metadata: metadata
|
metadata: metadata
|
||||||
' StreamUrls is taken
|
' StreamUrls is taken
|
||||||
@@ -80,115 +80,125 @@ function VideoContentTask(input as object) as object
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function CreateStreamUrls(metadata as object, service as Invidious.InvidiousService, preferences as object, playletServerPort as integer) as object
|
function CreateStreamUrls(metadata as object, service as Invidious.InvidiousService, preferences as object, backend as string, playletServerPort as integer) as object
|
||||||
instance = service.GetInstance()
|
instance = service.GetInstance()
|
||||||
proxyVideos = preferences["invidious.proxy_videos"]
|
proxyVideos = preferences["invidious.proxy_videos"]
|
||||||
|
preferredQuality = preferences["playback.preferred_quality"]
|
||||||
|
|
||||||
streamUrls = []
|
streamUrls = []
|
||||||
|
|
||||||
if metadata.hlsUrl <> invalid
|
if metadata.hlsUrl <> invalid
|
||||||
AddHlsUrls(streamUrls, metadata, proxyVideos, playletServerPort)
|
metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance)
|
||||||
|
AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
|
||||||
else
|
else
|
||||||
preferredQuality = preferences["playback.preferred_quality"]
|
AddDashUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
|
||||||
|
|
||||||
if preferredQuality = "auto"
|
|
||||||
AddDashUrls(streamUrls, metadata, proxyVideos, playletServerPort)
|
|
||||||
AddStreamUrls(streamUrls, metadata, service, proxyVideos, preferredQuality)
|
|
||||||
else
|
|
||||||
AddStreamUrls(streamUrls, metadata, service, proxyVideos, preferredQuality)
|
|
||||||
AddDashUrls(streamUrls, metadata, proxyVideos, playletServerPort)
|
|
||||||
end if
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
AddInstanceToUrlIfNeeded(streamUrls, instance)
|
|
||||||
|
|
||||||
return streamUrls
|
return streamUrls
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function AddHlsUrls(streamUrls as object, metadata as object, proxyVideos as string, playletServerPort as integer)
|
function AddHlsUrls(streamUrls as object, metadata as object, preferredQuality as string, backend as string, proxyVideos as string, playletServerPort as integer)
|
||||||
hlsUrl = metadata.hlsUrl
|
hlsUrl = metadata.hlsUrl
|
||||||
if hlsUrl.StartsWith("/api/manifest")
|
hlsUrlLocal = invalid
|
||||||
hlsUrl = "https://manifest.googlevideo.com" + hlsUrl
|
hlsUrlFiltered = invalid
|
||||||
|
hlsUrlFilteredLocal = invalid
|
||||||
|
|
||||||
|
supportsProxying = backend <> "playlet"
|
||||||
|
hasQuality = not StringUtils.IsNullOrEmpty(preferredQuality) and preferredQuality <> "auto"
|
||||||
|
|
||||||
|
if supportsProxying
|
||||||
|
hlsUrlLocal = UrlUtils.AppendQueryParams(hlsUrl, { local: "true" })
|
||||||
end if
|
end if
|
||||||
hlsUrlLocal = AddLocalFlag(hlsUrl)
|
|
||||||
|
|
||||||
' Redirect to Playet's local web server, where we will be
|
' Redirect to Playet's local web server, where we will be
|
||||||
' dynamically adding storyboards
|
' dynamically adding storyboards to the HLS manifest, and filter quality
|
||||||
hlsUrl = `http://127.0.0.1:${playletServerPort}/api/hls?url=${hlsUrl.EncodeUriComponent()}`
|
hlsUrl = `http://127.0.0.1:${playletServerPort}/api/hls?url=${hlsUrl.EncodeUriComponent()}`
|
||||||
|
hlsUrlLocal = `http://127.0.0.1:${playletServerPort}/api/hls?url=${hlsUrlLocal.EncodeUriComponent()}`
|
||||||
|
|
||||||
AddUrls(streamUrls, hlsUrl, hlsUrlLocal, proxyVideos)
|
if hasQuality
|
||||||
|
hlsUrlFiltered = UrlUtils.AppendQueryParams(hlsUrl, { quality: preferredQuality })
|
||||||
|
if supportsProxying
|
||||||
|
hlsUrlFilteredLocal = UrlUtils.AppendQueryParams(hlsUrlLocal, { quality: preferredQuality })
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
AddUrls(streamUrls, hlsUrl, hlsUrlLocal, hlsUrlFiltered, hlsUrlFilteredLocal, proxyVideos)
|
||||||
|
if streamUrls.Count() = 0
|
||||||
|
streamUrls.push(hlsUrl)
|
||||||
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function AddDashUrls(streamUrls as object, metadata as object, proxyVideos as string, playletServerPort as integer) as void
|
function AddDashUrls(streamUrls as object, metadata as object, preferredQuality as string, backend as string, proxyVideos as string, playletServerPort as integer) as void
|
||||||
' Redirect to Playet's local web server, where will will be
|
' Redirect to Playet's local web server, where will will be
|
||||||
' dynamically generating the DASH manifest, instead of metadata.dashUrl
|
' dynamically generating the DASH manifest, and filter quality
|
||||||
dashUrl = `http://127.0.0.1:${playletServerPort}/api/dash?v=${metadata.videoId}`
|
dashUrl = `http://127.0.0.1:${playletServerPort}/api/dash?v=${metadata.videoId}`
|
||||||
|
dashUrlLocal = invalid
|
||||||
|
dashUrlFiltered = invalid
|
||||||
|
dashUrlFilteredLocal = invalid
|
||||||
|
|
||||||
dashUrlLocal = AddLocalFlag(dashUrl)
|
supportsProxying = backend <> "playlet"
|
||||||
AddUrls(streamUrls, dashUrl, dashUrlLocal, proxyVideos)
|
hasQuality = not StringUtils.IsNullOrEmpty(preferredQuality) and preferredQuality <> "auto"
|
||||||
end function
|
|
||||||
|
|
||||||
function AddStreamUrls(streamUrls as object, metadata as object, service as Invidious.InvidiousService, proxyVideos as string, preferredQuality as string) as void
|
if supportsProxying
|
||||||
if metadata.formatStreams = invalid or metadata.formatStreams.Count() = 0
|
dashUrlLocal = UrlUtils.AppendQueryParams(dashUrl, { local: "true" })
|
||||||
return
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
itag = invalid
|
if hasQuality
|
||||||
' If we prefer medium quality, we check if we have a 360p or 480p streams
|
dashUrlFiltered = UrlUtils.AppendQueryParams(dashUrl, { quality: preferredQuality })
|
||||||
if preferredQuality = "medium"
|
if supportsProxying
|
||||||
' These are roughly the itags for 360p and 480p
|
dashUrlFilteredLocal = UrlUtils.AppendQueryParams(dashUrlLocal, { quality: preferredQuality })
|
||||||
' Most videos will hit 18, which is 360p
|
end if
|
||||||
mediumItags = {
|
|
||||||
"18": true
|
|
||||||
"43": true
|
|
||||||
"44": true
|
|
||||||
"82": true
|
|
||||||
"83": true
|
|
||||||
"101": true
|
|
||||||
}
|
|
||||||
for each formatStream in metadata.formatStreams
|
|
||||||
if mediumItags[ValidString(formatStream.itag)] = true
|
|
||||||
itag = formatStream.itag
|
|
||||||
exit for
|
|
||||||
end if
|
|
||||||
end for
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
url = service.GetVideoStreamUrl(metadata.videoId, itag)
|
AddUrls(streamUrls, dashUrl, dashUrlLocal, dashUrlFiltered, dashUrlFilteredLocal, proxyVideos)
|
||||||
localUrl = AddLocalFlag(url)
|
if streamUrls.Count() = 0
|
||||||
|
streamUrls.push(dashUrl)
|
||||||
AddUrls(streamUrls, url, localUrl, proxyVideos)
|
|
||||||
end function
|
|
||||||
|
|
||||||
function AddLocalFlag(url as string) as string
|
|
||||||
if url.InStr("?") = -1
|
|
||||||
return url + "?local=true"
|
|
||||||
else
|
|
||||||
return url + "&local=true"
|
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function AddUrls(streamUrls as object, url as string, localUrl as string, proxyVideos as string)
|
function AddUrls(streamUrls as object, url as string, urlLocal as dynamic, urlFiltered as dynamic, urlFilteredLocal as dynamic, proxyVideos as string)
|
||||||
if proxyVideos = "if_needed"
|
if proxyVideos = "if_needed"
|
||||||
|
if urlFiltered <> invalid
|
||||||
|
streamUrls.push(urlFiltered)
|
||||||
|
end if
|
||||||
streamUrls.push(url)
|
streamUrls.push(url)
|
||||||
streamUrls.push(localUrl)
|
if urlFilteredLocal <> invalid
|
||||||
|
streamUrls.push(urlFilteredLocal)
|
||||||
|
end if
|
||||||
|
if urlLocal <> invalid
|
||||||
|
streamUrls.push(urlLocal)
|
||||||
|
end if
|
||||||
else if proxyVideos = "never"
|
else if proxyVideos = "never"
|
||||||
|
if urlFiltered <> invalid
|
||||||
|
streamUrls.push(urlFiltered)
|
||||||
|
end if
|
||||||
streamUrls.push(url)
|
streamUrls.push(url)
|
||||||
else if proxyVideos = "always"
|
else if proxyVideos = "always"
|
||||||
streamUrls.push(localUrl)
|
if urlFilteredLocal <> invalid
|
||||||
|
streamUrls.push(urlFilteredLocal)
|
||||||
|
end if
|
||||||
|
if urlLocal <> invalid
|
||||||
|
streamUrls.push(urlLocal)
|
||||||
|
end if
|
||||||
else
|
else
|
||||||
|
if urlFiltered <> invalid
|
||||||
|
streamUrls.push(urlFiltered)
|
||||||
|
end if
|
||||||
streamUrls.push(url)
|
streamUrls.push(url)
|
||||||
streamUrls.push(localUrl)
|
if urlFilteredLocal <> invalid
|
||||||
|
streamUrls.push(urlFilteredLocal)
|
||||||
|
end if
|
||||||
|
if urlLocal <> invalid
|
||||||
|
streamUrls.push(urlLocal)
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function AddInstanceToUrlIfNeeded(streamUrls as object, instance as string)
|
function AddInstanceToUrlIfNeeded(url as object, instance as string) as string
|
||||||
for i = 0 to streamUrls.Count() - 1
|
if url.StartsWith("/")
|
||||||
url = streamUrls[i]
|
return instance + url
|
||||||
if url.StartsWith("/")
|
end if
|
||||||
streamUrls[i] = instance + url
|
return url
|
||||||
end if
|
|
||||||
end for
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function SetCaptions(metadata as object, service as object, contentNode as object) as void
|
function SetCaptions(metadata as object, service as object, contentNode as object) as void
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace Http
|
|||||||
|
|
||||||
v = request.query.v
|
v = request.query.v
|
||||||
local = request.query.local
|
local = request.query.local
|
||||||
|
quality = request.query.quality
|
||||||
|
|
||||||
if StringUtils.IsNullOrEmpty(v)
|
if StringUtils.IsNullOrEmpty(v)
|
||||||
response.Default(400, "Missing video id")
|
response.Default(400, "Missing video id")
|
||||||
@@ -37,7 +38,8 @@ namespace Http
|
|||||||
metadata = metadataRequest.Json()
|
metadata = metadataRequest.Json()
|
||||||
m.dashManifest.invidiousInstance = m.invidiousService.GetInstance()
|
m.dashManifest.invidiousInstance = m.invidiousService.GetInstance()
|
||||||
|
|
||||||
xmlContent = m.dashManifest.fromVideoMetadata(metadata, ValidString(local) = "true")
|
qualityFilter = m.CreateQualityFilter(quality)
|
||||||
|
xmlContent = m.dashManifest.fromVideoMetadata(metadata, qualityFilter, ValidString(local) = "true")
|
||||||
|
|
||||||
response.http_code = 200
|
response.http_code = 200
|
||||||
response.SetBodyDataString(xmlContent)
|
response.SetBodyDataString(xmlContent)
|
||||||
@@ -46,6 +48,27 @@ namespace Http
|
|||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function CreateQualityFilter(quality as dynamic) as object
|
||||||
|
qualityFilter = {}
|
||||||
|
if not IsString(quality)
|
||||||
|
return qualityFilter
|
||||||
|
end if
|
||||||
|
|
||||||
|
includeList = quality.split(",")
|
||||||
|
for each quality in includeList
|
||||||
|
if quality = "auto"
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
pIndex = quality.InStr("p")
|
||||||
|
if pIndex <> -1
|
||||||
|
quality = quality.Mid(0, pIndex)
|
||||||
|
end if
|
||||||
|
qualityFilter[quality] = true
|
||||||
|
end for
|
||||||
|
|
||||||
|
return qualityFilter
|
||||||
|
end function
|
||||||
|
|
||||||
end class
|
end class
|
||||||
|
|
||||||
end namespace
|
end namespace
|
||||||
@@ -15,6 +15,7 @@ namespace Http
|
|||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
url = request.query.url
|
url = request.query.url
|
||||||
|
quality = request.query.quality
|
||||||
|
|
||||||
if StringUtils.IsNullOrEmpty(url)
|
if StringUtils.IsNullOrEmpty(url)
|
||||||
response.Default(400, "Missing url")
|
response.Default(400, "Missing url")
|
||||||
@@ -33,6 +34,10 @@ namespace Http
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
hlsManifest = hlsResponse.Text()
|
hlsManifest = hlsResponse.Text()
|
||||||
|
|
||||||
|
qualityFilter = m.CreateQualityFilter(quality)
|
||||||
|
hlsManifest = m.FilterHlsManifest(hlsManifest, qualityFilter)
|
||||||
|
|
||||||
hlsManifest = m.AppendStoryboardPlaylists(hlsManifest)
|
hlsManifest = m.AppendStoryboardPlaylists(hlsManifest)
|
||||||
|
|
||||||
response.http_code = hlsResponse.StatusCode()
|
response.http_code = hlsResponse.StatusCode()
|
||||||
@@ -87,7 +92,7 @@ namespace Http
|
|||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function AppendStoryboardPlaylists(hlsManifest as dynamic) as string
|
function AppendStoryboardPlaylists(hlsManifest as dynamic) as dynamic
|
||||||
if StringUtils.IsNullOrEmpty(hlsManifest) or not hlsManifest.StartsWith("#EXTM3U")
|
if StringUtils.IsNullOrEmpty(hlsManifest) or not hlsManifest.StartsWith("#EXTM3U")
|
||||||
return hlsManifest
|
return hlsManifest
|
||||||
end if
|
end if
|
||||||
@@ -122,6 +127,50 @@ namespace Http
|
|||||||
return hlsManifest
|
return hlsManifest
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function FilterHlsManifest(hlsManifest as dynamic, qualityFilter as object) as dynamic
|
||||||
|
if StringUtils.IsNullOrEmpty(hlsManifest) or qualityFilter.Count() = 0
|
||||||
|
return hlsManifest
|
||||||
|
end if
|
||||||
|
|
||||||
|
lines = hlsManifest.split(`\n`)
|
||||||
|
newLines = []
|
||||||
|
includedQualitiesCount = 0
|
||||||
|
|
||||||
|
for i = 0 to lines.Count() - 1
|
||||||
|
line = lines[i]
|
||||||
|
if not line.StartsWith("#EXT-X-STREAM-INF:")
|
||||||
|
newLines.push(line)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
|
resolution = StringUtils.GetBetween(line, "RESOLUTION=", ",")
|
||||||
|
if StringUtils.IsNullOrEmpty(resolution)
|
||||||
|
newLines.push(line)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
|
resolutionParts = resolution.split("x")
|
||||||
|
if resolutionParts.Count() <> 2
|
||||||
|
newLines.push(line)
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
|
if qualityFilter[resolutionParts[1]] = true
|
||||||
|
newLines.push(line)
|
||||||
|
includedQualitiesCount += 1
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
|
||||||
|
' skip the next line
|
||||||
|
i += 1
|
||||||
|
end for
|
||||||
|
|
||||||
|
if includedQualitiesCount = 0
|
||||||
|
return hlsManifest
|
||||||
|
end if
|
||||||
|
return newLines.join(`\n`)
|
||||||
|
end function
|
||||||
|
|
||||||
function GenerateStoryboardManifest(storyboard as object, lengthSeconds as float) as string
|
function GenerateStoryboardManifest(storyboard as object, lengthSeconds as float) as string
|
||||||
tileCount = storyboard.storyboardWidth * storyboard.storyboardHeight
|
tileCount = storyboard.storyboardWidth * storyboard.storyboardHeight
|
||||||
intervalSeconds = Cdbl(storyboard.interval) / 1000.0
|
intervalSeconds = Cdbl(storyboard.interval) / 1000.0
|
||||||
@@ -190,6 +239,27 @@ ${storyboard.templateUrl.replace("$M", `${i}`)}
|
|||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function CreateQualityFilter(quality as dynamic) as object
|
||||||
|
qualityFilter = {}
|
||||||
|
if not IsString(quality)
|
||||||
|
return qualityFilter
|
||||||
|
end if
|
||||||
|
|
||||||
|
includeList = quality.split(",")
|
||||||
|
for each quality in includeList
|
||||||
|
if quality = "auto"
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
pIndex = quality.InStr("p")
|
||||||
|
if pIndex <> -1
|
||||||
|
quality = quality.Mid(0, pIndex)
|
||||||
|
end if
|
||||||
|
qualityFilter[quality] = true
|
||||||
|
end for
|
||||||
|
|
||||||
|
return qualityFilter
|
||||||
|
end function
|
||||||
end class
|
end class
|
||||||
|
|
||||||
end namespace
|
end namespace
|
||||||
@@ -15,22 +15,17 @@
|
|||||||
displayText: "Preferred quality",
|
displayText: "Preferred quality",
|
||||||
key: "playback.preferred_quality",
|
key: "playback.preferred_quality",
|
||||||
description: "Preferred video quality",
|
description: "Preferred video quality",
|
||||||
type: "radio",
|
type: "string",
|
||||||
defaultValue: "auto",
|
defaultValue: "auto",
|
||||||
options: [
|
visibility: "tv",
|
||||||
{
|
rokuComponent: "EditQualityControl",
|
||||||
displayText: "Auto (DASH)",
|
},
|
||||||
value: "auto",
|
{
|
||||||
},
|
displayText: "Preferred quality",
|
||||||
{
|
key: "playback.preferred_quality",
|
||||||
displayText: "720p",
|
description: "Preferred video quality",
|
||||||
value: "720p",
|
visibility: "web",
|
||||||
},
|
svelteComponent: "EditQualityControl",
|
||||||
{
|
|
||||||
displayText: "Medium",
|
|
||||||
value: "medium",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayText: "Backend",
|
displayText: "Backend",
|
||||||
|
|||||||
@@ -137,16 +137,8 @@
|
|||||||
<translation>Nach dem Ende eines Videos wird automatisch ein neues Video wiedergegeben</translation>
|
<translation>Nach dem Ende eines Videos wird automatisch ein neues Video wiedergegeben</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Auto (DASH)</source>
|
<source>Auto</source>
|
||||||
<translation>Automatisch (DASH)</translation>
|
<translation>Automatisch</translation>
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Medium</source>
|
|
||||||
<translation>Mittel</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>720p</source>
|
|
||||||
<translation>720p</translation>
|
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Proxy videos</source>
|
<source>Proxy videos</source>
|
||||||
|
|||||||
@@ -737,16 +737,8 @@
|
|||||||
<translation>Preferred video quality</translation>
|
<translation>Preferred video quality</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Auto (DASH)</source>
|
<source>Auto</source>
|
||||||
<translation>Auto (DASH)</translation>
|
<translation>Auto</translation>
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>720p</source>
|
|
||||||
<translation>720p</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Medium</source>
|
|
||||||
<translation>Medium</translation>
|
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Invidious preferences</source>
|
<source>Invidious preferences</source>
|
||||||
|
|||||||
@@ -912,10 +912,6 @@
|
|||||||
<source>Preferred video quality</source>
|
<source>Preferred video quality</source>
|
||||||
<translation>Calidad de vídeo preferida</translation>
|
<translation>Calidad de vídeo preferida</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>720p</source>
|
|
||||||
<translation>720p</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Instance</source>
|
<source>Instance</source>
|
||||||
<translation>Instancia</translation>
|
<translation>Instancia</translation>
|
||||||
@@ -1265,12 +1261,8 @@
|
|||||||
<translation>Características</translation>
|
<translation>Características</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Auto (DASH)</source>
|
<source>Auto</source>
|
||||||
<translation>Automático (DASH)</translation>
|
<translation>Automático</translation>
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Medium</source>
|
|
||||||
<translation>Medio</translation>
|
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Filler Tangent/Jokes</source>
|
<source>Filler Tangent/Jokes</source>
|
||||||
|
|||||||
@@ -808,10 +808,6 @@
|
|||||||
<source>Wired connection</source>
|
<source>Wired connection</source>
|
||||||
<translation>Conexíon alámbrica</translation>
|
<translation>Conexíon alámbrica</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>720p</source>
|
|
||||||
<translation>720p</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Channel</source>
|
<source>Channel</source>
|
||||||
<translation>Canal</translation>
|
<translation>Canal</translation>
|
||||||
@@ -952,10 +948,6 @@
|
|||||||
<source>Playback</source>
|
<source>Playback</source>
|
||||||
<translation>Reproducción</translation>
|
<translation>Reproducción</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Medium</source>
|
|
||||||
<translation>Media</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Request cancelled.</source>
|
<source>Request cancelled.</source>
|
||||||
<translation>Solicitud cancelada.</translation>
|
<translation>Solicitud cancelada.</translation>
|
||||||
@@ -1085,8 +1077,8 @@
|
|||||||
<translation>PRÓXIMAMENTE</translation>
|
<translation>PRÓXIMAMENTE</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Auto (DASH)</source>
|
<source>Auto</source>
|
||||||
<translation>Automática (DASH)</translation>
|
<translation>Automática</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>SponsorBlock</source>
|
<source>SponsorBlock</source>
|
||||||
|
|||||||
@@ -721,16 +721,8 @@
|
|||||||
<translation>Qualité vidéo préférée</translation>
|
<translation>Qualité vidéo préférée</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Auto (DASH)</source>
|
<source>Auto</source>
|
||||||
<translation>Auto (DASH)</translation>
|
<translation>Auto</translation>
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>720p</source>
|
|
||||||
<translation>720p</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Medium</source>
|
|
||||||
<translation>Moyenne</translation>
|
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Invidious preferences</source>
|
<source>Invidious preferences</source>
|
||||||
|
|||||||
@@ -457,16 +457,8 @@
|
|||||||
<translation>Qualidade de vídeo preferida</translation>
|
<translation>Qualidade de vídeo preferida</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Auto (DASH)</source>
|
<source>Auto</source>
|
||||||
<translation>Auto (DASH)</translation>
|
<translation>Auto</translation>
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>720p</source>
|
|
||||||
<translation>720p</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Medium</source>
|
|
||||||
<translation>Médio</translation>
|
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Instance</source>
|
<source>Instance</source>
|
||||||
|
|||||||
@@ -240,9 +240,7 @@ namespace Locale
|
|||||||
AutoplayDescription = "When you finish a video, another plays automatically"
|
AutoplayDescription = "When you finish a video, another plays automatically"
|
||||||
PreferredQuality = "Preferred quality"
|
PreferredQuality = "Preferred quality"
|
||||||
PreferredQualityDescription = "Preferred video quality"
|
PreferredQualityDescription = "Preferred video quality"
|
||||||
AutoDASH = "Auto (DASH)"
|
AutoQuality = "Auto"
|
||||||
Seven20p = "720p"
|
|
||||||
Medium = "Medium"
|
|
||||||
|
|
||||||
' "Invidious" is used as node id, so we can't use it before refactoring node ids.
|
' "Invidious" is used as node id, so we can't use it before refactoring node ids.
|
||||||
' Either way, Invidious doesn't translate, so it's fine to skip it here
|
' Either way, Invidious doesn't translate, so it's fine to skip it here
|
||||||
|
|||||||
@@ -24,5 +24,18 @@ namespace StringUtils
|
|||||||
buffer.FromBase64String(input)
|
buffer.FromBase64String(input)
|
||||||
return buffer.ToAsciiString()
|
return buffer.ToAsciiString()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function GetBetween(input as string, startStr as string, endStr as string) as string
|
||||||
|
startIndex = input.InStr(startStr)
|
||||||
|
if startIndex = -1
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
startIndex = startIndex + startStr.len()
|
||||||
|
endIndex = input.InStr(startIndex, endStr)
|
||||||
|
if endIndex = -1
|
||||||
|
return ""
|
||||||
|
end if
|
||||||
|
return input.Mid(startIndex, endIndex - startIndex)
|
||||||
|
end function
|
||||||
end namespace
|
end namespace
|
||||||
|
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { PlayletApi } from "lib/Api/PlayletApi";
|
||||||
|
import { tr, userPreferencesStore } from "lib/Stores";
|
||||||
|
|
||||||
|
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
|
||||||
|
const qualityLabels = {
|
||||||
|
auto: "Auto",
|
||||||
|
"1080p": "1080p",
|
||||||
|
"720p": "720p",
|
||||||
|
"480p": "480p",
|
||||||
|
"360p": "360p",
|
||||||
|
"240p": "240p",
|
||||||
|
"144p": "144p",
|
||||||
|
};
|
||||||
|
|
||||||
|
export let displayText: string = "";
|
||||||
|
export let key: string = "";
|
||||||
|
export let description: string = "";
|
||||||
|
export let level: number = 0;
|
||||||
|
|
||||||
|
let valueCheckedStates: any = {};
|
||||||
|
let originalValue;
|
||||||
|
let displayValue;
|
||||||
|
|
||||||
|
userPreferencesStore.subscribe((userPreferences) => {
|
||||||
|
originalValue = userPreferences[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (!originalValue) {
|
||||||
|
valueCheckedStates = {};
|
||||||
|
displayValue = "";
|
||||||
|
} else {
|
||||||
|
valueCheckedStates = Object.keys(qualityLabels).reduce((acc, cur) => {
|
||||||
|
acc[cur] = originalValue.includes(cur);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
displayValue = originalValue
|
||||||
|
.split(",")
|
||||||
|
.map((item) => $tr(qualityLabels[item] || item))
|
||||||
|
.join(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let modal;
|
||||||
|
|
||||||
|
async function openQualitySelector() {
|
||||||
|
valueCheckedStates = Object.keys(qualityLabels).reduce((acc, cur) => {
|
||||||
|
acc[cur] = originalValue.includes(cur);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
modal.showModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
if (key !== "" && valueCheckedStates) {
|
||||||
|
const stringValue = Object.keys(valueCheckedStates)
|
||||||
|
.filter((key) => valueCheckedStates[key])
|
||||||
|
.join(",");
|
||||||
|
await PlayletApi.saveUserPreference(key, stringValue);
|
||||||
|
|
||||||
|
const refreshUserPrefrences = PlayletApi.getUserPreferences();
|
||||||
|
refreshUserPrefrences.then((value) => {
|
||||||
|
userPreferencesStore.set(value);
|
||||||
|
});
|
||||||
|
|
||||||
|
await userPreferencesStore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function close() {
|
||||||
|
modal.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClose() {
|
||||||
|
// Reset value to original value to avoid weird animation on show
|
||||||
|
valueCheckedStates = Object.keys(qualityLabels).reduce((acc, cur) => {
|
||||||
|
acc[cur] = originalValue.includes(cur);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onChange(e: Event, quality: string) {
|
||||||
|
const target = e.target as HTMLInputElement;
|
||||||
|
valueCheckedStates[quality] = target.checked;
|
||||||
|
|
||||||
|
const autoChanged = quality === "auto";
|
||||||
|
const hasAuto = valueCheckedStates.auto;
|
||||||
|
|
||||||
|
if (autoChanged) {
|
||||||
|
if (hasAuto) {
|
||||||
|
Object.keys(valueCheckedStates).forEach((key) => {
|
||||||
|
valueCheckedStates[key] = key === "auto";
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
valueCheckedStates = Object.keys(qualityLabels).reduce((acc, cur) => {
|
||||||
|
acc[cur] = cur !== "auto";
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedCount = Object.keys(valueCheckedStates).filter(
|
||||||
|
(key) => valueCheckedStates[key]
|
||||||
|
).length;
|
||||||
|
if (checkedCount === 0) {
|
||||||
|
valueCheckedStates.auto = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkedCount > 1 && valueCheckedStates.auto) {
|
||||||
|
valueCheckedStates.auto = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="m-5">
|
||||||
|
<div class={textSizes[level]}>{$tr(displayText)}</div>
|
||||||
|
<div class="text-xs text-gray-500">{@html $tr(description)}</div>
|
||||||
|
<button class="btn m-1" on:click={openQualitySelector}>{displayValue}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dialog bind:this={modal} class="modal" on:close={onClose}>
|
||||||
|
<div class="modal-box bg-base-100">
|
||||||
|
<table class="w-full">
|
||||||
|
{#each Object.keys(qualityLabels) as quality}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label class="label p-0 cursor-pointer">
|
||||||
|
<div class="label-text text-lg">
|
||||||
|
{$tr(qualityLabels[quality])}
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={valueCheckedStates[quality]}
|
||||||
|
on:change={(e) => onChange(e, quality)}
|
||||||
|
class="toggle toggle-primary"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</table>
|
||||||
|
<form method="dialog" class="flex justify-center space-x-2">
|
||||||
|
<button class="btn btn-primary" on:click={save}>{$tr("Save")}</button>
|
||||||
|
<button class="btn btn-primary">{$tr("Close")}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<form method="dialog" class="modal-backdrop">
|
||||||
|
<button>{$tr("Close")}</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
@@ -6,8 +6,9 @@
|
|||||||
import RadioControl from "lib/Screens/Settings/SettingControls/RadioControl.svelte";
|
import RadioControl from "lib/Screens/Settings/SettingControls/RadioControl.svelte";
|
||||||
import StringControl from "lib/Screens/Settings/SettingControls/StringControl.svelte";
|
import StringControl from "lib/Screens/Settings/SettingControls/StringControl.svelte";
|
||||||
import NumberControl from "./SettingControls/NumberControl.svelte";
|
import NumberControl from "./SettingControls/NumberControl.svelte";
|
||||||
import { tr } from "lib/Stores";
|
|
||||||
import ClearCacheControl from "./SettingControls/ClearCacheControl.svelte";
|
import ClearCacheControl from "./SettingControls/ClearCacheControl.svelte";
|
||||||
|
import EditQualityControl from "./SettingControls/EditQualityControl.svelte";
|
||||||
|
import { tr } from "lib/Stores";
|
||||||
|
|
||||||
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
|
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
ClearCacheControl,
|
ClearCacheControl,
|
||||||
EditHomeScreenControl,
|
EditHomeScreenControl,
|
||||||
PlayletLibVersionControl,
|
PlayletLibVersionControl,
|
||||||
|
EditQualityControl,
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user