コード例 #1
0
  public File GetFanartArtifactDir(
      Object mediaObject,
      MediaType mediaType,
      String mediaTitle,
      MediaArtifactType artifactType,
      String artifactTitle,
      Map<String, String> metadata,
      boolean create) {
    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();
    File f =
        FanartUtil.getCentralFanartDir(
            mediaType, mediaTitle, artifactType, artifactTitle, fanartFolder, metadata);

    if (create && f != null && !f.exists()) {
      sagex.phoenix.util.FileUtils.mkdirsQuietly(f);
      if (!f.exists()) {
        log.warn("Unable to create directory: " + f.getAbsolutePath() + "; Pemission issue?");
      }
    }

    return f;
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  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;
  }