iawia002/lux · error

invalid url for yinyuetai

Error message

invalid url for yinyuetai

What it means

The YinYueTai extractor only accepts three URL shapes: v.yinyuetai.com/video/<id>, v.yinyuetai.com/video/h5/<id>, and m2.yinyuetai.com/video.html?id=<id>. If none of the three regexes matches, the video id cannot be extracted and this error is returned before any network call is made.

Solutions

  1. Rewrite the URL to the canonical form https://v.yinyuetai.com/video/<id> before extracting
  2. Confirm the URL opens a video page in a browser
  3. If the domain layout changed permanently, add the new pattern to the MatchOneOf call in extractors/yinyuetai/yinyuetai.go
  4. Validate the URL against the three patterns on the caller side first

Example fix

// before
_, err := yinyuetai.Extract("https://www.yinyuetai.com/video/2515284", opts) // wrong host -> error

// after
_, err := yinyuetai.Extract("https://v.yinyuetai.com/video/2515284", opts) // matches first pattern
Defensive patterns

Strategy: validation

Validate before calling

var yinyuetaiRe = regexp.MustCompile(`^https?://(v\.yinyuetai\.com/video/(h5/)?\d+(\?vid=\d+)?$|https?://m2\.yinyuetai\.com/video\.html\?id=\d+)`)

func isYinyuetaiVideoURL(raw string) bool {
    return yinyuetaiRe.MatchString(raw)
}

Try / catch

if !isYinyuetaiVideoURL(url) {
    // rewrite to canonical https://v.yinyuetai.com/video/<id> or reject
}
_, err := yinyuetai.Extract(url, opts)

Prevention

When it happens

Trigger: Passing a www.yinyuetai.com host, a fan/stage page, a URL with the id in an unexpected query param, or any post-rebrand domain layout that no longer matches the three patterns.

Common situations: YinYueTai rebranded/reorganized its site so canonical video permalinks changed; users paste search-result or playlist URLs; trailing fragments or encoded characters break the match.

Related errors


AI-assisted analysis of iawia002/lux@dd00f6d258 (2026-08-15). Data as JSON: /api/errors/bc5c5be11ec1dacb. Report an issue: GitHub.

Appendix: source

Thrown at extractors/yinyuetai/yinyuetai.go:44

}

type extractor struct{}

// New returns a yinyuetai extractor.
func New() extractors.Extractor {
	return &extractor{}
}

// Extract is the main function to extract the data.
func (e *extractor) Extract(url string, option extractors.Options) ([]*extractors.Data, error) {
	vid := utils.MatchOneOf(
		url,
		`https?://v.yinyuetai.com/video/(\d+)(?:\?vid=\d+)?`,
		`https?://v.yinyuetai.com/video/h5/(\d+)(?:\?vid=\d+)?`,
		`https?://m2.yinyuetai.com/video.html\?id=(\d+)`,
	)
	if vid == nil || len(vid) < 2 {
		return nil, errors.New("invalid url for yinyuetai")
	}
	params := fmt.Sprintf("videoId=%s", vid[1])
	// generate api url
	apiURL := genAPI(actionGetMvInfo, params)
	var err error
	html, err := request.Get(apiURL, url, nil)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	// parse yinyuetai data
	data := yinyuetaiMvData{}
	if err = json.Unmarshal([]byte(html), &data); err != nil {
		return nil, errors.WithStack(extractors.ErrURLParseFailed)
	}
	// handle api error
	if data.Error {
		return nil, errors.New(data.Message)
	}

View on GitHub (pinned to dd00f6d258)