From 3d410346bfd642e152453c898c8d98b4b7a4800d Mon Sep 17 00:00:00 2001 From: horchi Date: Sat, 18 Mar 2017 11:56:16 +0100 Subject: added dynamic pause hadling for scraper movie download --- update.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'update.c') diff --git a/update.c b/update.c index b0d61be..139f7c0 100644 --- a/update.c +++ b/update.c @@ -2316,9 +2316,6 @@ int cEpgd::scrapNewEvents() if (seriesCur % 10 == 0) tell(0, "series episode %d / %d scraped...continuing scraping", seriesCur, seriesTotal); - if (seriesCur % 50 == 0) - sleep(1); - tvdbManager->ProcessSeries(*it); if (doShutDown()) @@ -2356,6 +2353,8 @@ int cEpgd::scrapNewEvents() tell(0, "%d new movies to scrap in db", moviesTotal); + time_t sectionStartAt = time(0); // split download in parts of 40 + for (vector::iterator it = moviesToScrap.begin(); it != moviesToScrap.end(); ++it) { movieCur++; @@ -2363,8 +2362,19 @@ int cEpgd::scrapNewEvents() if (movieCur % 10 == 0) tell(0, "movie %d / %d scraped...continuing scraping", movieCur, moviesTotal); - if (movieCur % 50 == 0) - sleep(1); + if (movieCur % 40 == 0) + { + int duration = time(0) - sectionStartAt; + + if (duration < 10) + { + duration = 10 - duration; + tell(0, "Waiting %d seconds..", duration); + sleep(duration); + } + + sectionStartAt = time(0); + } movieDbManager->ProcessMovie(*it); -- cgit v1.2.3