Repository: metatube-community/metatube-sdk-go

Issue:
[Feature] add env var to control if adding modelmediaasian or madouqu to provider list
### Description

modelmediaasian and madouqu are disable by default. We want to add a env var to add them so user doesn't need to rebuild the server.

### Is this feature related to a specific bug?

_No response_

### Do you have a specific solution in mind?

_No response_

Hints from issue comments:
@xjasonlyu: Preferable solutions:

1. Register these providers by default in the engine: https://github.com/metatube-community/metatube-sdk-go/blob/main/engine/register.go
2. Set their default priorities to 0.
3. Users can enable these providers by setting e.g. `MT_MOVIE_PROVIDER_XXX=1000`.@charleshuang3: > Preferable solutions:
> 
> 1. Register these providers by default in the engine: https://github.com/metatube-community/metatube-sdk-go/blob/main/engine/register.go
> 2. Set their default priorities to 0.
> 3. Users can enable these providers by setting e.g. `MT_MOVIE_PROVIDER_XXX=1000`.

I just test this idea, it just put them on lower priorities instead of disable. Is it want you expected?@xjasonlyu: ugh, yeah I think there is a potential bug.. would also need to configure something elsewhere like https://github.com/metatube-community/metatube-sdk-go/blob/754f63754c3349fb43a3e217973ef216e877bf11/engine/init.go#L66-L72

Solution patch:
diff --git a/engine/init.go b/engine/init.go
index aa0c0dc..8182cfc 100644
--- a/engine/init.go
+++ b/engine/init.go
@@ -14,7 +14,6 @@ func (e *Engine) init() *Engine {
 	e.initFetcher()
 	e.initActorProviders()
 	e.initMovieProviders()
-	e.initAllProviderPriorities()
 	return e
 }
 
@@ -26,43 +25,35 @@ func (e *Engine) initFetcher() {
 	e.fetcher = fetch.Default(&fetch.Config{Timeout: e.timeout})
 }
 
-func (e *Engine) initAllProviderPriorities() {
+// initActorProviders initializes actor providers.
+func (e *Engine) initActorProviders() {
 	defer func() {
 		// remove references.
 		e.actorPriorities = nil
-		e.moviePriorities = nil
 	}()
-	for name, prio := range e.actorPriorities {
-		if prio == 0 {
-			delete(e.actorProviders, name)
-			continue
-		}
-		if provider, ok := e.actorProviders[name]; ok {
-			provider.SetPriority(prio)
-		}
-	}
-	for name, prio := range e.moviePriorities {
-		if prio == 0 {
-			delete(e.movieProviders, name)
-			continue
-		}
-		if provider, ok := e.movieProviders[name]; ok {
-			provider.SetPriority(prio)
-		}
-	}
-}
 
-// initActorProviders initializes actor providers.
-func (e *Engine) initActorProviders() {
 	e.actorProviders = make(map[string]mt.ActorProvider)
 	e.actorHostProviders = make(map[string][]mt.ActorProvider)
 	for name, factory := range mt.RangeActorFactory {
+		name = strings.ToUpper(name)
+
 		provider := factory()
+		if p, ok := e.actorPriorities[name]; ok {
+			e.logger.Printf("Set actor provider with overridden priority: %s=%.2f", provider.Name(), p)
+			provider.SetPriority(p)
+		}
+		if provider.Priority() <= 0 {
+			e.logger.Printf("Disable actor provider: %s", provider.Name())
+			continue
+		}
+
+		// Set request timeout.
 		if s, ok := provider.(mt.RequestTimeoutSetter); ok {
 			s.SetRequestTimeout(e.timeout)
 		}
+
 		// Add actor provider by name.
-		e.actorProviders[strings.ToUpper(name)] = provider
+		e.actorProviders[name] = provider
 		// Add actor provider by host.
 		host := provider.URL().Hostname()
 		e.actorHostProviders[host] = append(e.actorHostProviders[host], provider)
@@ -71,15 +62,33 @@ func (e *Engine) initActorProviders() {
 
 // initMovieProviders initializes movie providers.
 func (e *Engine) initMovieProviders() {
+	defer func() {
+		// remove references.
+		e.moviePriorities = nil
+	}()
+
 	e.movieProviders = make(map[string]mt.MovieProvider)
 	e.movieHostProviders = make(map[string][]mt.MovieProvider)
 	for name, factory := range mt.RangeMovieFactory {
+		name = strings.ToUpper(name)
+
 		provider := factory()
+		if p, ok := e.moviePriorities[name]; ok {
+			e.logger.Printf("Set movie provider with overridden priority: %s=%.2f", provider.Name(), p)
+			provider.SetPriority(p)
+		}
+		if provider.Priority() <= 0 {
+			e.logger.Printf("Disable movie provider: %s", provider.Name())
+			continue
+		}
+
+		// Set request timeout.
 		if s, ok := provider.(mt.RequestTimeoutSetter); ok {
 			s.SetRequestTimeout(e.timeout)
 		}
+
 		// Add movie provider by name.
-		e.movieProviders[strings.ToUpper(name)] = provider
+		e.movieProviders[name] = provider
 		// Add movie provider by host.
 		host := provider.URL().Hostname()
 		e.movieHostProviders[host] = append(e.movieHostProviders[host], provider)
diff --git a/engine/register.go b/engine/register.go
index 708e16d..a09287e 100644
--- a/engine/register.go
+++ b/engine/register.go
@@ -28,7 +28,9 @@ import (
 	_ "github.com/metatube-community/metatube-sdk-go/provider/javbus"
 	_ "github.com/metatube-community/metatube-sdk-go/provider/javfree"
 	_ "github.com/metatube-community/metatube-sdk-go/provider/kin8tengoku"
+	_ "github.com/metatube-community/metatube-sdk-go/provider/madouqu"
 	_ "github.com/metatube-community/metatube-sdk-go/provider/mgstage"
+	_ "github.com/metatube-community/metatube-sdk-go/provider/modelmediaasia"
 	_ "github.com/metatube-community/metatube-sdk-go/provider/muramura"
 	_ "github.com/metatube-community/metatube-sdk-go/provider/mywife"
 	_ "github.com/metatube-community/metatube-sdk-go/provider/pacopacomama"
diff --git a/provider/madouqu/madouqu.go b/provider/madouqu/madouqu.go
index eed18d3..860ac91 100644
--- a/provider/madouqu/madouqu.go
+++ b/provider/madouqu/madouqu.go
@@ -25,7 +25,7 @@ var (
 
 const (
 	Name     = "MadouQu"
-	Priority = 1000 - 3
+	Priority = 0 // Disabled by default, use `export MT_MOVIE_PROVIDER_PRIORITY_MADOUQU=1000` to enable.
 )
 
 const (
diff --git a/provider/modelmediaasia/modelmediaasia.go b/provider/modelmediaasia/modelmediaasia.go
index 9d49bc4..7ab6923 100644
--- a/provider/modelmediaasia/modelmediaasia.go
+++ b/provider/modelmediaasia/modelmediaasia.go
@@ -24,8 +24,8 @@ var (
 )
 
 const (
-	Name     = "MODEL-MEDIA-ASIA"
-	Priority = 0 // Disabled by default, use `export MT_MOVIE_PROVIDER_PRIORITY_MODEL_MEDIA_ASIA=1000` to enable.
+	Name     = "ModelMediaAsia"
+	Priority = 0 // Disabled by default, use `export MT_MOVIE_PROVIDER_PRIORITY_MODELMEDIAASIA=1000` to enable.
 )
 
 const (
@@ -108,7 +108,7 @@ func (mma *ModelMediaAsia) GetMovieInfoByURL(rawURL string) (info *model.MovieIn
 	info = &model.MovieInfo{
 		Provider:      mma.Name(),
 		Homepage:      fmt.Sprintf(movieURL, id),
-		Maker:         "Model Media",
+		Maker:         "麻豆傳媒映畫",
 		Actors:        []string{},
 		PreviewImages: []string{},
 		Genres:        []string{},



Test patch:
diff --git a/provider/modelmediaasia/modelmediaaisa_test.go b/provider/modelmediaasia/modelmediaasia_test.go
similarity index 100%
rename from provider/modelmediaasia/modelmediaaisa_test.go
rename to provider/modelmediaasia/modelmediaasia_test.go