Check forceBastp and use own ID3v2 reader if true

Also sync with bastp head to get additional vorbis <-> id3v2 mappings
This commit is contained in:
Adrian Ulrich 2017-02-04 11:24:48 +01:00
parent 51a4c0ffeb
commit 56154f21bd
3 changed files with 29 additions and 2 deletions

View File

@ -214,6 +214,10 @@ public class MediaMetadataExtractor extends HashMap<String, ArrayList<String>> {
* True if we consider the file to be a good media item * True if we consider the file to be a good media item
*/ */
private boolean mIsMediaFile = false; private boolean mIsMediaFile = false;
/**
* True if we should try bastp for 'experimental' formats
*/
private boolean mForceBastp = false;
/** /**
* Constructor for MediaMetadataExtractor * Constructor for MediaMetadataExtractor
@ -221,6 +225,17 @@ public class MediaMetadataExtractor extends HashMap<String, ArrayList<String>> {
* @param path the path to scan * @param path the path to scan
*/ */
public MediaMetadataExtractor(String path) { public MediaMetadataExtractor(String path) {
this(path, false);
}
/**
* Constructor for MediaMetadataExtractor
*
* @param path the path to scan
* @param forceBastp always prefer bastp if possible
*/
public MediaMetadataExtractor(String path, boolean forceBastp) {
mForceBastp = forceBastp;
extractMetadata(path); extractMetadata(path);
} }
@ -293,10 +308,17 @@ public class MediaMetadataExtractor extends HashMap<String, ArrayList<String>> {
case "OPUS": case "OPUS":
populateSelf(bastpTags); populateSelf(bastpTags);
break; break;
case "MP3/ID3v2":
// ^-- these tagreaders are not fully stable, but can be enabled on demand
if(mForceBastp) {
populateSelf(bastpTags);
break;
}
// else: fallthrough
default: default:
populateSelf(mediaTags); populateSelf(mediaTags);
convertNumericGenre();
} }
convertNumericGenre();
// We consider this a media file if it has some common tags OR // We consider this a media file if it has some common tags OR
// if bastp was able to parse it (which is stricter than Androids own parser) // if bastp was able to parse it (which is stricter than Androids own parser)

View File

@ -408,7 +408,7 @@ public class MediaScanner implements Handler.Callback {
hasChanged = true; hasChanged = true;
} }
MediaMetadataExtractor tags = new MediaMetadataExtractor(path); MediaMetadataExtractor tags = new MediaMetadataExtractor(path, prefs.forceBastp);
if (!tags.isMediaFile()) { if (!tags.isMediaFile()) {
mustInsert = false; // does not have any useable metadata: won't insert even if it is a playable file mustInsert = false; // does not have any useable metadata: won't insert even if it is a playable file
} }

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2013-2016 Adrian Ulrich <adrian@blinkenlights.ch> * Copyright (C) 2013-2016 Adrian Ulrich <adrian@blinkenlights.ch>
* Copyright (C) 2017 Google Inc.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -115,6 +116,10 @@ public class ID3v2File extends Common {
lu.put("TIT2", "TITLE"); lu.put("TIT2", "TITLE");
lu.put("TALB", "ALBUM"); lu.put("TALB", "ALBUM");
lu.put("TPE1", "ARTIST"); lu.put("TPE1", "ARTIST");
lu.put("TYER", "YEAR");
lu.put("TRCK", "TRACKNUMBER");
lu.put("TCON", "GENRE");
lu.put("TCOM", "COMPOSER");
if(lu.containsKey(k)) { if(lu.containsKey(k)) {
/* A normal, known key: translate into Ogg-Frame name */ /* A normal, known key: translate into Ogg-Frame name */