addSeasons.php 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/local/bin/php
  2. <?
  3. function verbose($str) {
  4. echo $str;
  5. }
  6. set_time_limit(0);
  7. require_once 'includes/main.php';
  8. global $TV_PATH;
  9. $all_series = allSeriesSeasons($TV_PATH);
  10. # Check each series for new seasons listed on TVDB but not locally
  11. foreach ($all_series as $series => $seasons) {
  12. # Long wait between series, to avoid TVDB bans
  13. sleep(rand(20, 40));
  14. # Grab the TVDB season list
  15. $flags = readFlags($series);
  16. $tvdb_seasons = getTVDBSeasons($flags['tvdb-id'], $flags['tvdb-lid']);
  17. # We only care about "new" seasons -- don't force old seasons into the local tree
  18. $tvdb_max = @max(array_keys($tvdb_seasons));
  19. $local_max = @max(array_keys($seasons));
  20. # If we detect one or more missing seasons
  21. if ($tvdb_max > $local_max) {
  22. verbose($series . "\n");
  23. for ($season = $local_max + 1; $season <= $tvdb_max; $season++) {
  24. verbose("\tAdding season: " . $season);
  25. #addSeason($series, $season);
  26. }
  27. } else {
  28. verbose('No new seasons: ' . $series . "\n");
  29. }
  30. exit(0);
  31. }
  32. ?>