[tika] branch branch_1x updated: Changelog update

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/branch_1x by this push:
 new a1ec3fd  Changelog update
a1ec3fd is described below

commit a1ec3fd2c00605864b5c4543d4943abb151c7ef0
Author: Nick Burch 
AuthorDate: Sun Mar 14 20:55:28 2021 +

Changelog update
---
 CHANGES.txt | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 1b2bd7f..6d56a7e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,7 +9,10 @@ Release 1.26 - 03/09/2021
* Fix parsing of emails attached to other emails in PST files (TIKA-3004).
 
* MP3 parser should output the xmpDM:duration metadata as seconds not 
- milliseconds, consistent with the other Audio and Video parsers 
(TIKA-3318)
+ milliseconds, consistent with the other Audio and Video parsers 
(TIKA-3318).
+
+   * MP4 parser check if any of the Compatible Brands match when identifying 
+ the subtype (TIKA-3310).
 
 Release 1.25 - 11/25/2020
 



[tika] branch branch_1x updated: Backport to 1.x - TIKA-3310 Check if MP4 file's compatible brands match any of the expected values, from Peter Kronenberg

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/branch_1x by this push:
 new b0242ee  Backport to 1.x - TIKA-3310 Check if MP4 file's compatible 
brands match any of the expected values, from Peter Kronenberg
b0242ee is described below

commit b0242ee617857fe85db2ba5ce186f6c9965b67bd
Author: Nick Burch 
AuthorDate: Sun Mar 14 20:53:38 2021 +

Backport to 1.x - TIKA-3310 Check if MP4 file's compatible brands match any 
of the expected values, from Peter Kronenberg
---
 .../java/org/apache/tika/parser/mp4/MP4Parser.java | 26 --
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git 
a/tika-parsers/src/main/java/org/apache/tika/parser/mp4/MP4Parser.java 
b/tika-parsers/src/main/java/org/apache/tika/parser/mp4/MP4Parser.java
index 933c53c..f06e556 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/mp4/MP4Parser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/mp4/MP4Parser.java
@@ -70,6 +70,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 
 /**
@@ -132,14 +133,25 @@ public class MP4Parser extends AbstractParser {
 // Grab the file type box
 FileTypeBox fileType = getOrNull(isoFile, FileTypeBox.class);
 if (fileType != null) {
-// Identify the type
-MediaType type = MediaType.application("mp4");
-for (Map.Entry> e : 
typesMap.entrySet()) {
-if (e.getValue().contains(fileType.getMajorBrand())) {
-type = e.getKey();
-break;
-}
+// Identify the type based on the major brand
+Optional typeHolder = typesMap.entrySet()
+.stream()
+.filter(e -> 
e.getValue().contains(fileType.getMajorBrand()))
+.findFirst()
+.map(Map.Entry::getKey);
+
+if (!typeHolder.isPresent()) {
+// If no match for major brand, see if any of the 
compatible brands match
+typeHolder = typesMap.entrySet()
+.stream()
+.filter(e -> e.getValue()
+.stream()
+
.anyMatch(fileType.getCompatibleBrands()::contains))
+.findFirst()
+.map(Map.Entry::getKey);
 }
+
+MediaType type = 
typeHolder.orElse(MediaType.application("mp4"));
 metadata.set(Metadata.CONTENT_TYPE, type.toString());
 
 if (type.getType().equals("audio")) {



[tika] branch main updated (356cf44 -> 4bd931d)

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git.


from 356cf44  TIKA-3318 Document the units of xmpDM:duration as seconds by 
default
 new d80dc36  TIKA-3310 Check if MP4 file's compatible brands match any of 
the expected values
 new 187fd47  TIKA-3310 Check major brand before checking compatible brands
 new 4551f7d  Separate search for major brand and compatible brands
 new 4bd931d  Merge pull request #410 from peterkronenberg/main

The 5072 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/tika/parser/mp4/MP4Parser.java | 35 +++---
 1 file changed, 24 insertions(+), 11 deletions(-)



[tika] branch branch_1x updated: Changelog update

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/branch_1x by this push:
 new a4c9257  Changelog update
a4c9257 is described below

commit a4c92579d2a012e0296f057b70dd9fb2d0842445
Author: Nick Burch 
AuthorDate: Sun Mar 14 20:22:59 2021 +

Changelog update
---
 CHANGES.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/CHANGES.txt b/CHANGES.txt
index 57ca53c..1b2bd7f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,9 @@ Release 1.26 - 03/09/2021

* Fix parsing of emails attached to other emails in PST files (TIKA-3004).
 
+   * MP3 parser should output the xmpDM:duration metadata as seconds not 
+ milliseconds, consistent with the other Audio and Video parsers 
(TIKA-3318)
+
 Release 1.25 - 11/25/2020
 
* Fix inconsistent license in xmpcore (TIKA-3204).



[tika] 02/02: TIKA-3318 MP3 parser should output the xmpDM:duration metadata as seconds not milliseconds

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git

commit 21b3cf8b5a209ab6cf0176d8bc55e640fdc8c351
Author: Nick Burch 
AuthorDate: Sun Mar 14 20:20:14 2021 +

TIKA-3318 MP3 parser should output the xmpDM:duration metadata as seconds 
not milliseconds
---
 .../src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java | 13 -
 .../test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java |  6 +++---
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git 
a/tika-parsers/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java 
b/tika-parsers/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
index 52dad7c..c14b300 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
@@ -69,10 +69,10 @@ public class Mp3Parser extends AbstractParser {
 // Create handlers for the various kinds of ID3 tags
 ID3TagsAndAudio audioAndTags = getAllTagHandlers(stream, handler);
 
-//process as much metadata as possible before
-//writing to xhtml
+// Before we start on the XHTML output, process and store
+//  as much metadata as possible
 if (audioAndTags.duration > 0) {
-metadata.set(XMPDM.DURATION, audioAndTags.duration);
+   metadata.set(XMPDM.DURATION, audioAndTags.durationSeconds());
 }
 
 if (audioAndTags.audio != null) {
@@ -151,7 +151,7 @@ public class Mp3Parser extends AbstractParser {
 xhtml.element("p", tag.getYear());
 xhtml.element("p", tag.getGenre());
 }
-xhtml.element("p", String.valueOf(audioAndTags.duration));
+xhtml.element("p", String.valueOf(audioAndTags.durationSeconds()));
 for (String comment : comments) {
 xhtml.element("p", comment);
 }
@@ -250,7 +250,10 @@ public class Mp3Parser extends AbstractParser {
 private ID3Tags[] tags;
 private AudioFrame audio;
 private LyricsHandler lyrics;
-private float duration;
+private float duration; // Milliseconds
+private float durationSeconds() {
+   return duration / 1000;
+}
 }
 
 }
diff --git 
a/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java 
b/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
index e670809..01fa4f7 100644
--- a/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
+++ b/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
@@ -39,7 +39,7 @@ public class Mp3ParserTest extends TikaTest {
  */
 private static void checkDuration(Metadata metadata, int expected) {
 assertEquals("Wrong duration", expected,
-Math.round(Float.valueOf(metadata.get(XMPDM.DURATION)) / 
1000));
+Math.round(Float.valueOf(metadata.get(XMPDM.DURATION;
 }
 
 /**
@@ -126,7 +126,7 @@ public class Mp3ParserTest extends TikaTest {
 String content = getXML("testMP3id3v1.mp3").xml;
 assertContains("

[tika] branch branch_1x updated (02ed830 -> 21b3cf8)

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a change to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git.


from 02ed830  TIKA-3244: update pax-url-aether
 new 8081e6d  TIKA-3318 Document the units of xmpDM:duration as seconds by 
default
 new 21b3cf8  TIKA-3318 MP3 parser should output the xmpDM:duration 
metadata as seconds not milliseconds

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java |  1 +
 .../src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java | 13 -
 .../test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java |  6 +++---
 3 files changed, 12 insertions(+), 8 deletions(-)



[tika] 01/02: TIKA-3318 Document the units of xmpDM:duration as seconds by default

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git

commit 8081e6da8d34ef9675638699eb2ec6d6145c89d4
Author: Nick Burch 
AuthorDate: Sun Mar 14 19:24:43 2021 +

TIKA-3318 Document the units of xmpDM:duration as seconds by default
---
 tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java 
b/tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java
index ce78145..60a3d1e 100644
--- a/tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java
+++ b/tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java
@@ -173,6 +173,7 @@ public interface XMPDM {
 
 /**
  * "The duration of the media file."
+ * Value is in Seconds, unless xmpDM:scale is also set.
  */
 Property DURATION = Property.externalReal("xmpDM:duration");
 



[tika] branch main updated: TIKA-3318 Document the units of xmpDM:duration as seconds by default

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
 new 356cf44  TIKA-3318 Document the units of xmpDM:duration as seconds by 
default
356cf44 is described below

commit 356cf44e6c426ad4411bb2c8a945597dbac4543c
Author: Nick Burch 
AuthorDate: Sun Mar 14 19:24:43 2021 +

TIKA-3318 Document the units of xmpDM:duration as seconds by default
---
 tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java 
b/tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java
index ce78145..60a3d1e 100644
--- a/tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java
+++ b/tika-core/src/main/java/org/apache/tika/metadata/XMPDM.java
@@ -173,6 +173,7 @@ public interface XMPDM {
 
 /**
  * "The duration of the media file."
+ * Value is in Seconds, unless xmpDM:scale is also set.
  */
 Property DURATION = Property.externalReal("xmpDM:duration");
 



[tika] branch main updated: TIKA-3318 MP3 parser should output the xmpDM:duration metadata as seconds not milliseconds

2021-03-14 Thread nick
This is an automated email from the ASF dual-hosted git repository.

nick pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
 new 31da853  TIKA-3318 MP3 parser should output the xmpDM:duration 
metadata as seconds not milliseconds
31da853 is described below

commit 31da853a5779806b1b83f4709e90ac2e3ac2688e
Author: Nick Burch 
AuthorDate: Sun Mar 14 19:07:02 2021 +

TIKA-3318 MP3 parser should output the xmpDM:duration metadata as seconds 
not milliseconds
---
 .../main/java/org/apache/tika/parser/mp3/Mp3Parser.java| 14 --
 .../java/org/apache/tika/parser/mp3/Mp3ParserTest.java |  8 
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git 
a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
 
b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
index 7a02473..11a7d4b 100644
--- 
a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
+++ 
b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
@@ -70,10 +70,10 @@ public class Mp3Parser extends AbstractParser {
 // Create handlers for the various kinds of ID3 tags
 ID3TagsAndAudio audioAndTags = getAllTagHandlers(stream, handler);
 
-//process as much metadata as possible before
-//writing to xhtml
+// Before we start on the XHTML output, process and store
+//  as much metadata as possible
 if (audioAndTags.duration > 0) {
-metadata.set(XMPDM.DURATION, audioAndTags.duration);
+   metadata.set(XMPDM.DURATION, audioAndTags.durationSeconds());
 }
 
 if (audioAndTags.audio != null) {
@@ -152,7 +152,7 @@ public class Mp3Parser extends AbstractParser {
 xhtml.element("p", tag.getYear());
 xhtml.element("p", tag.getGenre());
 }
-xhtml.element("p", String.valueOf(audioAndTags.duration));
+xhtml.element("p", String.valueOf(audioAndTags.durationSeconds()));
 for (String comment : comments) {
 xhtml.element("p", comment);
 }
@@ -261,7 +261,9 @@ public class Mp3Parser extends AbstractParser {
 private ID3Tags[] tags;
 private AudioFrame audio;
 private LyricsHandler lyrics;
-private float duration;
+private float duration; // Milliseconds
+private float durationSeconds() {
+   return duration / 1000;
+}
 }
-
 }
diff --git 
a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-audiovideo-module/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
 
b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-audiovideo-module/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
index f952c84..ed0b16c 100644
--- 
a/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-audiovideo-module/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
+++ 
b/tika-parsers/tika-parsers-classic/tika-parsers-classic-modules/tika-parser-audiovideo-module/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
@@ -38,8 +38,8 @@ public class Mp3ParserTest extends TikaTest {
  * @param expected the expected duration, rounded as seconds
  */
 private static void checkDuration(Metadata metadata, int expected) {
-assertEquals("Wrong duration", expected,
-Math.round(Float.valueOf(metadata.get(XMPDM.DURATION)) / 
1000));
+assertEquals("Wrong duration", expected, 
+Math.round(Float.valueOf(metadata.get(XMPDM.DURATION;
 }
 
 /**
@@ -124,7 +124,7 @@ public class Mp3ParserTest extends TikaTest {
 String content = getXML("testMP3id3v1.mp3").xml;
 assertContains("