Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Cleaning and Invalid Audiofiles Handling #27

Merged
merged 9 commits into from Feb 13, 2019

Conversation

sezanzeb
Copy link
Contributor

@sezanzeb sezanzeb commented Feb 12, 2019

1. gtk tool, add folder and broken/non audiofiles

When I put a text file into the sound source directory and renamed it to foobar.flac, no other flac files from other subdirectories were added if this textfile was the first .flac file seen. This was caused, because the TypeFinder only looked at one single sample of .flac files to detect the mime type. Hence the .flac type was not added to the list of accepted file extensions.

This change checks the mime type of all the sound files instead in order to find out which ones are broken. After this fix, all the .flac files are added to the list for conversion except those that don't contain sound (those for which gstreamer throws errors)

This increases the time to read in large folders, but it is the way for integrity, which is the first priority when handling files. Also, reading in the files is still fast compared to the conversion. Because of this longer required time for reading in files, the statusbar now also shows the progress of reading in the files.

An Error message appears to show how many files (only those with audio extensions) failed. The ErrorDialog apperance was also fixed.

old:
old_dialog

new:
new_dialog

After reading this message, the user can decide whether or not to start the conversion.

2. Cleanup Changelog

  • added some docstrings
  • removed a dead path from .gitignore
  • removed 7 year old TODO file in a foreign language. If those TODOs are still relevant, can you please create issues in github in english?
  • added building and installation information to readme
  • used vulture and removed some unused variables and imports (after checking if it really is unused)
  • added missing whitespaces after commas in lists and functions
  • formatted docstring whitespaces into a uniform format across all python files
  • removed all trailing whitespaces in python files

3. soundconverter.py

  • moved imports and such things to the top, dividing it from the mode, command line arg and settings handling. It is considered better practice to have them on the top.
  • if from soundconverter.ui import gui_main fails, it would switch to batch mode. However, this would start conversion immediatelly, either with no command line arguments at all or some files, which would convert all the files into their folders without further user configuration. This is sudden unexpected behaviour and therefore I would rather go a different way. The import of gui_main will fail if there is an e.g. syntax error in that file. So the proper way would be not make sure gui_main doesn't throw errors upon importing. I moved this import to the top.
  • grouped batch options in --help using an OptionParser group. Also some modifications to the help output for batch parameters.

@sezanzeb sezanzeb closed this Feb 12, 2019
@sezanzeb sezanzeb reopened this Feb 12, 2019
@sezanzeb
Copy link
Contributor Author

sezanzeb commented Feb 12, 2019

Gonna add a menu entry to the dropdown to open the list of the broken files later on, for the user to see more easily what was broken

@sezanzeb
Copy link
Contributor Author

sezanzeb commented Feb 12, 2019

Gonna add a menu entry to the dropdown to open the list of the broken files later on, for the user to see more easily what was broken

added the described feature:

couldnotread
invalidfiles

clear list also clears the list of invalid files. The displayed list is a TextView, so that the list can be easily copied and saved elsewhere if desired.

listinvalid

@sezanzeb sezanzeb changed the title Code Cleaning and Broken Audiofiles Handling Code Cleaning and Invalid Audiofiles Handling Feb 12, 2019
s = ''
if broken_audiofiles > 1:
s = 's'
show_error('{} audiofile{} could not be read by gstreamer!'.format(broken_audiofiles, s),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be very problematic to translate.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to use ngettext() for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in fd17384

@kassoulet kassoulet merged commit d6a108a into kassoulet:py3k Feb 13, 2019
@kassoulet
Copy link
Owner

Well done. Thank you!

sezanzeb pushed a commit to sezanzeb/soundconverter that referenced this pull request Jun 20, 2020
Code Cleaning and Invalid Audiofiles Handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants