get all adaptation

This commit is contained in:
唐三 2023-07-07 17:45:33 +08:00
parent 650e093dd0
commit 30eed9471b
1 changed files with 5 additions and 4 deletions

View File

@ -145,23 +145,24 @@ public class Bili extends Spider {
Resp resp = Resp.objectFrom(json); Resp resp = Resp.objectFrom(json);
Dash dash = resp.getData().getDash(); Dash dash = resp.getData().getDash();
String videoList = "", audioList = ""; StringBuilder videoList = new StringBuilder();
StringBuilder audioList = new StringBuilder();
for (Dash.Media video : dash.getVideo()) { for (Dash.Media video : dash.getVideo()) {
if (video.getId().equals(qn)) { if (video.getId().equals(qn)) {
videoList = getMedia(video); videoList.append(getMedia(video));
break; break;
} }
} }
for (Dash.Media audio : dash.getAudio()) { for (Dash.Media audio : dash.getAudio()) {
for (String key : audios.keySet()) { for (String key : audios.keySet()) {
if (audio.getId().equals(key)) { if (audio.getId().equals(key)) {
audioList = getMedia(audio); audioList.append(getMedia(audio));
break; break;
} }
} }
} }
String mpd = getMpd(dash, videoList, audioList); String mpd = getMpd(dash, videoList.toString(), audioList.toString());
String url = "data:application/dash+xml;base64," + Base64.encodeToString(mpd.getBytes(), 0); String url = "data:application/dash+xml;base64," + Base64.encodeToString(mpd.getBytes(), 0);
return Result.get().url(url).header(header).string(); return Result.get().url(url).header(header).string();
} }