series.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?
  2. require 'config.php';
  3. # Find all shows under the given path
  4. function allShows($base) {
  5. $retval = array();
  6. # Look for series folders
  7. $tv_dir = opendir($base);
  8. if ($tv_dir === FALSE) {
  9. die('Unable to opendir(): ' . htmlspecialchars($path) . "\n");
  10. }
  11. while (false !== ($show = readdir($tv_dir))) {
  12. # Skip junk
  13. if (isJunk($show)) {
  14. continue;
  15. }
  16. # We only care about directories
  17. $show_path = $base . '/' . $show;
  18. if (!is_dir($show_path)) {
  19. continue;
  20. }
  21. # Record the show title and look for season folders
  22. $retval[ $show ] = findSeasons($show_path);
  23. }
  24. closedir($tv_dir);
  25. return $retval;
  26. }
  27. # Read and parse all of the series-level exists, content, and *.webloc files
  28. function readFlags($path) {
  29. global $EXISTS_FILES;
  30. global $CONTENT_FILES;
  31. $flags = array();
  32. # Look for all the exists files
  33. foreach ($EXISTS_FILES as $name) {
  34. $flags[ $name ] = false;
  35. if (file_exists($path . '/' . $name)) {
  36. $flags[ $name ] = true;
  37. }
  38. }
  39. # Read all the content files
  40. foreach ($CONTENT_FILES as $name) {
  41. $flags[ $name ] = false;
  42. $file = $path . '/' . $name;
  43. if (is_readable($file)) {
  44. $flags[ $name ] = trim(file_get_contents($file));
  45. }
  46. }
  47. # Read the TVDB IDs from the *.webloc file
  48. $webloc = findWebloc($path);
  49. if ($webloc !== false) {
  50. $flags = array_merge($flags, readWebloc($webloc));
  51. }
  52. return $flags;
  53. }
  54. ?>