From 691506ccc5f0f953aad73c629fad4bad89b97de8 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Thu, 4 Aug 2022 15:49:14 +0200 Subject: [PATCH] removed default features for lang and sub --- feature.go | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/feature.go b/feature.go index 3125e27..1950b0a 100644 --- a/feature.go +++ b/feature.go @@ -28,22 +28,6 @@ var ( } ) -var ( - featureLangOther = Feature[string]{ - name: "lang", - value: "_", - } - featureSubOther = Feature[string]{ - name: "sub", - value: "_", - } -) - -func PrintAllFeatures() { - fmt.Printf("string features: %#v\n", stringFeatures) - fmt.Printf("bool features: %#v\n", boolFeatures) -} - var ( // string features are user-defined. 'primary key' is name and value stringFeatures = []*Feature[string]{} @@ -52,6 +36,11 @@ var ( boolFeatures = []*Feature[bool]{Feature1080p, Feature720p, FeatureTrusted} ) +func PrintAllFeatures() { + fmt.Printf("string features: %#v\n", stringFeatures) + fmt.Printf("bool features: %#v\n", boolFeatures) +} + func makeStringFeature(name, value string, priority int, essential bool) *Feature[string] { for _, feature := range stringFeatures { if feature.name == name && feature.value == value { @@ -79,9 +68,9 @@ func GetStringFeature(name, value string) *Feature[string] { // lang and sub features have their special '_' value if name == "lang" { - return makeStringFeature(name, value, featureLangOther.priority, featureLangOther.essential) + return makeStringFeature(name, value, 0, false) } else if name == "sub" { - return makeStringFeature(name, value, featureSubOther.priority, featureSubOther.essential) + return makeStringFeature(name, value, 0, false) } panic("TODO") @@ -105,6 +94,14 @@ func ParseEssentialFeatures(essentialFeatureString string) { } } +func ParsePrioritizedFeatures(prioritizedFeatureString string) { + featureSpecs := strings.Split(prioritizedFeatureString, ",") + + for index, featureSpec := range featureSpecs { + handleFeatureSpec(featureSpec, len(featureSpec)-index, false) + } +} + func handleFeatureSpec(featureSpec string, priority int, essential bool) { data := strings.Split(featureSpec, ":") name := data[0]