I have observed that OpenLP sometimes create a new song when a service file is opened.
How does OpenLP decide when to create a new song or when to update a song?
I've studied the service_data.osj file to some extent and it contains the "xml version" of the song.
Will a new song be created if the content of "xml version" changes? When does OpenLP update an existing song?
Does it compute the checksum of any field?
Could someone explain on this please?
I'm working on a feature to export songs from an app in OpenLP Service format.
I'm able to currently generate a OSZL file from the app and OpenLP could open it but a new song is created everytime I open this service file.
I'm stuck on this for quite some time. Appreciate your help. Thank you very much.
Is there any unit test on loading a service which I can have a look at?
Had a look at https://gitlab.com/openlp/openlp/-/blob/master/openlp/plugins/songs/lib/mediaitem.py and it looks like a new song will be added when the authors in the service item doesn't match with the author of an existing song. Is this understanding correct?
Thanks for the excellent unit tests and the clean code you guys have written. I was able to understand how loading the service works by looking at the unit tests and the code.
Managed to solve the issue.
In my case, the issue was in the service_data file created by my app, the [header][data][title] was not formatted in the way OpenLP expects it. I found that this title is set as the "search_title" in the db and so the song importer couldn't find a matching song and hence kept on adding a new song.
Once the [data][title] is set correctly replacing the apostrophes and non-word chars, the service was imported without creating new songs.
Hi @sskjames I'm glad you got it figured out. OpenLP creates songs from the service when the "Import Missing Songs from Service File" option in the Songs section of the settings is checked.
I have found that a song is duplicated if the author field has a comma in it. my workaround was to edit all the authors with commas to hyphens.