|
|
|
@ -39,6 +39,7 @@ import java.util.Locale;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.jaudiotagger.audio.AudioFile;
|
|
|
|
|
import org.jaudiotagger.audio.AudioFileIO;
|
|
|
|
|
import org.jaudiotagger.audio.SupportedFileFormat;
|
|
|
|
@ -198,6 +199,8 @@ public class audioTagParser extends AbstractParser implements Parser {
|
|
|
|
|
|
|
|
|
|
/** Map from each supported audio file extensions to a single audio media type */
|
|
|
|
|
private final Map<String, SupportedAudioMediaType> ext2NormalMediaType;
|
|
|
|
|
|
|
|
|
|
private static final char SPACE_CHAR = ' ';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public audioTagParser() {
|
|
|
|
@ -268,35 +271,12 @@ public class audioTagParser extends AbstractParser implements Parser {
|
|
|
|
|
// text
|
|
|
|
|
final List<String> descriptions = new ArrayList<String>(7);
|
|
|
|
|
final StringBuilder text = new StringBuilder(500);
|
|
|
|
|
final char space = ' ';
|
|
|
|
|
if(tag != null) {
|
|
|
|
|
String field = tag.getFirst(FieldKey.ARTIST);
|
|
|
|
|
descriptions.add(FieldKey.ARTIST.name() + ": " + field);
|
|
|
|
|
text.append(field); text.append(space);
|
|
|
|
|
|
|
|
|
|
field = tag.getFirst(FieldKey.ALBUM);
|
|
|
|
|
descriptions.add(FieldKey.ALBUM.name() + ": " + field);
|
|
|
|
|
text.append(field); text.append(space);
|
|
|
|
|
|
|
|
|
|
field = tag.getFirst(FieldKey.TITLE);
|
|
|
|
|
descriptions.add(FieldKey.TITLE.name() + ": " + field);
|
|
|
|
|
text.append(field); text.append(space);
|
|
|
|
|
|
|
|
|
|
field = tag.getFirst(FieldKey.COMMENT);
|
|
|
|
|
descriptions.add(FieldKey.COMMENT.name() + ": " + field);
|
|
|
|
|
text.append(field); text.append(space);
|
|
|
|
|
|
|
|
|
|
field = tag.getFirst(FieldKey.LYRICS);
|
|
|
|
|
descriptions.add(FieldKey.LYRICS.name() + ": " + field);
|
|
|
|
|
text.append(field); text.append(space);
|
|
|
|
|
|
|
|
|
|
field = tag.getFirst(FieldKey.TAGS);
|
|
|
|
|
descriptions.add(FieldKey.TAGS.name() + ": " + field);
|
|
|
|
|
text.append(field); text.append(space);
|
|
|
|
|
|
|
|
|
|
field = tag.getFirst(FieldKey.GENRE);
|
|
|
|
|
descriptions.add(FieldKey.GENRE.name() + ": " + field);
|
|
|
|
|
text.append(field); text.append(space);
|
|
|
|
|
final FieldKey[] fieldsToProcess = new FieldKey[] { FieldKey.ARTIST, FieldKey.ALBUM, FieldKey.TITLE,
|
|
|
|
|
FieldKey.COMMENT, FieldKey.LYRICS, FieldKey.TAGS, FieldKey.GENRE };
|
|
|
|
|
for (final FieldKey field : fieldsToProcess) {
|
|
|
|
|
processTagField(field, tag, descriptions, text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
text.append(location.toTokens());
|
|
|
|
|
|
|
|
|
@ -376,4 +356,27 @@ public class audioTagParser extends AbstractParser implements Parser {
|
|
|
|
|
}
|
|
|
|
|
return docs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Process a tag field : add its value to the descriptions and to text. All
|
|
|
|
|
* parameters must not be null.
|
|
|
|
|
*
|
|
|
|
|
* @param fieldKey
|
|
|
|
|
* a field key
|
|
|
|
|
* @param tag
|
|
|
|
|
* a parsed audio tag
|
|
|
|
|
* @param descriptions
|
|
|
|
|
* the document descriptions to fill
|
|
|
|
|
* @param text
|
|
|
|
|
* the document text to fill
|
|
|
|
|
*/
|
|
|
|
|
private void processTagField(final FieldKey fieldKey, final Tag tag, final List<String> descriptions,
|
|
|
|
|
final StringBuilder text) {
|
|
|
|
|
final String fieldValue = tag.getFirst(fieldKey);
|
|
|
|
|
if(StringUtils.isNotBlank(fieldValue)) {
|
|
|
|
|
descriptions.add(fieldKey.name() + ": " + fieldValue);
|
|
|
|
|
text.append(fieldValue);
|
|
|
|
|
text.append(SPACE_CHAR);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|