Skip to content

Commit

Permalink
Debug Alpha: implementing iTunes TV specification
Browse files Browse the repository at this point in the history
-organized imports and fixed builds for iTunes TV metadata
  • Loading branch information
kgoncharov committed Sep 1, 2016
1 parent b3bea37 commit 014469d
Show file tree
Hide file tree
Showing 25 changed files with 974 additions and 98 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ configure(project.javaSubprojectList) {
mavenCentral()
jcenter()
flatDir {
dirs '../ttml-java/dist', '../itunes-metadata-film/dist'
dirs '../ttml-java/dist', '../itunes-metadata-film/dist', '../itunes-metadata-tv/dist'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ private ITunesConversionXsdConstants() {
public static final String FILM_METADATA_PACKAGE = "com.apple.itunes.importer.film";
public static final String FILM_METADATA_NAMESPACE = "http://apple.com/itunes/importer";
public static final String FILM_METADATA_ROOT_ELEMENT = "package";
// tv spec
public static final String TV_METADATA_XML_SCHEME = "xsd/metadata/tv5.2-strict.xsd";
public static final String TV_METADATA_PACKAGE = "com.apple.itunes.importer.tv";
public static final String TV_METADATA_NAMESPACE = "http://apple.com/itunes/importer";
public static final String TV_METADATA_ROOT_ELEMENT = "package";

// audiomap.xml
public static final String AUDIOMAP_XML_SCHEME = "xsd/audiomap/itunes-audiomap.xsd";
Expand Down
1 change: 1 addition & 0 deletions itunes-conversion/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ dependencies {
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
compile name: 'ttml-java-1.0'
compile name: 'itunes-metadata-film-5.2'
compile name: 'itunes-metadata-tv-5.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import com.netflix.imfutility.itunes.locale.LocaleValidator;
import com.netflix.imfutility.itunes.mediainfo.SimpleMediaInfoBuilder;
import com.netflix.imfutility.itunes.metadata.MetadataXmlProvider;
import com.netflix.imfutility.itunes.metadata.film.FilmMetadataXmlProvider;
import com.netflix.imfutility.itunes.metadata.tv.TvMetadataXmlProvider;
import com.netflix.imfutility.mediainfo.MediaInfoException;
import com.netflix.imfutility.util.ConversionHelper;
import com.netflix.imfutility.xml.XmlParser;
Expand Down Expand Up @@ -346,7 +346,8 @@ private void initMetadata() throws IOException, XmlParsingException {
File metadataFile = iTunesInputParameters.getMetadataFile();
String vendorId = iTunesInputParameters.getCmdLineArgs().getVendorId();

metadataXmlProvider = new FilmMetadataXmlProvider(metadataFile);
// TODO: make strategy to define provider depends on package type (film or tv)
metadataXmlProvider = new TvMetadataXmlProvider(metadataFile);
metadataXmlProvider.updateVendorId(vendorId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
package com.netflix.imfutility.itunes;

import com.netflix.imfutility.ConversionException;
import com.netflix.imfutility.itunes.audiomap.AudioMapXmlProvider;
import com.netflix.imfutility.itunes.chapters.ChaptersXmlProvider;
import com.netflix.imfutility.itunes.inputparameters.ITunesCmdLineArgs;
import com.netflix.imfutility.itunes.inputparameters.ITunesDefaultTools;
import com.netflix.imfutility.itunes.inputparameters.ITunesInputParameters;
import com.netflix.imfutility.itunes.inputparameters.ITunesInputParametersValidator;
import com.netflix.imfutility.itunes.metadata.film.FilmMetadataXmlCreator;
import com.netflix.imfutility.itunes.audiomap.AudioMapXmlProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -73,6 +73,7 @@ public int process(ITunesCmdLineArgs cmdLineArgs) {
private int processMetadataMode(ITunesInputParameters inputParameters) {
logger.info("Metadata mode\n");
logger.info("Generating a sample Metadata.xml file {}", inputParameters.getCmdLineArgs().getOutput());
// TODO: make using creator depends on package type (film or tv)
FilmMetadataXmlCreator.generateSampleXml(inputParameters.getCmdLineArgs().getOutput());
logger.info("Generated a sample Metadata.xml file: OK");
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.apple.itunes.importer.film.ChapterItem;
import com.apple.itunes.importer.film.File;
import com.apple.itunes.importer.film.NonEmptyLocalizableTextElement;
import com.netflix.imfutility.itunes.metadata.ElemWrapper;

import javax.xml.bind.JAXBContext;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with IMF Conversion Utility. If not, see <http://www.gnu.org/licenses/>.
*/
package com.netflix.imfutility.itunes.metadata;
package com.netflix.imfutility.itunes.metadata.film.wrap;


import com.apple.itunes.importer.film.ObjectFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.apple.itunes.importer.film.Checksum;
import com.apple.itunes.importer.film.File;
import com.netflix.imfutility.itunes.metadata.ElemWrapper;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2016 Netflix, Inc.
*
* This file is part of IMF Conversion Utility.
*
* IMF Conversion Utility is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* IMF Conversion Utility is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with IMF Conversion Utility. If not, see <http://www.gnu.org/licenses/>.
*/
package com.netflix.imfutility.itunes.metadata.tv;

import com.apple.itunes.importer.tv.PackageType;
import com.netflix.imfutility.itunes.metadata.MetadataDescriptor;

import static com.netflix.imfutility.itunes.ITunesConversionXsdConstants.TV_METADATA_NAMESPACE;
import static com.netflix.imfutility.itunes.ITunesConversionXsdConstants.TV_METADATA_PACKAGE;
import static com.netflix.imfutility.itunes.ITunesConversionXsdConstants.TV_METADATA_ROOT_ELEMENT;
import static com.netflix.imfutility.itunes.ITunesConversionXsdConstants.TV_METADATA_XML_SCHEME;

/**
* Metadata descriptor for iTunes tv specification.
*/
public final class TvMetadataDescriptor implements MetadataDescriptor<PackageType> {

public static final TvMetadataDescriptor INSTANCE = new TvMetadataDescriptor();

private TvMetadataDescriptor() {
}

@Override
public Class<PackageType> getMetadataClass() {
return PackageType.class;
}

@Override
public String getMetadataSchema() {
return TV_METADATA_XML_SCHEME;
}

@Override
public String getMetadataPackage() {
return TV_METADATA_PACKAGE;
}

@Override
public String getMetadataNamespace() {
return TV_METADATA_NAMESPACE;
}

@Override
public String getMetadataRoot() {
return TV_METADATA_ROOT_ELEMENT;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2016 Netflix, Inc.
*
* This file is part of IMF Conversion Utility.
*
* IMF Conversion Utility is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* IMF Conversion Utility is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with IMF Conversion Utility. If not, see <http://www.gnu.org/licenses/>.
*/
package com.netflix.imfutility.itunes.metadata.tv;


import com.apple.itunes.importer.tv.ObjectFactory;
import com.apple.itunes.importer.tv.PackageType;
import com.netflix.imfutility.itunes.metadata.tv.builder.TvMetadataXmlSampleBuilder;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.File;

/**
* Provides functionality to generate sample metadata.xml for iTunes tv specification.
*/
public final class TvMetadataXmlCreator {

private TvMetadataXmlCreator() {
}

/**
* Generates sample metadata.xml file.
*
* @param path a path to the output metadata.xml file
*/
public static void generateSampleXml(String path) {
File file = new File(path);
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(TvMetadataDescriptor.INSTANCE.getMetadataClass());
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

JAXBElement<PackageType> metadataJaxb = new ObjectFactory().createPackage(TvMetadataXmlSampleBuilder.buildPackage());
jaxbMarshaller.marshal(metadataJaxb, file);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}

}
Loading

0 comments on commit 014469d

Please sign in to comment.