You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2021/07/01 15:34:04 UTC
[tika] branch main updated: mp4parser clean up
This is an automated email from the ASF dual-hosted git repository.
tallison 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 27202a2 mp4parser clean up
27202a2 is described below
commit 27202a2e35ee4745f169e4fe5f8535a3424a2d91
Author: tallison <ta...@apache.org>
AuthorDate: Thu Jul 1 11:33:37 2021 -0400
mp4parser clean up
---
.../apache/tika/parser/mp4/ISO6709Extractor.java | 93 ----------------------
.../java/org/apache/tika/parser/mp4/MP4Parser.java | 5 +-
2 files changed, 1 insertion(+), 97 deletions(-)
diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp4/ISO6709Extractor.java b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp4/ISO6709Extractor.java
deleted file mode 100644
index 4e232ef..0000000
--- a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp4/ISO6709Extractor.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.mp4;
-
-import java.io.Serializable;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.tika.metadata.Metadata;
-
-class ISO6709Extractor implements Serializable {
- //based on: https://en.wikipedia.org/wiki/ISO_6709
- //strip lat long -- ignore crs for now
- private static final Pattern ISO6709_PATTERN =
- Pattern.compile("\\A([-+])(\\d{2,6})(\\.\\d+)?([-+])(\\d{3,7})(\\.\\d+)?");
-
- //must be thread safe
- public void extract(String s, Metadata m) {
- if (s == null) {
- return;
- }
- Matcher matcher = ISO6709_PATTERN.matcher(s);
- if (matcher.find()) {
- String lat = getLat(matcher.group(1), matcher.group(2), matcher.group(3));
- String lng = getLng(matcher.group(4), matcher.group(5), matcher.group(6));
- m.set(Metadata.LATITUDE, lat);
- m.set(Metadata.LONGITUDE, lng);
- } else {
- //ignore problems for now?
- }
-
- }
-
- private String getLng(String sign, String integer, String flot) {
- String flotNormed = (flot == null) ? "" : flot;
- if (integer.length() == 3) {
- return sign + integer + flotNormed;
- } else if (integer.length() == 5) {
- return calcDecimalDegrees(sign, integer.substring(0, 3),
- integer.substring(3, 5) + flotNormed);
- } else if (integer.length() == 7) {
- return calcDecimalDegrees(sign, integer.substring(0, 3), integer.substring(3, 5),
- integer.substring(5, 7) + flotNormed);
- } else {
- //ignore problems for now?
- }
- return "";
- }
-
- private String getLat(String sign, String integer, String flot) {
- String flotNormed = (flot == null) ? "" : flot;
- if (integer.length() == 2) {
- return sign + integer + flotNormed;
- } else if (integer.length() == 4) {
- return calcDecimalDegrees(sign, integer.substring(0, 2),
- integer.substring(2, 4) + flotNormed);
- } else if (integer.length() == 6) {
- return calcDecimalDegrees(sign, integer.substring(0, 2), integer.substring(2, 4),
- integer.substring(4, 6) + flotNormed);
- } else {
- //ignore problems for now?
- }
- return "";
- }
-
- private String calcDecimalDegrees(String sign, String degrees, String minutes) {
- double d = Integer.parseInt(degrees);
- d += (Double.parseDouble(minutes) / 60);
- return sign + String.format(Locale.ROOT, "%.8f", d);
- }
-
- private String calcDecimalDegrees(String sign, String degrees, String minutes, String seconds) {
- double d = Integer.parseInt(degrees);
- d += (Double.parseDouble(minutes) / 60);
- d += (Double.parseDouble(seconds) / 3600);
- return sign + String.format(Locale.ROOT, "%.8f", d);
- }
-}
diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp4/MP4Parser.java b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp4/MP4Parser.java
index 730e0ea..d49941f 100644
--- a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp4/MP4Parser.java
+++ b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-audiovideo-module/src/main/java/org/apache/tika/parser/mp4/MP4Parser.java
@@ -61,8 +61,7 @@ import org.apache.tika.utils.StringUtils;
* Parser for the MP4 media container format, as well as the older
* QuickTime format that MP4 is based on.
* <p>
- * This uses the MP4Parser project from http://code.google.com/p/mp4parser/
- * to do the underlying parsing
+ * This uses Drew Noakes' metadata-extractor: https://github.com/drewnoakes/metadata-extractor
*/
public class MP4Parser extends AbstractParser {
/**
@@ -89,8 +88,6 @@ public class MP4Parser extends AbstractParser {
typesMap.put(MediaType.application("mp4"), Collections.emptyList());
}
- private ISO6709Extractor iso6709Extractor = new ISO6709Extractor();
-
public Set<MediaType> getSupportedTypes(ParseContext context) {
return SUPPORTED_TYPES;
}