Comments (6)
I've done exactly that before, glad you've fixed it.
from m3u8.
m3u8.DecodeFrom gives only #EXTM3U absent
if strict is set. If it's not, then I get: Can't detect playlist type
.
Also tried with different Apple sample files.
golang 1.7.4, m3u8 0.9.0
from m3u8.
I'll get a look in the next 24 hours if that's ok
from m3u8.
No hurries, @bradleyfalzon. Thanks!
from m3u8.
having said that, this looks ok to me:
package main
import (
"fmt"
"log"
"net/http"
"net/http/httptest"
"github.com/grafov/m3u8"
)
func main() {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, `#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="stereo",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="audio/stereo/en/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="stereo",LANGUAGE="dubbing",NAME="Dubbing",DEFAULT=NO,AUTOSELECT=YES,URI="audio/stereo/none/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="surround",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="audio/surround/en/320kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="surround",LANGUAGE="dubbing",NAME="Dubbing",DEFAULT=NO,AUTOSELECT=YES,URI="audio/stereo/none/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Deutsch",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="de",URI="subtitles_de.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",URI="subtitles_en.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Espanol",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="es",URI="subtitles_es.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Français",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="fr",URI="subtitles_fr.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=258157,CODECS="avc1.4d400d,mp4a.40.2",AUDIO="stereo",RESOLUTION=422x180,SUBTITLES="subs"
video/250kbit.m3u8`)
}))
defer ts.Close()
res, err := http.Get(ts.URL)
if err != nil {
log.Fatal(err)
}
p := m3u8.NewMasterPlaylist()
err = p.DecodeFrom(res.Body, false)
fmt.Println("err:", err)
fmt.Println("playlist:", p)
}
go run main.go
err: <nil>
playlist: #EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="stereo",NAME="English",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en",URI="audio/stereo/en/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="stereo",NAME="Dubbing",DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="dubbing",URI="audio/stereo/none/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="surround",NAME="English",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en",URI="audio/surround/en/320kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="surround",NAME="Dubbing",DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="dubbing",URI="audio/stereo/none/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Deutsch",DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="de",FORCED="NO",URI="subtitles_de.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en",FORCED="NO",URI="subtitles_en.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Espanol",DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="es",FORCED="NO",URI="subtitles_es.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Français",DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="fr",FORCED="NO",URI="subtitles_fr.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=258157,CODECS="avc1.4d400d,mp4a.40.2",RESOLUTION=422x180,AUDIO="stereo",SUBTITLES="subs"
video/250kbit.m3u8
from m3u8.
@bradleyfalzon aaargh it was a problem with me reading from ReadCloser simultaneously and writing it to a file, so it drained the body. :)
from m3u8.
Related Issues (20)
- Under load encoder does not perform correctly HOT 3
- Using for range loop to MediaPlaylist.Segments would lead to nil pointer dereference HOT 2
- Fix a report card issues for passing to awesome-go list HOT 1
- M3U8 doesn't play after some time HOT 1
- EXT-X-MEDIA audio missing from VariantParams.Alternatives for master playlist decode HOT 1
- . HOT 2
- MediaPlaylist decode custom tag panic
- m3u8.DecodeFrom panics in case of blank lines in playlist
- I have a SCTE-35 parser...... HOT 1
- SCTE35 - EXT-OATCLS-SCTE35 with EXT-X-CUE-IN
- tag: #EXT-X-MEDIA attribute: CHANNELS is not recognized HOT 1
- Is this repo dead? HOT 3
- program panic when i get the url of media segments HOT 6
- safari play fail bug
- Doesn't handle "Alternatives" correctly inside a master playlist's "variants"
- program panic when I parse the media segments
- Decoding MediaPlaylist panics with error: index out of range [0] with length 0 HOT 2
- Support Tag #EXT-X-IMAGE-STREAM-INF
- set Segment key error
- Duplicate Data Resulting from Custom Tags HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from m3u8.