Adapt iTunesParser.py for Python 3
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
--> Parse library and just do JSON
|
||||
--> Parse library and just do JSON adapted for Elasticsearch
|
||||
|
||||
iTunes Graph Parser
|
||||
|
||||
@@ -210,17 +210,17 @@ defaultOutputFile = os.path.dirname(os.path.realpath(__file__)) + '/es-music-dat
|
||||
# Get options
|
||||
parser = OptionParser(version="%prog 1.0")
|
||||
parser.add_option('-f', '--file', dest='file', type='string',
|
||||
help='iTunes Library XML file path',
|
||||
default=defaultLibraryFile)
|
||||
help='iTunes Library XML file path',
|
||||
default=defaultLibraryFile)
|
||||
parser.add_option('-o', '--output', dest='output', type='string',
|
||||
help='Output to file (default=./js/music-data.json)',
|
||||
default=defaultOutputFile)
|
||||
help='Output to file (default=./js/music-data.json)',
|
||||
default=defaultOutputFile)
|
||||
parser.add_option('-c', '--console', dest='console', action='store_true',
|
||||
help='Output to console instead of file')
|
||||
help='Output to console instead of file')
|
||||
parser.add_option('-p', '--jsonp', dest='jsonp', action='store_true',
|
||||
help='Output in JSON-P format')
|
||||
help='Output in JSON-P format')
|
||||
parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
|
||||
help='Verbose output')
|
||||
help='Verbose output')
|
||||
|
||||
if __name__ == '__main__':
|
||||
(options, args) = parser.parse_args()
|
||||
@@ -235,5 +235,5 @@ if __name__ == '__main__':
|
||||
print(output)
|
||||
else:
|
||||
with io.open(options.output, 'wb') as outfile:
|
||||
outfile.write(output)
|
||||
outfile.write(bytes(output, 'UTF-8'))
|
||||
print('JSON data written to: ' + options.output)
|
||||
|
||||
Reference in New Issue
Block a user