Getting length of audiobooks
I thought it would be fun to calculate length of each audiobook, as I really like audiobooks. One can listen to them while travelling, falling asleep, walking outside, and many other activities.
To get all of the audiobooks in a folder, I used os.listdir()
and os.path.isdir()
. Then I crawled through the subfolders, and if there was a length of the audio files, I kept the pair folder name / length in a list.
Obtaining the length was just handled by TinyTag or Mutagen modules. Then it’s just summing the length of the individual files (chapters) to get the total duration of the audiobook.
In the end, I converted the output to a markdown table, and keep it in my notes.
The project is done in Python, source code available on Github.