(scripts) Adapat generation & sending scripts
This commit is contained in:
@@ -66,7 +66,10 @@ class ITunesParser:
|
||||
"""
|
||||
Parse an iTunes Library and produce JSON - for ELS
|
||||
"""
|
||||
ELS_INDEX_NAME = "itunessongs"
|
||||
SONG_INDEX = 'itunes-songs'
|
||||
ALBUM_INDEX = 'itunes-albums'
|
||||
ARTIST_INDEX = 'itunes-artists'
|
||||
# TODO Put variables in a config files or in a python library
|
||||
|
||||
def __init__(self):
|
||||
self._tracks = {}
|
||||
@@ -249,7 +252,7 @@ class WriteElsJson:
|
||||
artist['Rating'] = round(artist['Rating'])
|
||||
|
||||
json_track_index = {
|
||||
"index": {"_index": ITunesParser.ELS_INDEX_NAME, "_type": "artist", "_id": persistent_id}
|
||||
"index": {"_index": ITunesParser.ARTIST_INDEX, "_id": persistent_id}
|
||||
}
|
||||
|
||||
file_artist.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
@@ -270,7 +273,7 @@ class WriteElsJson:
|
||||
album['Rating'] = round(album['Rating'])
|
||||
|
||||
json_track_index = {
|
||||
"index": {"_index": ITunesParser.ELS_INDEX_NAME, "_type": "album", "_id": persistent_id}
|
||||
"index": {"_index": ITunesParser.ALBUM_INDEX, "_id": persistent_id}
|
||||
}
|
||||
|
||||
file_albums.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
@@ -287,7 +290,7 @@ class WriteElsJson:
|
||||
file = io.open(output_file, 'wb')
|
||||
for persistent_id, song in songs.items():
|
||||
json_track_index = {
|
||||
"index": {"_index": ITunesParser.ELS_INDEX_NAME, "_type": "song", "_id": persistent_id}
|
||||
"index": {"_index": ITunesParser.SONG_INDEX, "_id": persistent_id}
|
||||
}
|
||||
|
||||
file.write(bytes(json.dumps(json_track_index, indent=None, cls=SetEncoder), 'UTF-8'))
|
||||
|
||||
Reference in New Issue
Block a user