private void initializeFanartFolder(String dir) {
   log.info("Phoenix Fanart initializing");
   if (StringUtils.isEmpty(dir)) {
     dir =
         System.getProperty("user.dir")
             + File.separator
             + "STVs"
             + File.separator
             + "Phoenix"
             + File.separator
             + "Fanart";
     fanartConfig.setCentralFanartFolder(dir);
   }
   File fanartFolder = new File(dir);
   if (!fanartFolder.exists()) {
     log.warn("Fanart folder does not exist, creating: " + fanartFolder);
     if (!fanartFolder.mkdirs()) {
       log.warn(
           "Failed to create the fanart folder, this may be a permissions problem:  Folder; "
               + fanartFolder);
     }
     if (!fanartFolder.canWrite()) {
       log.warn("You don't have permissions to write to your fanart folder: " + fanartFolder);
     }
   }
   log.info("Phoenix Fanart initialized");
 }
  public File[] GetFanartArtifacts(
      Object mediaObject,
      MediaType mediaType,
      String mediaTitle,
      MediaArtifactType artifactType,
      String artifactTitle,
      Map<String, String> metadata) {
    File files[] = null;
    SimpleMediaFile mf = SageFanartUtil.GetSimpleMediaFile(mediaObject);
    mediaType = Utils.returnNonNull(mediaType, mf.getMediaType());
    mediaTitle = Utils.returnNonNull(mediaTitle, mf.getTitle());
    metadata = Utils.returnNonNull(metadata, getMetadata(mediaType, mediaObject));
    String fanartFolder = GetFanartCentralFolder();

    if (!fanartConfig.getUseSeason()) {
      // if we are setup to not use season specific fanart, null out
      // metadata
      metadata = null;
    }

    files =
        GetFanartArtifactsForTitle(
            mediaObject,
            mediaType,
            mediaTitle,
            artifactType,
            artifactTitle,
            metadata,
            fanartFolder);

    if (!exists(files) && mf.getMediaType() == MediaType.MUSIC) {
      files =
          GetFanartArtifactsForTitle(
              mediaObject,
              mediaType,
              SageFanartUtil.GetAlbumArtist(mediaObject),
              artifactType,
              artifactTitle,
              metadata,
              fanartFolder);
      if (!exists(files)) {
        files =
            GetFanartArtifactsForTitle(
                mediaObject,
                mediaType,
                SageFanartUtil.GetAlbumPersonArtist(mediaObject),
                artifactType,
                artifactTitle,
                metadata,
                fanartFolder);
      }
    }

    // if no central fanart, then check for local fanart
    // if (!exists(files)) {
    // File f = localFanart.GetFanartArtifact(mediaObject, mediaType,
    // mediaTitle, artifactType, artifactTitle, metadata);
    // if (f.exists()) {
    // files = new File[] {f};
    // }
    // }

    return files;
  }
 public PhoenixFanartSupport() {
   fanartConfig = GroupProxy.get(MetadataConfiguration.class);
   initializeFanartFolder(fanartConfig.getFanartCentralFolder());
 }
  public File GetFanartArtifact(
      Object mediaObject,
      MediaType mediaType,
      String mediaTitle,
      MediaArtifactType artifactType,
      String artifactTitle,
      Map<String, String> metadata) {
    File file = null;
    SimpleMediaFile mf = SageFanartUtil.GetSimpleMediaFile(mediaObject);
    mediaType = Utils.returnNonNull(mediaType, mf.getMediaType());
    mediaTitle = Utils.returnNonNull(mediaTitle, mf.getTitle());
    metadata = Utils.returnNonNull(metadata, getMetadata(mediaType, mediaObject));
    String fanartFolder = GetFanartCentralFolder();

    if (!fanartConfig.getUseSeason()) {
      // if we are setup to not use season specific fanart, null out
      // metadata
      metadata = null;
    }

    // check for a default file
    file = getDefaultArtifact(mediaObject, artifactType);

    if (file == null) {
      file =
          GetFanartArtifactForTitle(
              mediaObject,
              mediaType,
              mediaTitle,
              artifactType,
              artifactTitle,
              metadata,
              fanartFolder);
    }

    if (!exists(file) && mf.getMediaType() == MediaType.MUSIC) {
      file =
          GetFanartArtifactForTitle(
              mediaObject,
              MediaType.MUSIC,
              SageFanartUtil.GetAlbumArtist(mediaObject),
              artifactType,
              artifactTitle,
              metadata,
              GetFanartCentralFolder());

      if (!exists(file)) {
        file =
            GetFanartArtifactForTitle(
                mediaObject,
                MediaType.MUSIC,
                SageFanartUtil.GetAlbumPersonArtist(mediaObject),
                artifactType,
                artifactTitle,
                metadata,
                GetFanartCentralFolder());
      }
    }

    // fallback to local fanart
    // if (!file.exists()) {
    // file = localFanart.GetFanartArtifact(mediaObject, mediaType,
    // mediaTitle, artifactType, artifactTitle, metadata);
    // }

    return file;
  }
 public void SetIsFanartEnabled(boolean value) {
   fanartConfig.setFanartEnabled(value);
 }
 public void SetFanartCentralFolder(String folder) {
   log.debug("Setting Central Fanart Folder: " + folder);
   fanartConfig.setCentralFanartFolder(folder);
   initializeFanartFolder(folder);
 }
 public boolean IsFanartEnabled() {
   return fanartConfig.isFanartEnabled();
 }
 public String GetFanartCentralFolder() {
   return fanartConfig.getFanartCentralFolder();
 }