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