Fix for issue #1693 (Apply data_source field to albums)#3350
Fix for issue #1693 (Apply data_source field to albums)#3350sampsyo merged 5 commits intobeetbox:masterfrom
data_source field to albums)#3350Conversation
beets/importer.py
Outdated
| self.record_replaced(lib) | ||
| self.remove_replaced(lib) | ||
| self.album = lib.add_album(self.imported_items()) | ||
| self.album.set_parse('data_source', self.imported_items()[0].data_source) |
There was a problem hiding this comment.
How about self.album.data_source = ... instead of using the set_parse method?
|
Thanks for getting this started! Indeed, it does need a check like that to avoid an error when the field is missing. You can see this by running the tests if you want! |
Just a 'curiosity' from running the tests... In addition to the extra Python modules required to run the tests (as listed in Anyway, other than that I just had to comment out the custom output templates in my config file. There was also this error output: which didn't seem important but does perhaps indicate that the test needs to be modified to allow for relative paths (?) starting from mount points other than drive |
Yes, they should indeed be! Maybe a reinstall with
Hmm; interesting! I don't quite see the problem yet, but if you're interested in helping out, perhaps you could try fixing this test in a separate PR! It is, however, suspicious that the test doesn't run into a problem on AppVeyor? |
I just installed them separately with
It's probably only an issue with my particular set-up ... Anyway I'm glad that this PR passes the tests now. |
beets/importer.py
Outdated
| self.record_replaced(lib) | ||
| self.remove_replaced(lib) | ||
| self.album = lib.add_album(self.imported_items()) | ||
| if 'data_source' in self.imported_items()[0].keys(): |
There was a problem hiding this comment.
I think a simpler expression 'data_source' in self.imported_items()[0] should work… any chance you could give that a quick try?
There was a problem hiding this comment.
No worries, all done
...I must admit I had wondered if it was possible that way, but with my inexperience and in my haste I neglected to test it first. Thanks again :)
|
Great! If this indeed seems to fix the problem in your tests, can you please add a quick changeling entry and we'll call this done? ✨ |
|
Changelog updated - since the original request was tagged as a 'feature' I added it under 'New Features' |
|
Looks great; thank you! Just to double check, have you tried importing an album with this to confirm that the fix actually works and the album gets the data source field as intended? If so, then we're good to go! |
|
I did indeed test it, though hardly extensively ... I only tested it with one album import :/ Basically as per the evidence I submitted during the work building towards this PR, I would simply remove an existing album from beets (in this case "How to Destroy Angels") and import it again. I would then perform a search, first for items then for the album, with the |
|
Perfect! Thanks for confirming. And thanks for your work on this! |
This adds the
data_sourcefield (flex-attribute) to Albums during an import, it copies the value from the first Item's corresponding field.Does this need a conditional test to make sure that the Item field exists and actually has a value first?