Code Monkey home page Code Monkey logo

m3u8parser's Introduction

M3U8Parser

M3U8Parser is a Java library which exposes classes to parse, merge and write M3U8 playlists.

This parser is based on http://ss-iptv.com/en/users/documents/m3u

It is a very simple library and it doesn't take care of all the attributes; it just parsers a playlist like the following one:

#EXTM3U
#EXTINF:0 tvg-id="1" tvg-name="Name1" tvg-logo="http://mylogos.domain/name1logo.png" group-title="Group1", Name1
http://server.name/stream/to/video1 #EXTINF:0 tvg-id="2" tvg-name="Name2" tvg-logo="http://mylogos.domain/name2logo.png" group-title="Group1", Name2
http://server.name/stream/to/video2 #EXTINF:0, tvg-id="3" tvg-name="Name3" tvg-logo="http://mylogos.domain/name3logo.png" group-title="Group2", Name3
http://server.name/stream/to/video3

Main classes

  • M3U8Parser: it parsers a .m3u8 text file and generates a Playlist object.
  • PlaylistMerger: it merges two or more Playlist objects into one.
  • M3U8PlaylistWriter: it converts a Playlist object into a ByteArrayOutputStream which can be written to a file (or wherever) to have a .m3u8 playlist as the one parsed by M3U8Parser.

How to use it

Import the source code as a module in your project or download it, build the .jar and then import the .jar into your project.

Parsing a playlist from file Create an M3U8Parser object to parse a file and create a Playlist object:

M3U8Parser m3U8Parser = new M3U8Parser(new URL("URLPointingToThePlaylistFile").openStream(), M3U8ItemScanner.Encoding.UTF_8); Playlist playlist = m3U8Parser.parse();

Merge Playlists Create a PlaylistMerger object and merge two or more Playlist objects: PlaylistMerger playlistMerger = new PlaylistMerger(); Playlist playlist = playlistMerger.mergePlaylist(playlist1, playlist2);

Write Playlist Create a M3U8PlaylistWriter object and write the ByteArrayOutputStream where you need to: M3U8PlaylistWriter m3U8PlaylistWriter = new M3U8PlaylistWriter(); ByteArrayOutputStream byteArrayOutputStream = m3U8PlaylistWriter.getByteArrayOutputStream(playlist);

Contributions

Pull requests are welcome

License

Apache License 2.0

m3u8parser's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.