removed default features for lang and sub
This commit is contained in:
parent
2b0d13cadf
commit
691506ccc5
33
feature.go
33
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]
|
||||
|
Loading…
Reference in New Issue
Block a user