From 43cfea36deabfc08a13c4ffc5949633c37a7c42a Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Sat, 1 Jun 2019 17:27:59 +0200 Subject: [PATCH] Wait a few seconds after a problem (404,403) with the HLS playlist occured --- .../java/ctbrec/recorder/download/HlsDownload.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/src/main/java/ctbrec/recorder/download/HlsDownload.java b/common/src/main/java/ctbrec/recorder/download/HlsDownload.java index 2f72bb75..187a42b4 100644 --- a/common/src/main/java/ctbrec/recorder/download/HlsDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/HlsDownload.java @@ -161,8 +161,10 @@ public class HlsDownload extends AbstractHlsDownload { } catch(HttpException e) { if(e.getResponseCode() == 404) { LOG.debug("Playlist not found (404). Model {} probably went offline", model); + waitSomeTime(); } else if(e.getResponseCode() == 403) { LOG.debug("Playlist access forbidden (403). Model {} probably went private or offline", model); + waitSomeTime(); } else { throw e; } @@ -344,4 +346,15 @@ public class HlsDownload extends AbstractHlsDownload { throw new FileNotFoundException(playlist.getAbsolutePath() + " does not exist"); } } + + /** + * Causes the current thread to sleep for a short amount of time. + * This is used to slow down retries, if something is wrong with the playlist. + * E.g. HTTP 403 or 404 + */ + private void waitSomeTime() { + try { + Thread.sleep(10_000); + } catch (Exception e) {} + } }