Little py script adaptation
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,3 +16,5 @@ dashboard/resultToStudy.json
|
||||
sand_box.py
|
||||
rating_test.py
|
||||
iTunesGraphParser.my.py
|
||||
iTunes Library.xml
|
||||
*.jsonl
|
||||
|
||||
11
Justfile
Normal file
11
Justfile
Normal file
@@ -0,0 +1,11 @@
|
||||
parse:
|
||||
rm -v es-*
|
||||
python3 iTunesParser.py -f iTunes\ Library.xml
|
||||
|
||||
send-all:
|
||||
just send songs
|
||||
just send artists
|
||||
just send albums
|
||||
|
||||
send type:
|
||||
curl -X POST 'localhost:7700/indexes/itunes-{{type}}/documents?primaryKey=Persistent%20ID' -H 'Content-Type: application/json' -H 'Authorization: Bearer aSampleMasterKey' --data-binary @es-{{type}}.json
|
||||
@@ -263,8 +263,8 @@ class WriteElsJson:
|
||||
"index": {"_index": ITunesParser.ARTIST_INDEX, "_id": persistent_id}
|
||||
}
|
||||
|
||||
file_artist.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
file_artist.write(bytes("\n", 'UTF-8'))
|
||||
# file_artist.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
# file_artist.write(bytes("\n", 'UTF-8'))
|
||||
file_artist.write(bytes(json.dumps(artist, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
file_artist.write(bytes("\n", 'UTF-8'))
|
||||
file_artist.close()
|
||||
@@ -284,8 +284,8 @@ class WriteElsJson:
|
||||
"index": {"_index": ITunesParser.ALBUM_INDEX, "_id": persistent_id}
|
||||
}
|
||||
|
||||
file_albums.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
file_albums.write(bytes("\n", 'UTF-8'))
|
||||
# file_albums.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
# file_albums.write(bytes("\n", 'UTF-8'))
|
||||
file_albums.write(bytes(json.dumps(album, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
file_albums.write(bytes("\n", 'UTF-8'))
|
||||
file_albums.close()
|
||||
@@ -301,8 +301,8 @@ class WriteElsJson:
|
||||
"index": {"_index": ITunesParser.SONG_INDEX, "_id": persistent_id}
|
||||
}
|
||||
|
||||
file.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
file.write(bytes("\n", 'UTF-8'))
|
||||
# file.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
# file.write(bytes("\n", 'UTF-8'))
|
||||
file.write(bytes(json.dumps(song, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
file.write(bytes("\n", 'UTF-8'))
|
||||
file.close()
|
||||
@@ -335,9 +335,9 @@ if __name__ == '__main__':
|
||||
itunes_parser = ITunesParser().parse(args.file)
|
||||
|
||||
print("Writing JSON files...")
|
||||
WriteElsJson.write_songs(itunes_parser['songs'], "es-songs.json")
|
||||
WriteElsJson.write_artists(itunes_parser['artists'], "es-artists.json")
|
||||
WriteElsJson.write_albums(itunes_parser['albums'], "es-albums.json")
|
||||
WriteElsJson.write_songs(itunes_parser['songs'], "es-songs.jsonl")
|
||||
WriteElsJson.write_artists(itunes_parser['artists'], "es-artists.jsonl")
|
||||
WriteElsJson.write_albums(itunes_parser['albums'], "es-albums.jsonl")
|
||||
|
||||
print('Done!')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user