From 0152187aa8aa74b54d7085818e934f76a3fedf24 Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Fri, 16 Oct 2020 20:23:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Div=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E7=B4=A2=E5=BC=95=E6=96=87=E4=BB=B6=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98,=20https://github.com/Aria?= =?UTF-8?q?Lyy/Aria/issues/780?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DEV_LOG.md | 1 + .../com/arialyy/aria/m3u8/BaseM3U8Loader.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/DEV_LOG.md b/DEV_LOG.md index c51d13ab..036c9fc3 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,6 +1,7 @@ ## 开发日志 + v_3.8.15 - 修复不支持断点的连接下载失败问题,https://github.com/AriaLyy/Aria/issues/771 + - 修复iv不存在时,索引文件异常的问题,https://github.com/AriaLyy/Aria/issues/780 + v_3.8.14 (2020/9/23) - 修复spi机制的兼容问题,https://github.com/AriaLyy/Aria/issues/743 - 增加路径不可以写的判断,下载时,如果路径不可写,将执行失败回调 https://github.com/AriaLyy/Aria/issues/750 diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java index 3b06165a..10ee5523 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java @@ -95,9 +95,21 @@ public abstract class BaseM3U8Loader extends AbsNormalLoader { i++; } else if (line.startsWith("#EXT-X-KEY")) { M3U8Entity m3U8Entity = getEntity().getM3U8Entity(); - String keyInfo = String.format("#EXT-X-KEY:METHOD=%s,URI=\"%s\",IV=%s\r\n", m3U8Entity.method, - m3U8Entity.keyPath, m3U8Entity.iv); - bytes = keyInfo.getBytes(Charset.forName("UTF-8")); + StringBuilder sb = new StringBuilder("#EXT-X-KEY:"); + sb.append("METHOD=").append(m3U8Entity.method); + sb.append(",URI=\"").append(m3U8Entity.keyPath).append("\""); + if (!TextUtils.isEmpty(m3U8Entity.iv)) { + sb.append(",IV=").append(m3U8Entity.iv); + } + if (!TextUtils.isEmpty(m3U8Entity.keyFormat)) { + sb.append(",KEYFORMAT=\"").append(m3U8Entity.keyFormat).append("\""); + sb.append(",KEYFORMATVERSIONS=\"") + .append(TextUtils.isEmpty(m3U8Entity.keyFormatVersion) ? "1" + : m3U8Entity.keyFormatVersion) + .append("\""); + } + sb.append("\r\n"); + bytes = sb.toString().getBytes(Charset.forName("UTF-8")); } else { bytes = line.concat("\r\n").getBytes(Charset.forName("UTF-8")); }