<?xml version="1.0" encoding="UTF-8"?> <playlist version="1" xmlns="http://xspf.org/ns/0/"> <trackList> <track> <location>http://archive.obscure.server:8080/stream/phantom_empire.mkv</location> <title>The Phantom Empire - Chapter 12</title> <annotation>The last stand of Gene Autry.</annotation> </track>
tree = ET.ElementTree(root) tree.write(xspf_path, encoding="UTF-8", xml_declaration=True)
In the context of IPTV, an XSPF playlist is used to organize and play back live TV channels or on-demand content. The playlist contains a list of streams, each of which is identified by a unique URL (Uniform Resource Locator) and other metadata, such as the channel name and description. When an IPTV player loads an XSPF playlist, it reads the XML file and uses the information to connect to the corresponding streams.
<?xml version="1.0" encoding="UTF-8"?> <xspf version="1" xmlns="http://xspf.org/ns/0/"> <title>Example IPTV Playlist</title> <trackList> <track> <title>News Channel</title> <location>http://example.com/streams/news.m3u8</location> <annotation>Live 24/7</annotation> <image>http://example.com/logos/news.png</image> <duration>0</duration> </track> <track> <title>Movie Channel</title> <location>http://example.com/streams/movie.ts</location> <annotation>HD</annotation> <image>http://example.com/logos/movie.png</image> </track> </trackList> </xspf>
Using XSPF for IPTV provides a more "database-like" experience for your media:
Not all IPTV players handle XSPF equally. Here are the top performers:
<track> <title>CNN International</title> <location>http://stream.cnn.com/live.m3u8</location> <meta rel="epg-id">cnn.intl</meta> <meta rel="epg-source">https://example.com/epg.xml.gz</meta> <meta rel="channel-number">105</meta> <meta rel="catchup-days">7</meta> </track>