Beispiel #1
0
  public void download(final Context context) {

    String album = "*";
    String title = "*";
    String artist = "*";
    if (this instanceof Song) {
      Song song = (Song) this;
      title = song.getName();
      album = song.getAlbum().getName();
      artist = song.getArtist().getName();
    } else if (this instanceof Album) {
      Album a = (Album) this;
      if (a.getArtist().getName().trim().equals("") == false) {
        artist = a.getArtist().getName();
      }
      album = a.getName();
    } else if (this instanceof Artist) {
      Artist a = (Artist) this;
      artist = a.getName();
    }
    SyncTask task = new SyncTask(context, true);
    task.execute(
        "download",
        new BasicNameValuePair("name", title),
        new BasicNameValuePair("album", album),
        new BasicNameValuePair("artist", artist));
  }
Beispiel #2
0
  public void tagList(final Context context) {

    String album = "*";
    String title = "*";
    String artist = "*";
    if (this instanceof Song) {
      Song song = (Song) this;
      title = song.getName();
      album = song.getAlbum().getName();
      artist = song.getArtist().getName();
    } else if (this instanceof Album) {
      Album a = (Album) this;
      if (a.getArtist().getName().trim().equals("") == false) {
        artist = a.getArtist().getName();
      }
      album = a.getName();
    } else if (this instanceof Artist) {
      Artist a = (Artist) this;
      artist = a.getName();
    }
    showTagListDialog(context, title, album, artist);
  }
  @Override
  public void run() {
    FilenameFilter filter = new FlacFilter();
    boolean atBeginningOfLibrary = true;
    boolean okToUseTags;
    TagReader tr;
    String path = "";
    Album rippedDisc = new Album();

    parentWindow.setStatus("Recursing directories to find music files");
    try {
      sleep(1);
    } catch (InterruptedException ie) {
    }

    this.files = RecurseDirectory.listFilesAsArray(options.getLibraryRoot(), filter, true);
    for (File file : files) {
      if (options.isUseEmbeddedTags()
          && ((file.getName().toLowerCase()).endsWith(".flac")
              || (file.getName().toLowerCase()).endsWith(".mp3"))) okToUseTags = true;
      else okToUseTags = false;

      File parentDirectory = file.getParentFile();

      String[] splitPath = (file.toString()).split("\\\\");
      if (parentDirectory.getPath().equals(path) == false) {
        // new album
        path = parentDirectory.getPath();
        parentWindow.setStatus("Processing " + path);
        try {
          sleep(1);
        } catch (InterruptedException ie) {
        }

        // add current Album first
        if (atBeginningOfLibrary == false) {
          rippedDiscs.add(rippedDisc);
        }
        atBeginningOfLibrary = false;

        rippedDisc = new Album();

        // Get General Artist - Album information
        if (okToUseTags) {
          try {
            tr = new TagReader(file);
            tr.processSong();
            rippedDisc.setAlbumTitle(tr.getAlbum());
            rippedDisc.setDate(tr.getDate());

            if (tr.getAlbumArtist() != null && !tr.getAlbumArtist().isEmpty())
              rippedDisc.setArtist(tr.getAlbumArtist());
            else rippedDisc.setArtist(tr.getArtist());

            if (options.isSubstituteComposer()) {
              if (tr.getComposer() != null
                  && !tr.getComposer().isEmpty()
                  && tr.getGenre().startsWith("Classical")) {
                rippedDisc.setGenre(tr.getComposer());
              } else {
                rippedDisc.setGenre(tr.getGenre());
              }
            } else {
              rippedDisc.setGenre(tr.getGenre());
            }
          } catch (Exception e) {
            rippedDisc.setAlbumTitle(splitPath[splitPath.length - 2]);
            rippedDisc.setArtist(splitPath[splitPath.length - 3]);
            parentWindow.setStatus(e.getMessage());
            System.out.println(e.getStackTrace());
          }

        } else {
          if (options.isParseTagsFromSingleFolder()) {
            try {
              rippedDisc.setAlbumTitle(
                  getAlbumNameFromSingleFolder(splitPath[splitPath.length - 2]));
            } catch (Exception e) {
              System.out.println("Can't parse album name from single folder name.");
              System.out.println(
                  "You will need to manually edit " + splitPath[splitPath.length - 2]);
              System.out.println(e.getMessage());
              System.out.println(e.getStackTrace());
              rippedDisc.setAlbumTitle(splitPath[splitPath.length - 2]);
            }
            try {
              rippedDisc.setArtist(getArtistNameFromSingleFolder(splitPath[splitPath.length - 2]));
            } catch (Exception e) {
              System.out.println("Can't parse artist from single folder name.");
              System.out.println(
                  "You will need to manually edit " + splitPath[splitPath.length - 2]);
              System.out.println(e.getMessage());
              System.out.println(e.getStackTrace());
              rippedDisc.setArtist(splitPath[splitPath.length - 2]);
            }
          } else {
            rippedDisc.setAlbumTitle(splitPath[splitPath.length - 2]);
            rippedDisc.setArtist(splitPath[splitPath.length - 3]);
          }

          // write genre if using genre - artist - album folder structure
          if (options.getFoldersInCueSheetName() == 3) {
            try {
              rippedDisc.setGenre(splitPath[splitPath.length - 4]);
            } catch (Exception e) {
              System.out.println(e.getMessage());
            }
          }
        }

        rippedDisc.setDirectoryOnDisc(parentDirectory);
      }

      if (okToUseTags) {
        try {
          tr = new TagReader(file);
          tr.processSong();
          if (options.isArtistInTrackTitle()
              && (tr.getArtist() != null && !tr.getArtist().isEmpty())
              && (rippedDisc.getArtist() != null && !rippedDisc.getArtist().isEmpty())
              && (!tr.getArtist().equalsIgnoreCase(rippedDisc.getArtist()))) {
            rippedDisc.addTrack(
                new Track(
                    splitPath[splitPath.length - 1],
                    tr.getArtist() + " - " + tr.getTitle(),
                    tr.getArtist()));

          } else {
            if ((tr.getArtist() != null && !tr.getArtist().isEmpty())) {
              rippedDisc.addTrack(
                  new Track(splitPath[splitPath.length - 1], tr.getTitle(), tr.getArtist()));
            } else {
              rippedDisc.addTrack(new Track(splitPath[splitPath.length - 1], tr.getTitle()));
            }
          }
        } catch (Exception e) {
          rippedDisc.addTrack(
              new Track(splitPath[splitPath.length - 1], splitPath[splitPath.length - 1]));
          parentWindow.setStatus(e.getMessage());
          System.out.println(e.getStackTrace());
        }
      } else {
        String trackTitle;
        if (options.isParseTitle()) {
          trackTitle = parseTrackTitle(splitPath[splitPath.length - 1]);
        } else {
          trackTitle = splitPath[splitPath.length - 1];
        }
        rippedDisc.addTrack(new Track(splitPath[splitPath.length - 1], trackTitle));
      }

      okToUseTags = false;
    }
    // add last album
    rippedDiscs.add(rippedDisc);

    // write cue files
    writeCueFiles();
    parentWindow.setStatus("Cue creation complete");
  }
Beispiel #4
-1
  public void edit(final Context context) {

    String album = "*";
    String title = "*";
    String artist = "*";
    String editable = "";
    String typeName = "";
    if (this instanceof Song) {
      Song song = (Song) this;
      title = song.getName();
      album = song.getAlbum().getName();
      artist = song.getArtist().getName();
      editable = title;
      typeName = "track";
    } else if (this instanceof Album) {
      Album a = (Album) this;
      if (a.getArtist().getName().trim().equals("") == false) {
        artist = a.getArtist().getName();
      }
      album = a.getName();
      editable = album;
      typeName = "album";
    } else if (this instanceof Artist) {
      Artist a = (Artist) this;
      artist = a.getName();
      editable = artist;
      typeName = "artist";
    }
    showEditDialog(context, typeName, editable, title, album, artist);
  }