diff --git a/.gitignore b/.gitignore index b3156fa..fb814e8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ dashboard/resultToStudy.json sand_box.py rating_test.py iTunesGraphParser.my.py +iTunes Library.xml +*.jsonl diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..0e0b84e --- /dev/null +++ b/Justfile @@ -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 diff --git a/iTunesParser.py b/iTunesParser.py index ebb54a9..6c04bc0 100644 --- a/iTunesParser.py +++ b/iTunesParser.py @@ -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!')