Moved media file scanning logic into its own file.