Etienne Perot  committed 4f321a5

Added --skipgenre and --nodate arguments to skip MP3 genre tag and remove creation date on mktorrent (respectively)

  • Participants
  • Parent commits cdb182e
  • Branches master

Comments (0)

Files changed (1)

 # Default encoding options
 enc_options = {
-	'320':	{'enc': 'lame',  	'opts': '-b 320 --ignore-tag-errors'},
-	'V0':	{'enc': 'lame',		'opts': '-V 0 --vbr-new --ignore-tag-errors'},
-	'V2':	{'enc': 'lame',		'opts': '-V 2 --vbr-new --ignore-tag-errors'},
+	'320':	{'enc': 'lame',  	'opts': '-q 0 -b 320 --ignore-tag-errors'},
+	'V0':	{'enc': 'lame',		'opts': '-q 0 -V 0 --vbr-new --ignore-tag-errors'},
+	'V2':	{'enc': 'lame',		'opts': '-q 0 -V 2 --vbr-new --ignore-tag-errors'},
 	'Q8':	{'enc': 'oggenc',	'opts': '-q 8'},
 	'AAC':	{'enc': 'neroAacEnc',	'opts': '-br 320000'},
 	'ALAC':	{'enc': 'ffmpeg',	'opts': '-i - -acodec alac'},
 		flac_command = ''
 		if enc_options[self.codec]['enc'] == 'lame':
-			flac_command = 'lame -S %s --tt "%s" --tl "%s" --ta "%s" --tn "%s" --tg "%s" --ty "%s" --add-id3v2 - "%s.mp3" 2>&1'
+			if self.options.skip_genre:
+				flac_command = 'lame -S %s --tt "%s" --tl "%s" --ta "%s" --tn "%s" --ty "%s" --add-id3v2 - "%s.mp3" 2>&1'
+			else:
+				flac_command = 'lame -S %s --tt "%s" --tl "%s" --ta "%s" --tn "%s" --tg "%s" --ty "%s" --add-id3v2 - "%s.mp3" 2>&1'
 		elif enc_options[self.codec]['enc'] == 'oggenc':
 			flac_command = 'oggenc -Q %s -t "%s" -l "%s" -a "%s" -N "%s" -G "%s" -d "%s" -o "%s.ogg" - 2>&1'
 		elif enc_options[self.codec]['enc'] == 'ffmpeg':
 		if enc_options[self.codec]['enc'] == 'neroAacEnc':
 			flac_command = flac_command % (escape_quote(enc_options[self.codec]['opts']), escape_quote(mp3_filename), escape_quote(mp3_filename), escape_quote(tags['TITLE']), escape_quote(tags['ALBUM']), escape_quote(tags['ARTIST']), escape_quote(tags['TRACKNUMBER']), escape_quote(tags['GENRE']), escape_quote(tags['DATE']))
-			flac_command = flac_command % (escape_quote(enc_options[self.codec]['opts']), escape_quote(tags['TITLE']), escape_quote(tags['ALBUM']), escape_quote(tags['ARTIST']), escape_quote(tags['TRACKNUMBER']), escape_quote(tags['GENRE']), escape_quote(tags['DATE']), escape_quote(mp3_filename))
+			genre_tag = (escape_quote(tags['GENRE']),)
+			if enc_options[self.codec]['enc'] == 'lame' and self.options.skip_genre:
+				genre_tag = ()
+			params = (escape_quote(enc_options[self.codec]['opts']), escape_quote(tags['TITLE']), escape_quote(tags['ALBUM']), escape_quote(tags['ARTIST']), escape_quote(tags['TRACKNUMBER'])) + genre_tag + (escape_quote(tags['DATE']), escape_quote(mp3_filename))
+			flac_command = flac_command % params
 		if self.options.verbose:
 	parser.add_option('-n', '--notorrent',	action='store_true',	dest='notorrent',	default=False,	help='will not create a torrent after conversion (Default: False)')
 	parser.add_option('--nolog',		action='store_true',	dest='nolog',		default=False,	help='will not move log files after conversion (Default: False)')
 	parser.add_option('--nocue',		action='store_true',	dest='nocue',		default=False,	help='will not move cue files after conversion (Default: False)')
+	parser.add_option('--nodate',           action='store_true',    dest='nodate',          default=False,  help='do not write the creation date to the .torrent file (Default: False)')
+	parser.add_option('--skipgenre',        action='store_true',    dest='skip_genre',      default=False,  help='do not insert a genre tag in MP3 files (Default: False)')
 	parser.add_option('-m', '--moveother',	action='store_true',	dest='moveother',	default=moveother,	help='move additional files (Default: True)')
 	parser.add_option('-p', '--passkey',	dest='passkey',		default=passkey,	help='tracker PASSKEY', metavar='PASSKEY')
 	parser.add_option('-t', '--tracker',	dest='tracker',		default=tracker,	help='tracker URL (Default: "")', metavar='URL')
 			if options.output and options.passkey and options.tracker and not options.notorrent:
 				if options.verbose: print('Creating torrent...')
 				torrent_command = 'mktorrent -p -a %s/announce -o "%s.torrent" "%s"' % (options.tracker + options.passkey, escape_quote(options.output + os.path.basename(flacdir)), escape_quote(flacdir))
+				if options.nodate:
+					torrent_command += ' -d'
 				if options.verbose: print(escape_backtick(torrent_command))