selsta / hlsdl

C program to download VoD HLS (.m3u8) files
MIT License
636 stars 158 forks source link

[404] Error getting Key-File when string has & #81

Open finelikewine opened 4 years ago

finelikewine commented 4 years ago

EXTM3U

EXT-X-VERSION:3

EXT-X-TARGETDURATION:5

EXT-X-MEDIA-SEQUENCE:0

EXT-X-KEY:METHOD=AES-128,URI="https://websiteurl.com?id=DF4s$t%FvsdEdc&fadk=couk"

Error: Getting key-file [https://websiteurl.com?id=DF4s$t%FvsdEdc&fadk=couk] failed http_code[404]

Not sure if it's a website issue, IP issue, or if it has to do with the & which is preventing HLSDL from getting the key.

Pfuenzle commented 3 years ago

nope, same error for me. Havent look into the code yet, but I hope I will be able to fix it, or at least make it possible to supply a keyfile via terminal

glgoose commented 3 years ago

nope, same error for me. Havent look into the code yet, but I hope I will be able to fix it, or at least make it possible to supply a keyfile via terminal

Yes, it would be great to have the ability to supply a keyfile via terminal

xavave commented 3 years ago

hi, I've already made a few fixes and upgrades on my fork https://github.com/xavave/hlsdl-vs2019, but not this one 1- I would like now to be able to reproduce the issue with '&' key file, would you have a key file within a http(s) url example please? (I would need the m3u8 url) 2- for supplying a keyfile via terminal, what would you suggest ? this provided keyfile would override the original keyfile url?

maybe you could try with this fix in hls.c method fill_key_value:

replace:

            http_code = get_hls_data_from_url(key_url, &key_value, &size, BINKEY, NULL);
            if (es->key_url != key_url) {
                free(key_url);
            }

            if (http_code != 200 || size == 0) {
                MSG_ERROR("Getting key-file [%s] failed http_code[%d].\n", es->key_url, http_code);
                return 1;
            }
[test_winX64.zip](https://github.com/selsta/hlsdl/files/5655285/test_winX64.zip)

with;

           char* oldurl = key_url;
            char* newurl = repl_str(oldurl, "&", "&");

            http_code = get_hls_data_from_url(newurl , &key_value, &size, BINKEY, NULL);
            // http_code = get_hls_data_from_url(key_url, &key_value, &size, BINKEY, NULL);
            if (es->key_url != key_url) {
                free(key_url);
            }

            if (http_code != 200 || size == 0) {
                MSG_ERROR("Getting key-file [%s] failed http_code[%d].\n", es->key_url, http_code);
                return 1;
            }

In test_winX64.zip attachment: I've zipped a windows 64 compiled version of hlsdl with this fix test