public AudioItem loadTrackWithVideoId(String videoId, boolean mustExist) {
try (HttpInterface httpInterface = getHttpInterface()) {
JsonBrowser info = getTrackInfoFromMainPage(httpInterface, videoId, mustExist);
if (info == null) {
return AudioReference.NO_TRACK;
}
JsonBrowser args = info.get("args");
if ("fail".equals(args.get("status").text())) {
throw new FriendlyException(args.get("reason").text(), COMMON, null);
}
boolean isStream = "1".equals(args.get("live_playback").text());
long duration = isStream ? Long.MAX_VALUE : args.get("length_seconds").as(Long.class) * 1000;
return buildTrackObject(videoId, args.get("title").text(), args.get("author").text(), isStream, duration);
} catch (Exception e) {
throw ExceptionTools.wrapUnfriendlyExceptions("Loading information for a YouTube track failed.", FAULT, e);
}
}