iawia002/lux · error

获取视频信息失败。

Error message

获取视频信息失败。

What it means

The miaopai extractor calls the aj_media/info.json endpoint with a random _cb callback and expects the JSONP wrapper <random>(...);. This error means the response did not match that wrapper — the API answered with an error body, empty output, or a changed format. The HTTP fetch itself succeeded.

Source

Thrown at extractors/miaopai/miaopai.go:71

	if ids == nil || len(ids) < 2 {
		return nil, errors.WithStack(extractors.ErrURLParseFailed)
	}
	id := ids[1]

	randomString := getRandomString(10)

	var data miaopaiData
	jsonString, err := request.Get(
		fmt.Sprintf("https://n.miaopai.com/api/aj_media/info.json?smid=%s&appid=530&_cb=_jsonp%s", id, randomString),
		url, nil,
	)
	if err != nil {
		return nil, errors.WithStack(err)
	}

	match := utils.MatchOneOf(jsonString, randomString+`\((.*)\);$`)
	if match == nil || len(match) < 2 {
		return nil, errors.New("获取视频信息失败。")
	}

	err = json.Unmarshal([]byte(match[1]), &data)
	if err != nil {
		return nil, errors.WithStack(err)
	}

	realURL := data.Data.MetaData[0].URLs.M
	size, err := request.Size(realURL, url)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	urlData := &extractors.Part{
		URL:  realURL,
		Size: size,
		Ext:  "mp4",
	}
	streams := map[string]*extractors.Stream{

View on GitHub (pinned to dd00f6d258)

Solutions

  1. Open the API URL (with the _cb parameter) in a browser and inspect the raw response for your smid.
  2. Confirm the video page still exists.
  3. If the endpoint changed shape, strip any optional wrapper and parse the JSON directly.

Example fix

// before
match := utils.MatchOneOf(jsonString, randomString+`\((.*)\);$`)
// after — strip an optional JSONP wrapper, then unmarshal directly
body := strings.TrimSpace(jsonString)
if i := strings.IndexByte(body, '('); i >= 0 {
	body = strings.TrimSuffix(body[i+1:], ");")
}
err = json.Unmarshal([]byte(body), &data)
Defensive patterns

Strategy: try-catch

Type guard

func isMiaopaiInfoFailed(err error) bool {
	return err != nil && strings.Contains(err.Error(), "获取视频信息失败")
}

Try / catch

Catch per-URL, mark the smid as unavailable (deleted/private videos never recover), and continue the batch. Optionally fetch the API URL manually once to confirm whether the response is a non-JSONP error object.

Prevention

When it happens

Trigger: Deleted or private videos where the API returns an error object without the JSONP wrapper; a wrong smid; rate limiting; the endpoint moving off JSONP.

Common situations: Old links circulating in bookmarks or playlists; scraping bursts; miaopai API changes.

Related errors


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