Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
gopkg.in/grafov/m3u8.v0
This is the most complete opensource library for parsing and generating of M3U8 playlists used in HTTP Live Streaming (Apple HLS) for internet video translations.
M3U8 is simple text format and parsing library for it must be simple too. It does not offer ways to play HLS or handle playlists over HTTP. So library features are:
The library covered by BSD 3-clause license. See LICENSE for the full text. Versions 0.8 and below was covered by GPL v3. License was changed from the version 0.9 and upper.
See the list of the library authors at AUTHORS file.
go get github.com/grafov/m3u8
or get releases from https://github.com/grafov/m3u8/releases
Package online documentation (examples included) available at:
Supported by the HLS protocol tags and their library support explained in M3U8 cheatsheet.
Parse playlist:
f, err := os.Open("playlist.m3u8")
if err != nil {
panic(err)
}
p, listType, err := m3u8.DecodeFrom(bufio.NewReader(f), true)
if err != nil {
panic(err)
}
switch listType {
case m3u8.MEDIA:
mediapl := p.(*m3u8.MediaPlaylist)
fmt.Printf("%+v\n", mediapl)
case m3u8.MASTER:
masterpl := p.(*m3u8.MasterPlaylist)
fmt.Printf("%+v\n", masterpl)
}
Then you get filled with parsed data structures. For master playlists you get Master
struct with slice consists of pointers to Variant
structures (which represent playlists to each bitrate).
For media playlist parser returns MediaPlaylist
structure with slice of Segments
. Each segment is of MediaSegment
type.
See structure.go
or full documentation (link below).
You may use API methods to fill structures or create them manually to generate playlists. Example of media playlist generation:
p, e := m3u8.NewMediaPlaylist(3, 10) // with window of size 3 and capacity 10
if e != nil {
panic(fmt.Sprintf("Creating of media playlist failed: %s", e))
}
for i := 0; i < 5; i++ {
e = p.Append(fmt.Sprintf("test%d.ts", i), 6.0, "")
if e != nil {
panic(fmt.Sprintf("Add segment #%d to a media playlist failed: %s", i, e))
}
}
fmt.Println(p.Encode().String())
Library has compact code and bundled in three files:
structure.go
— declares all structures related to playlists and their propertiesreader.go
— playlist parser methodswriter.go
— playlist generator methodsEach file has own test suite placed in *_test.go
accordingly.
This library was successfully used in streaming software developed for company where I worked several years ago. It was tested then in generating of VOD and Live streams and parsing of Widevine Live streams. Also the library used in opensource software so you may look at these apps for usage examples:
Project maintainers:
State of code coverage: https://gocover.io/github.com/grafov/m3u8
To version 1.0:
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.