Search code examples
pythonamazon-s3mp3audioformateyed3

get audio file object from amazon s3


I want to get audio tags from an audio file. For that, I use eyed3 plugin.

import eyed3
mp3_file = "The_File_Path"
audiofile = eyed3.load(mp3_file)
year = audiofile.tag.getBestDate()

But I have only the amazon s3 URL of the audio file. How can I get the file object from the s3 URL?


Solution

  • The eyed3.load() command requires a path to a file in the local operating system.

    Therefore, you will need to download the file to the local machine before loading it:

    import boto3
    s3_client = boto3.resource('s3', region='us-west-2')
    s3_client.download_file('my-bucket', 'music.mp3', '/tmp/music.mp3')