{"library":"m3u8","title":"m3u8","description":"m3u8 is a Python library designed to parse M3U8 HTTP Live Streaming (HLS) playlists. It allows loading playlists from URIs, file paths, or strings, and provides access to segments, streams, and other HLS tag information. The library is actively maintained, with its current version being 6.0.0, and receives regular updates to support new HLS specifications and bug fixes.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install m3u8"],"cli":null},"imports":["import m3u8\nplaylist = m3u8.load('http://example.com/playlist.m3u8')","import m3u8\nplaylist = m3u8.loads('#EXTM3U8\\n...')"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import m3u8\nimport requests\nimport os\n\n# Example: Load a remote M3U8 playlist\n# In a real scenario, use a specific, stable M3U8 URL.\n# For a runnable example, we'll use a placeholder or local file.\n# For demonstration, we'll simulate a playlist string.\n\n# --- Option 1: Load from a URL (requires internet access) ---\n# remote_m3u8_url = 'https://example.com/path/to/playlist.m3u8' # Replace with a real M3U8 URL if testing live\n# try:\n#     playlist = m3u8.load(remote_m3u8_url)\n#     print(f\"Loaded playlist from URL: {remote_m3u8_url}\")\n#     if playlist.segments:\n#         print(f\"First segment URI: {playlist.segments[0].uri}\")\n#     else:\n#         print(\"No segments found in remote playlist.\")\n# except requests.exceptions.RequestException as e:\n#     print(f\"Error loading remote playlist: {e}\")\n\n# --- Option 2: Load from a string (always runnable) ---\nlocal_m3u8_content = \"\"\"\n#EXTM3U\n#EXT-X-VERSION:3\n#EXT-X-TARGETDURATION:10\n#EXT-X-MEDIA-SEQUENCE:0\n#EXTINF:9.009,\nhttp://example.com/segment0.ts\n#EXTINF:10.000,\nhttp://example.com/segment1.ts\n#EXT-X-ENDLIST\n\"\"\"\n\nplaylist_from_string = m3u8.loads(local_m3u8_content)\nprint(\"\\n--- Playlist from String ---\")\nprint(f\"Target Duration: {playlist_from_string.target_duration}\")\nprint(f\"Number of segments: {len(playlist_from_string.segments)}\")\nif playlist_from_string.segments:\n    print(f\"First segment URI: {playlist_from_string.segments[0].uri}\")\n\n# Iterate through segments\nprint(\"\\nSegments:\")\nfor i, segment in enumerate(playlist_from_string.segments):\n    print(f\"  Segment {i}: Duration={segment.duration}, URI={segment.uri}\")\n","lang":"python","description":"This quickstart demonstrates how to load an M3U8 playlist from a string using `m3u8.loads()` and access its basic properties like target duration and individual segments. An commented-out section shows how to load directly from a URL using `m3u8.load()` for live HLS streams.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"6.0.0","pypi_latest":"6.0.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.5,"avg_import_s":0.13,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.11,"mem_mb":5.4,"disk_size":"18.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.5,"import_time_s":0.09,"mem_mb":5.4,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.16,"mem_mb":5.8,"disk_size":"19.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.5,"import_time_s":0.15,"mem_mb":5.8,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.15,"mem_mb":5.4,"disk_size":"11.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.4,"import_time_s":0.15,"mem_mb":5.4,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.13,"mem_mb":5.5,"disk_size":"11.5M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.4,"import_time_s":0.13,"mem_mb":5.5,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.11,"mem_mb":5.5,"disk_size":"17.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"m3u8","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.7,"import_time_s":0.11,"mem_mb":5.5,"disk_size":"18M"}]}}