nilaoda/N_m3u8DL-RE · error · Exception

ResString.keyProcessorNotFound

Error message

ResString.keyProcessorNotFound

What it means

During HLS playlist parsing, an '#EXT-X-KEY' line was found but none of the registered key processors in ParserConfig.KeyProcessors could handle it, so ParseKey throws. This usually means the key scheme (e.g. a specific DRM or encryption format) has no matching processor registered.

Solutions

  1. Inspect the EXT-X-KEY line in the playlist to identify the METHOD and URI format.
  2. Register/enable a key processor in ParserConfig.KeyProcessors that matches that key scheme (e.g. the AES or dedicated DRM processor).
  3. Update N_m3u8DL-RE — newer versions add processors for more key formats.
  4. If the content is DRM-protected and no processor exists, decryption is not supported; use another tool or an external decrypter.
  5. Catch the error and report the localized ResString.keyProcessorNotFound to the user.

Example fix

// before
var parserConfig = new ParserConfig(); // KeyProcessors left default

// after
var parserConfig = new ParserConfig();
parserConfig.KeyProcessors.Add(new AesKeyProcessor()); // handles METHOD=AES-128 style keys
// or provide the key manually if it is known:
parserConfig.CustomMethod = ...;
Defensive patterns

Strategy: try-catch

Validate before calling

var keyLines = content.Split('\n').Where(l => l.StartsWith("#EXT-X-KEY"));
foreach (var k in keyLines)
    Console.WriteLine(k); // confirm METHOD is one your KeyProcessors support before parsing

Try / catch

try { return await extractor.ExtractStreamsAsync(rawText); }
catch (Exception ex) when (ex.Message == ResString.keyProcessorNotFound)
{ throw new NotSupportedException($"Unsupported key scheme: {firstKeyLine}"); }

Prevention

When it happens

Trigger: Parsing an m3u8 containing an EXT-X-KEY whose METHOD/URI format does not match any processor's CanCustomProcess/CanProcess check; the loop over ParserConfig.KeyProcessors completes without a return.

Common situations: Playlist uses SAMPLE-AES or an unsupported DRM key scheme, the key processor list was left empty/default and the required processor (e.g. for a specific AES-128 variant) was not registered, or the key line is malformed.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of nilaoda/N_m3u8DL-RE@e113dee70c (2026-09-13). Data as JSON: /api/errors/75289092cce97194. Report an issue: GitHub.

Appendix: source

Thrown at src/N_m3u8DL-RE.Parser/Extractor/HLSExtractor.cs:458

            // 由于播放器默认从最后3个分片开始播放 此处设置刷新间隔为TargetDuration的2倍
            playlist.RefreshIntervalMs = (int)((playlist.TargetDuration ?? 5) * 2 * 1000);
        }

        return Task.FromResult(playlist);
    }

    private EncryptInfo ParseKey(string keyLine)
    {
        foreach (var p in ParserConfig.KeyProcessors)
        {
            if (p.CanProcess(ExtractorType, keyLine, M3u8Url, M3u8Content, ParserConfig))
            {
                // 匹配到对应处理器后不再继续
                return p.Process(keyLine, M3u8Url, M3u8Content, ParserConfig);
            }
        }

        throw new Exception(ResString.keyProcessorNotFound);
    }

    public async Task<List<StreamSpec>> ExtractStreamsAsync(string rawText)
    {
        this.M3u8Content = rawText;
        this.PreProcessContent();
        if (M3u8Content.Contains(HLSTags.ext_x_stream_inf))
        {
            Logger.Warn(ResString.masterM3u8Found);
            var lists = await ParseMasterListAsync();
            lists = lists.DistinctBy(p => p.Url).ToList();
            return lists;
        }

        var playlist = await ParseListAsync();
        return
        [
            new()

View on GitHub (pinned to e113dee70c)