diff --git a/main/src/main/java/com/sedmelluq/discord/lavaplayer/container/playlists/HlsStreamSegmentUrlProvider.java b/main/src/main/java/com/sedmelluq/discord/lavaplayer/container/playlists/HlsStreamSegmentUrlProvider.java index 950dbfe3..8d00f67b 100644 --- a/main/src/main/java/com/sedmelluq/discord/lavaplayer/container/playlists/HlsStreamSegmentUrlProvider.java +++ b/main/src/main/java/com/sedmelluq/discord/lavaplayer/container/playlists/HlsStreamSegmentUrlProvider.java @@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +import java.util.Arrays; import java.util.List; import static com.sedmelluq.discord.lavaplayer.tools.io.HttpClientTools.fetchResponseLines; @@ -29,6 +30,10 @@ protected String getQualityFromM3uDirective(ExtendedM3uParser.Line directiveLine return "default"; } + protected boolean isSegmentPlaylist(String[] lines) { + return Arrays.stream(lines).noneMatch(line -> line.startsWith("#EXT-X-STREAM-INF")); + } + @Override protected String fetchSegmentPlaylistUrl(HttpInterface httpInterface) throws IOException { if (segmentPlaylistUrl != null) { @@ -36,8 +41,13 @@ protected String fetchSegmentPlaylistUrl(HttpInterface httpInterface) throws IOE } HttpUriRequest request = new HttpGet(streamListUrl); - List streams = loadChannelStreamsList(fetchResponseLines(httpInterface, request, - "HLS stream list")); + String[] lines = fetchResponseLines(httpInterface, request, "HLS stream list"); + + if (isSegmentPlaylist(lines)) { + return (segmentPlaylistUrl = streamListUrl); + } + + List streams = loadChannelStreamsList(lines); if (streams.isEmpty()) { throw new IllegalStateException("No streams listed in HLS stream list."); diff --git a/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/stream/M3uStreamSegmentUrlProvider.java b/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/stream/M3uStreamSegmentUrlProvider.java index 5ed000df..82b5a07f 100644 --- a/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/stream/M3uStreamSegmentUrlProvider.java +++ b/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/stream/M3uStreamSegmentUrlProvider.java @@ -170,7 +170,7 @@ protected List loadChannelStreamsList(String[] lines) { } streamInfoLine = null; - } else if (line.isDirective() && "EXT-X-STREAM-INF".equals(line.directiveName)) { + } else if (line.isDirective() && ("EXT-X-STREAM-INF".equals(line.directiveName) || "EXTINF".equals(line.directiveName))) { streamInfoLine = line; } }