Add setting for playlist request timeout

This commit is contained in:
0xb00bface 2021-01-23 22:57:59 +01:00
parent 844295101e
commit f646c28151
3 changed files with 9 additions and 2 deletions

View File

@ -135,6 +135,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private SimpleIntegerProperty postProcessingThreads; private SimpleIntegerProperty postProcessingThreads;
private IgnoreList ignoreList; private IgnoreList ignoreList;
private Label restartNotification; private Label restartNotification;
private SimpleIntegerProperty playlistRequestTimeout;
public SettingsTab(List<Site> sites, Recorder recorder) { public SettingsTab(List<Site> sites, Recorder recorder) {
this.sites = sites; this.sites = sites;
@ -193,6 +194,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
useHlsdl = new SimpleBooleanProperty(null, "useHlsdl", settings.useHlsdl); useHlsdl = new SimpleBooleanProperty(null, "useHlsdl", settings.useHlsdl);
hlsdlExecutable = new SimpleFileProperty(null, "hlsdlExecutable", settings.hlsdlExecutable); hlsdlExecutable = new SimpleFileProperty(null, "hlsdlExecutable", settings.hlsdlExecutable);
recentlyWatched = new SimpleBooleanProperty(null, "recentlyWatched", settings.recentlyWatched); recentlyWatched = new SimpleBooleanProperty(null, "recentlyWatched", settings.recentlyWatched);
playlistRequestTimeout = new SimpleIntegerProperty(null, "playlistRequestTimeout", settings.playlistRequestTimeout);
} }
private void createGui() { private void createGui() {
@ -277,6 +279,9 @@ public class SettingsTab extends Tab implements TabSelectionListener {
) )
), ),
Category.of("Advanced / Devtools", Category.of("Advanced / Devtools",
Group.of("Networking",
Setting.of("Playlist request timeout (ms)", playlistRequestTimeout, "Timeout in ms for playlist requests")
),
Group.of("Logging", Group.of("Logging",
Setting.of("Log FFmpeg output", logFFmpegOutput, "Log FFmpeg output to files in the system's temp directory") Setting.of("Log FFmpeg output", logFFmpegOutput, "Log FFmpeg output to files in the system's temp directory")
), ),

View File

@ -113,6 +113,7 @@ public class Settings {
public String password = ""; public String password = "";
@Deprecated @Deprecated
public String postProcessing = ""; public String postProcessing = "";
public int playlistRequestTimeout = 2000;
public int postProcessingThreads = 2; public int postProcessingThreads = 2;
public List<PostProcessor> postProcessors = new ArrayList<>(); public List<PostProcessor> postProcessors = new ArrayList<>();
public String proxyHost; public String proxyHost;

View File

@ -230,7 +230,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
addHeaders(builder, Optional.ofNullable(model).map(Model::getHttpHeaderFactory).map(HttpHeaderFactory::createSegmentPlaylistHeaders).orElse(new HashMap<>()), model); addHeaders(builder, Optional.ofNullable(model).map(Model::getHttpHeaderFactory).map(HttpHeaderFactory::createSegmentPlaylistHeaders).orElse(new HashMap<>()), model);
Request request = builder.build(); Request request = builder.build();
try (Response response = client.execute(request, 2000)) { try (Response response = client.execute(request, config.getSettings().playlistRequestTimeout)) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
consecutivePlaylistTimeouts = 0; consecutivePlaylistTimeouts = 0;
String body = response.body().string(); String body = response.body().string();
@ -253,7 +253,8 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
throw new HttpException(response.code(), response.message()); throw new HttpException(response.code(), response.message());
} }
} catch (SocketTimeoutException e) { } catch (SocketTimeoutException e) {
LOG.debug("Playlist request timed out for model {} {} time{}", model, ++consecutivePlaylistTimeouts, (consecutivePlaylistTimeouts > 1) ? 's' : ""); LOG.debug("Playlist request timed out ({}ms) for model {} {} time{}", config.getSettings().playlistRequestTimeout, model,
++consecutivePlaylistTimeouts, (consecutivePlaylistTimeouts > 1) ? 's' : "");
// times out, return an empty playlist, so that the process can continue without wasting much more time // times out, return an empty playlist, so that the process can continue without wasting much more time
recordingEvents.add(RecordingEvent.of("Playlist request timed out " + consecutivePlaylistTimeouts)); recordingEvents.add(RecordingEvent.of("Playlist request timed out " + consecutivePlaylistTimeouts));
throw new PlaylistTimeoutException(e); throw new PlaylistTimeoutException(e);