Bug 426460 - File>Import Confusing or Not Functioning
Summary: File>Import Confusing or Not Functioning
Status: RESOLVED NOT A BUG
Alias: None
Product: kid3
Classification: Applications
Component: general (show other bugs)
Version: 3.8.x
Platform: macOS (DMG) macOS
: NOR wishlist
Target Milestone: ---
Assignee: Urs Fleisch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-13 02:18 UTC by Peter G. Becan
Modified: 2020-09-13 17:31 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
contents of the two file mentioned in the comment (427 bytes, text/plain)
2020-09-13 02:18 UTC, Peter G. Becan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter G. Becan 2020-09-13 02:18:43 UTC
Created attachment 131586 [details]
contents of the two file mentioned in the comment

SUMMARY

File>Import not working OR the UI gives no feedback OR I'm no good at following the HELP instructions.


STEPS TO REPRODUCE & OBSERVED RESULT
1. In order to see what a valid import file looks like, I use File>Export with the tags you'll see in the attached file (TAGS section) (good).

2. I create the info you'll see in the attached file (CONTENTS OF tracklist_tracks.txt), matching the tabs and order of columns I saw in the earlier export from Kid3 (okay).

3. I open a new folder with some MP3s.

4. I choose File>Import and the File Import dialog appears (good).

5. I click the From File/Clipboard button and the Import from File/Clipboard dialog appears (good).

6. I choose a format of CSV quoted (the same that I used for the export). I leave the Header field empty. In the Tracks field, I paste the tags that you'll see in the attached file (TAGS section).

7. I click the From File button, select the file (CONTENTS OF tracklist_tracks.txt), and click the Open button. At this point, I'm lost. The Import from File/Clipboard is still in the foreground. No change has occurred in the UI. I was expecting the info from the tracklist_tracks.txt file to be either shown in the File Import dialog, or that the info from the tracklist_tracks.txt file would actually be populated into the tracks in the main window, or something.

8. I guess at the next step, and I click the Close button in the Import from File/Clipboard dialog. Nothing happens. I was expecting maybe that the info would appear in the File Import dialog or that the track info would be populated in the main window.

Am I doing something wrong? Am I doing something out-of-order? Is there a better description somewhere of the steps to follow to import tag info?

EXPECTED RESULT (see the narrative above)


SOFTWARE/OS VERSIONS
macOS: 10.13.6
Qt Version: 5.9.7

ADDITIONAL INFORMATION
attached files.
Comment 1 Urs Fleisch 2020-09-13 10:34:28 UTC
The import format "CSV quoted" can only be used if the export was using the format "CSV quoted" without modifications, and the same is true for other formats which are present in both the import and the export dialogs. You are using a custom format for the export

%{track}\t%{tracks}\t%{title}\t%{artist}\t%{album}\t%{year}\t%{comment}\t%{file}

and therefore you need a corresponding custom format for the import

%{track}([^\r\n\t]*)\t[^\r\n\t]*\t%{title}([^\r\n\t]*)\t%{artist}([^\r\n\t]*)\t%{album}([^\r\n\t]*)\t%{year}([^\r\n\t]*)\t%{comment}([^\r\n\t]*)\t

Note that the import formats are more complicated than the export formats, basically, they are regular expressions with "%{framename}" expressions before the captures to give the name of the frame where the captured values have to be set. Only frames can be imported, other things which can be exported (in your case "tracks" and "file") cannot be imported, in the format given above I have not used a capture group in these positions, just "[^\r\n\t]*\t" to skip the values.

The use of regular expressions makes the import quite flexible but also hard to use. If you just want to import and export CSV files, I recommend using the "Export CSV" and "Import CSV" actions, which are available in the context menu of the file list. These functions are less flexible than the "Export" and "Import" dialogs available from the "File" menu, but they have a few advantages:

- They export and import all frames (not only the set of "standard frames") in all tags (e.g. both ID3v1 and ID3v2).
- They can encompass the files of multiple folders, not only of the current folder.
- The file paths are exported too and when being imported again, they are correctly matched. If no file can be matched, the file paths are ignored, so it is also possible to import after the file names have been changed.

Both actions are realized by QML-scripts, you can find them in qml/script/ExportCsv.qml and qml/script/ImportCsv.qml below the Kid3 installation folder (kid3.app/Contents/Resources/ on macOS). So you could copy these scripts to adapt them to your needs.

To match the columns to the frame names, a header line is needed in the CSV files used by "Import CSV". You could add the following header line to your example tracklist_tracks.txt to make it importable by "Import CSV":

track	Duration	title	artist	album	date	comment	Duration

Note that the fields are separated by TAB characters and the use of "Duration" for the columns which have to be skipped, which is a hack because it can be seen from the source code ImportCSV.qml that columns with header "Duration" are skipped.
Comment 2 Peter G. Becan 2020-09-13 17:31:17 UTC
Thank you for the very quick and thorough response. I now understand that the failure was because I was using an improper custom import format. I can also see that the application might purposely ignoring a bad format and moving on. What got me confused, then, was zero feedback from the application that I was wrong. Having the application point out the errors in my input would be asking be too much. Perhaps when the application applies the import format and gets nothing, it could display a message stating that. So when the user screws up like I did, at least the application lets me know "hey there! I tried your import format and it didn't match anything, so you probably did something wrong" rather than silence, which makes me think that the application isn't working or that there's some other button/command somewhere that had to be clicked/issued in order to execute the import.

Thanks for KID3. I find it to be comprehensive and I really enjoy it.