从亚马逊s3获取音频文件对象

时间:2019-06-25 10:32:51

标签: python amazon-s3 mp3 audioformat eyed3

我想从音频文件中获取音频标签。为此,我使用了eyed3插件。

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

但是我只有音频文件的亚马逊s3 URL。如何从s3 URL获取文件对象?

1 个答案:

答案 0 :(得分:0)

eyed3.load()命令需要一个本地操作系统中文件的路径。

因此,您需要在加载文件之前将文件下载到本地计算机上

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