So to not forget it i am posting this here as some sort of tutorial if anyone ever googles for that kind of stuff sicne i did not find anything.
What i was trying to do is add a huge list of Artists to a AutoPlaylist, so build some sort of Genre playlists.
since i wanted to add a few hundred artists to multiple Plalists the manual way was not really an option. So this is what i did:
(you need python3 to run this in the end)
1. Download SQLite Data Browser (Portable) to view and Edit the MediaMonkey.DB file
https://sqlitebrowser .org/dl/
2. Made a backup of my Database... Cant stress that enough. just copy it to some different location
3. Made Sure MediaMonkey was closed and opened the MM5.DB file with SQLiteBrowser
This gives you an overview over all the Database Tables. The Scructure can be ignored, we need to switch to the second Tab. Should be called View/Search Data (sorry mine is in german so not sure how the UI translates)
Over the Fields you can find a Dropdown Menu where it should start at Albums, but you need to switch to "Playlists"
4. When you have the Playlists table opened up you should see a spreadsheet like view of the Table contents, it should be easy for you to identify the Playlist you want to edit by their names.
Open up some sort of Text Editor (Windows one is fine, but something like VS Code gives you a bit of Highlighting colors and stuff)
copy and paste the contents of QueryData into the text editor, should look somethink like
Code: Select all
[Common]
QueryVersion=1
QueryType=2
CollectionID=-1
QuickSearch=0
[Basic]
SongTitle=
Artist=
Composer=
Album=
Genre=
Comment=
Lyrics=
AnyField=
YearFrom=0
YearTo=0
LevelFrom=-999999
LevelTo=-999999
Unleveled=0
SortOrder1=
SortOrder2=
SortOrder3=
[Adv]
ConditionsCount=239
OrdersCount=0
LimitTop=0
Top=50
LimitMB=0
MaxMB=650
LimitLen=0
MaxLen=74
LimitOrderIndex=7
UseORcon=1
RandomSortNumber=0.56
[AdvCond1]
DBField=Artists.Artist
DBFieldPerType=1
Condition=2
Value=Enzo
Value2=
nestOperator=or
nestLevel=0
isOperator=0
bypass=0
[AdvCond2]
DBField=Artists.Artist
DBFieldPerType=1
Condition=2
Value=KAYAN
Value2=
nestOperator=or
nestLevel=0
isOperator=0
bypass=0
but if you look at the lines:
Code: Select all
[Adv]
ConditionsCount=239
In a second text editor window do the same for the field
QueryDataJSON
Code: Select all
{
"collection": "Gesamtes Archiv",
"conditions": {
"autoSortString": "",
"data": [
{
"field": "artist",
"operator": "contains",
"value": "Enzo"
},
{
"field": "artist",
"operator": "contains",
"value": "KAYAN"
}
]
},
"matchAllCriteria": false
}
So now th fun part.
5. You need a list of artists for that, just a simple list where you have one artist per line,
save that as a file called input.txt
6. if you don't have it installed, now is a gut time to install python3 on your system since you will need it for the script:
save the following script as generator .py inside the same folder where you have saved your input.txt file
Code: Select all
import json
def generate_json_file(field, operator, values):
conditions = []
for value in values:
condition = {"field": field, "operator": operator, "value": value.strip()}
conditions.append(condition)
with open('output.json', 'w') as json_file:
json.dump(conditions, json_file, indent=2)
def generate_text_file(starting_number, field, operator, values):
with open('output.txt', 'w') as text_file:
for i, value in enumerate(values):
text_file.write(f'[AdvCond{starting_number + i}]\n')
text_file.write(f'DBField={field}\n')
text_file.write('DBFieldPerType=1\n')
text_file.write('Condition=2\n')
text_file.write(f'Value={value.strip()}\n')
text_file.write('Value2=\n')
text_file.write('nestOperator=or\n')
text_file.write('nestLevel=0\n')
text_file.write('isOperator=0\n')
text_file.write('bypass=0\n\n')
def main():
field = input('Enter the field: ')
operator = input('Enter the operator: ')
with open('input.txt', 'r') as input_file:
values = input_file.readlines()
starting_number = int(input('Enter the starting number for text file: '))
generate_json_file(field, operator, values)
generate_text_file(starting_number, 'Artists.Artist', operator, values)
if __name__ == "__main__":
main()
Remember QueryData? If you have already popupated the palylist like in my example and want to add artists to it you need to start with the next number after the [AdvCondX] that is already present. In my example the starting number would be 3
when you run the script it will generate a output.json file and a output.txt file.
7. Open the output.txt file in a text editor and copy the content at the end of the file you created with the content of the QueryData Field and change the line:
Code: Select all
[Adv]
ConditionsCount=239
8. open the output.json file, it starts and ends with [Brackets], those need to be deleted.
Check out your QueryDataJSON file that cou created before, copy the content of output.json to the existing data but beware to place it just after the last existing value before the cloing bracket] and add a comma to the existing value before you copy the rest
9. copy the changed content back into the fields inside SQLiteDataBrowser and write the cahnges. now you should be able to open mediamonkey again and see the changes.
I am aware that this is not a well written tutorial and might be a bit problematic to follow, it might even cause demage to your MediaMonkey installation, so please check that you created a backup of your database and roll back to that if anything strange happens.
And if anyone has some suggestions to make this easier pleas post them Also if this is the wrong froum or bad content just delete it