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) {} + } }