oopsguy / m3u8

A mini M3U8 downloader written in Golang for downloading and merging TS(Transport Stream) files. 一个迷你 M3U8 视频下载工具。
MIT License
513 stars 139 forks source link

Parse url failed: request m3u8 URL failed: http error: status code 403 #2

Open Sei969 opened 4 years ago

Sei969 commented 4 years ago

Hello, I'm trying to download a SiriusXM stream and got the following error:

.\m3u8-windows-10-x64 -u="https://siriusxm-priprodlive.akamaized.net/AAC_Data/metropolitanopera/metropolitanopera_variant_large_v3.m3u8?token=1587734244_df40af36598eb6b72bd08d0470d1f78d&consumer=k2&gupId=3BDA15C5F23ADEEFE7B02D01A66968D4" -o="C:\downloads" Panic: parse url failed: request m3u8 URL failed: http error: status code 403

Is it related to the wrong master.m3u8 parsed?

To try it by yourself please go here with USA Vpn: https://player.siriusxm.com/home/foryou > start free preview > all channels > and choose channel 75 (Met Opera Radio).

Thanks for looking into this!

zackmark29 commented 4 years ago

Same problem I'm about to ask this as well

Is there any way to add headers?

BRUHItsABunny commented 4 years ago

hi, I'm not too familiar with the code just yet and am barely about to use it myself this week.

Error 403 means you didn't have any access to the resource you requested, you probably need authorization headers like zackmark29 hinted.

If you know how to generate the authorization header value, or know where to scrape it, it shouldn't be too hard for me modify this code so you can pass it through

titibandit commented 4 years ago

I've been able to download protected video by setting two headers: Cookie and User-Agent. First, find the right values for that by using the developer tools of your browser. Then I could integrate them by changing the Func Get in the http.go file:

func Get(url string) (io.ReadCloser, error) {
    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
    }
    req.Header.Set("Cookie", "...your cookie that makes it work")
    req.Header.Set("User-Agent", "...your user agent...")

    c := http.Client{
        Timeout: time.Duration(60) * time.Second,
    }
    resp, err := c.Do(req)
    if err != nil {
        return nil, err
    }
    if resp.StatusCode != 200 {
        return nil, fmt.Errorf("http error: status code %d", resp.StatusCode)
    }
    return resp.Body, nil
}

You might need other headers depending on how the website you're downloading from works

llychao commented 3 years ago

see here: https://github.com/llychao/m3u8-downloader

dave9123 commented 2 years ago

the ?token after the .m3u8 probably confuses the m3u8 reader

zackmark29 commented 2 years ago

the ?token after the .m3u8 probably confuses the m3u8 reader

Bro. That was 2020 =D

dave9123 commented 2 years ago

👍