Commits

Oleg Oshmyan committed 626decc Merge

Merged in improvements by Santino Fuentes

Comments (0)

Files changed (5)

src/AtomicParsley.h

 void ListLanguageCodes();
 
 void ListMediaRatings();
+void ListTVGenreIDValues();
+void ListMovieGenreIDValues();
 const char* Expand_cli_mediastring(const char* cli_rating);
 
 char* ID3GenreIntToString(int genre);
   const char* media_rating_cli_str;
 } m_ratings;
 
+typedef struct {
+  const char* genre_id_movie_string;
+  uint16_t genre_id_movie_value;
+} geIDMovie;
+
+typedef struct {
+  const char* genre_id_tv_string;
+  uint16_t genre_id_tv_value;
+} geIDTV;
+
 enum {
   UNIVERSAL_UTF8,
   WIN32_UTF16
 	{ "Booklet", 11 }
 };
 
+geIDMovie genreidmovie[] = {
+	{ "Action & Adventure", 4401 },
+	{ "Anime", 4402 },
+	{ "Classics", 4403 },
+	{ "Comedy", 4404 },
+	{ "Documentary", 4405 },
+	{ "Drama", 4406 },
+	{ "Foreign", 4407 },
+	{ "Horror", 4408 },
+	{ "Independent", 4409 },
+	{ "Kids & Family", 4410 },
+	{ "Musicals", 4411 },
+	{ "Romance", 4412 },
+	{ "Sci-Fi & Fantasy", 4413 },
+	{ "Short Films", 4414 },
+	{ "Special Interest", 4415 },
+	{ "Thriller", 4416 },
+	{ "Sports", 4417 },
+	{ "Western", 4418 },
+	{ "Urban", 4419 },
+	{ "Holiday", 4420 },
+	{ "Made for TV", 4421 },
+	{ "Concert Films", 4422 },
+	{ "Music Documentaries", 4423 },
+	{ "Music Feature Films", 4424 },
+	{ "Japanese Cinema", 4425 },
+	{ "Jidaigeki", 4426 },
+	{ "Tokusatsu", 4427 },
+	{ "Korean Cinema", 4428 }
+};
+
+geIDTV genreidtv[] = {
+	{ "Comedy", 4000 },
+	{ "Drama", 4001 },
+	{ "Animation", 4002 },
+	{ "Action & Adventure", 4003 },
+	{ "Classic", 4004 },
+	{ "Kids", 4005 },
+	{ "Nonfiction", 4005 },
+	{ "Reality TV", 4007 },
+	{ "Sci-Fi & Fantasy", 4008 },
+	{ "Sports", 4009 },
+	{ "Teens", 4010 },
+	{ "Latino TV", 4011 }
+};
+
 // from William Herrera: http://search.cpan.org/src/BILLH/LWP-UserAgent-iTMS_Client-0.16/lib/LWP/UserAgent/iTMS_Client.pm
 sfIDs storefronts[] = {
 	{ "United States",	143441 },
 	return;
 }
 
+void ListTVGenreIDValues() {
+	uint16_t total_genreidtv = (uint16_t)(sizeof(genreidtv)/sizeof(*genreidtv));
+	fprintf(stdout, "\tAvailable iTunes TV Genre IDs:\n");
+
+	for (uint16_t i = 0; i < total_genreidtv; i++) {
+		fprintf(stdout, "(%u) %s\n", genreidtv[i].genre_id_tv_value, genreidtv[i].genre_id_tv_string);
+	}
+	return;
+}
+
+void ListMovieGenreIDValues() {
+	uint16_t total_genreidmovie = (uint16_t)(sizeof(genreidmovie)/sizeof(*genreidmovie));
+	fprintf(stdout, "\tAvailable iTunes Movie Genre IDs:\n");
+
+	for (uint16_t i = 0; i < total_genreidmovie; i++) {
+		fprintf(stdout, "(%u) %s\n", genreidmovie[i].genre_id_movie_value, genreidmovie[i].genre_id_movie_string);
+	}
+	return;
+}
+
 const char* Expand_cli_mediastring(const char* cli_rating) {
 	const char* media_rating = NULL;
 	uint16_t total_known_ratings = (uint16_t)(sizeof(known_ratings)/sizeof(*known_ratings));
 #define Meta_PurchaseDate        'D'
 #define Meta_apID                'Y'
 #define Meta_cnID                0xC0
+#define Meta_geID                0xC2
 #define Meta_xID                 0xC3
 #define Meta_EncodingTool        0xB7
 #define Meta_EncodedBy           0xC1
 "  --encodedBy    (string)     Set the name of the Person/company who encoded the file\n"
 "  --apID         (string)     Set the Account Name\n"
 "  --cnID         (number)     Set the iTunes Catalog ID (see --longhelp)\n"
+"  --geID         (number)     Set the iTunes Genre ID (see --longhelp)\n"
 "  --xID          (string)     Set the vendor-supplied iTunes xID (see --longhelp)\n"
 "  --gapless      (boolean)    Set the gapless playback flag\n"
 "  --contentRating (string*)   Set tv/mpaa rating (see -rDNS-help)\n"
 "  --encodedBy        ,       (str)    Set the name of the Person/company who encoded the file on the \"\302�enc\" atom\n"
 "  --apID             ,  -Y   (str)    Set the name of the Account Name on the \"apID\" atom\n"
 "  --cnID             ,       (num)    Set iTunes Catalog ID, used for combining SD and HD encodes in iTunes on the \"cnID\" atom\n"
-"                                       (To combine you must set \"hdvd\" atom on one file and must have same \"stik\" on both file)\n"
-"                                       (Must not use \"stik\" of value Movie(0), use Short Film(9))\n"
-"                                       (A bad idea for numbers is from http://www.imdb.com/ listings)\n"
-"                                       (A better idea for numbers is from the iTunes Store URL)\n"
+"\n"
+"                                      To combine you must set \"hdvd\" atom on one file and must have same \"stik\" on both file\n"
+"                                      Must not use \"stik\" of value Movie(0), use Short Film(9)\n"
+"\n"
+"                                      iTunes Catalog numbers can be obtained by finding the item in the iTunes Store.  Once item\n"
+"                                      is found in the iTunes Store right click on picture of item and select copy link.  Paste this link\n"
+"                                      into a document or web browser to display the catalog number ID.\n"
+"\n"
+"                                      An example link for the video Street Kings is:\n"
+"                                      http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewMovie?id=278743714&s=143441\n"
+"                                      Here you can see the cnID is 278743714\n"
+"\n"
+"                                      Alternatively you can use iMDB numbers, however these will not match the iTunes catalog.\n"
+"\n"
+"  --geID             ,       (num)    Set iTunes Genre ID.  This does not necessarily have to match genre.\n"
+"                                      See --genre-movie-id-list and --genre-tv-id-list\n"
+"\n"
 "  --xID              ,       (str)    Set iTunes vendor-supplied xID, used to allow iTunes LPs and iTunes Extras to interact \n"
 "                                            with other content in your iTunes Library\n"
 "  --gapless          ,       (bool)   Sets the gapless playback flag for a track in a gapless album\n"
         } else if (strcmp(argv[1], "--ratings-list") == 0) {
             ListMediaRatings(); exit(0);
 
+        } else if (strcmp(argv[1], "--genre-movie-id-list") == 0) {
+            ListMovieGenreIDValues(); exit(0);
+
+        } else if (strcmp(argv[1], "--genre-tv-id-list") == 0) {
+            ListTVGenreIDValues(); exit(0);
+
         } else if (strcmp(argv[1], "--ID3frames-list") == 0) {
             ListID3FrameIDstrings(); exit(0);
 
         { "encodedBy",        required_argument,  NULL,           Meta_EncodedBy },
         { "apID",             required_argument,  NULL,           Meta_apID },
         { "cnID",             required_argument,  NULL,           Meta_cnID },
+        { "geID",             required_argument,  NULL,           Meta_geID },
         { "xID",              required_argument,  NULL,           Meta_xID },
         { "gapless",          required_argument,  NULL,           Meta_PlayGapless },
         { "sortOrder",        required_argument,  NULL,           Meta_SortOrder } ,
             break;
         }
 
+        case Meta_geID : { // the iTunes Genre ID
+            APar_ScanAtoms(ISObasemediafile);
+            if ( !APar_assert(metadata_style == ITUNES_STYLE, 1, "iTunes Genre ID") ) {
+                break;
+            }
+
+            uint32_t data_value = 0;
+            sscanf(optarg, "%" SCNu32, &data_value );
+
+            AtomicInfo* geIDData_atom = APar_MetaData_atom_Init("moov.udta.meta.ilst.geID.data", optarg, AtomFlags_Data_UInt);
+            APar_Unified_atom_Put(geIDData_atom, NULL, UTF8_iTunesStyle_256glyphLimited, data_value, 32);
+            break;
+        }
+
         case Meta_xID : { // the vendor-supplied iTunes xID
             APar_ScanAtoms(ISObasemediafile);
             if ( !APar_assert(metadata_style == ITUNES_STYLE, 1, "iTunes xID") ) {

tools/iTunMOVI-1.1.pl

+#!/usr/bin/perl
+#
+# build --rDNSatom iTunMOVI data for AtomicParsley and write or print to file
+#
+# by HolyRoses
+#
+# example line from film "Extract"
+# http://www.imdb.com/title/tt1225822/fullcredits
+#
+#./iTunMOVI.pl --cast "Jason Bateman" --cast "Mila Kunis,Kristen Wiig" --directors "Mike Judge" --producers "John Altschuler,Michael Flynn" --studio "Miramax Films" --copy_warning "FBI ANTI-PIRACY WARNING: UNAUTHORIZED COPYING IS PUNISHABLE UNDER FEDERAL LAW." --screenwriters "Mike Judge" --codirectors "Jasmine Alhambra,Maria Mantia" --print
+
+use Getopt::Long;
+#Getopt::Long::Configure ("bundling");
+
+# default values for some items.
+$ripper = "HolyRoses"; 
+$copy_warning = "Help control the pet population. Have your pets spayed or neutered.";
+$studio = "A $ripper Production";
+
+GetOptions (
+	'version' => \$version,
+	'help' => \$help,
+	'print'=> \$print,
+	'write' => \$write,
+	'file=s' => \$file,
+	'copy_warning=s' => \$copy_warning,
+	'studio=s' => \$studio,
+	'cast|actors=s' => \@cast,
+	'directors=s' => \@directors,
+	'codirectors=s' => \@codirectors,
+	'screenwriters=s' => \@screenwriters,
+	'producers=s' => \@producers);
+
+#print help
+if ( $help ) {
+	print << "EOF";
+
+AtomicParsley iTunMOVI writer for Apple TV and iTunes.
+
+The options cast|actors, directors, codirectors, screenwriters, producers can take multiple of the same type.
+
+You can issue --cast "x person"  --cast "y person" or --cast "x person,y person,b person"
+-------------------------------------------------------------------------------------------------------------
+Atom options:
+--copy_warning:		Add copy warning (displayed in iTunes summary page)
+--studio:		Add film studio (displayed on Apple TV)
+--cast|actors:		Add Actors (displayed on Apple TV and iTunes under long description)
+--directors:		Add Directors (displayed on Apple TV and iTunes under long description)
+--producers:		Add Producers (displayed on Apple TV and iTunes under long description)
+--codirectors:		Add Co-Directors (displayed in iTunes under long description)
+--screenwriters:	Add ScreenWriters (displayed in iTunes under long description)
+
+Write and print options:
+--print:		Display XML data to screen
+--file:			MP4 file to write XML information to
+--write:		Write XML data to MP4 file with AtomicParlsey
+
+Misc options:
+--version:		Displays version
+--help:			Displays help
+-------------------------------------------------------------------------------------------------------------
+If there is more than 1 entry of cast, directors, producers, codirectors, screenwriters then in iTunes the verbage changes to plural. (PRODUCER -> PRODUCERS).
+
+Apple TV display items:
+Actors, Directors, Producers are displayed for Movies.
+Actors are displayed for TV shows.
+Studio is displayed on all videos (while video is playing press up arrow 2x, it is located under Title).
+
+EOF
+exit;
+}
+
+# version
+$version_number = "1.1";
+
+if ( $version ) {
+	print "\n$0 v$version_number\n\n";
+	print "Written by HolyRoses\n\n";
+	exit;
+}
+
+
+# process arrays, join multiple --options of same type and join options seperated by commas
+@cast = split(/,/,join(',',@cast));
+@directors = split(/,/,join(',',@directors));
+@producers = split(/,/,join(',',@producers));
+@codirectors = split(/,/,join(',',@codirectors));
+@screenwriters = split(/,/,join(',',@screenwriters));
+
+# set header
+$iTunMOVI_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+";
+
+# set copy-warning
+$iTunMOVI_data .= "	<key>copy-warning</key>
+	<string>$copy_warning</string>
+";
+# set studio
+$iTunMOVI_data .= "	<key>studio</key>
+	<string>$studio</string>
+";
+
+# assigned a default producer
+if ($producers[0] eq '') {
+	@producers = ("$ripper");
+}
+
+# Process cast array
+if ($cast[0] ne '') {
+	$iTunMOVI_data .= "	<key>cast</key>
+	<array>
+";
+}
+
+foreach $actor (@cast) {
+	$iTunMOVI_data .= "		<dict>
+			<key>name</key>
+			<string>$actor</string>
+		</dict>
+";
+}
+
+if ($cast[0] ne '') {
+	$iTunMOVI_data .= "	</array>
+";
+}
+
+# Process directors array
+if ($directors[0] ne '') {
+	$iTunMOVI_data .= "	<key>directors</key>
+	<array>
+";
+}
+
+foreach $director (@directors) {
+	$iTunMOVI_data .= "		<dict>
+			<key>name</key>
+			<string>$director</string>
+		</dict>
+";
+}
+
+if ($directors[0] ne '') {
+	$iTunMOVI_data .= "	</array>
+";
+}
+
+# Process producers array
+if ($producers[0] ne '') {
+	$iTunMOVI_data .= "	<key>producers</key>
+	<array>
+";
+}
+
+foreach $producer (@producers) {
+	$iTunMOVI_data .= "		<dict>
+			<key>name</key>
+			<string>$producer</string>
+		</dict>
+";
+}
+
+if ($producers[0] ne '') {
+	$iTunMOVI_data .= "	</array>
+";
+}
+
+# Process codirectors array
+if ($codirectors[0] ne '') {
+	$iTunMOVI_data .= "	<key>codirectors</key>
+	<array>
+";
+}
+
+foreach $codirector (@codirectors) {
+	$iTunMOVI_data .= "		<dict>
+			<key>name</key>
+			<string>$codirector</string>
+		</dict>
+";
+}
+
+if ($codirectors[0] ne '') {
+	$iTunMOVI_data .= "	</array>
+";
+}
+
+# Process screenwriters array
+if ($screenwriters[0] ne '') {
+	$iTunMOVI_data .= "	<key>screenwriters</key>
+	<array>
+";
+}
+
+foreach $screenwriter (@screenwriters) {
+	$iTunMOVI_data .= "		<dict>
+			<key>name</key>
+			<string>$screenwriter</string>
+		</dict>
+";
+}
+
+if ($screenwriters[0] ne '') {
+	$iTunMOVI_data .= "	</array>
+";
+}
+
+# set footer
+$iTunMOVI_data .= "</dict>
+</plist>
+";
+
+# print output
+if ( $print ) {
+	print "$iTunMOVI_data\n";
+}
+
+# check if file they want to write to can be opened
+if ( $file ) {
+	open(FILE, "$file") or die "Cannot open file <$file>: $!";
+	close(FILE);
+}
+
+# do the AtomicParsley write
+if ( $file && $write ) {
+	`AtomicParsley \"$file\" --rDNSatom \'$iTunMOVI_data\' name=iTunMOVI domain=com.apple.iTunes --overWrite`;
+}