本文整理汇总了Python中song.Song.from_path方法的典型用法代码示例。如果您正苦于以下问题:Python Song.from_path方法的具体用法?Python Song.from_path怎么用?Python Song.from_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类song.Song
的用法示例。
在下文中一共展示了Song.from_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_song_route
# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import from_path [as 别名]
def edit_song_route(filename):
"""Route for editing song info."""
relpath = os.path.join(WORKING_DIR, filename)
if request.method == "GET":
song = Song.from_path(relpath)
return render_template("edit.html", song=song)
# POST
cover = request.files.get("cover", None)
tag = eyed3.load(relpath).tag
tag.artist = request.form["artist"]
tag.album = request.form["album"]
tag.title = request.form["title"]
if cover:
# 3 for front cover, 4 for back, 0 for other.
# This is specified in the eyed3 docs.
tag.images.set(3, cover.read(), cover.mimetype)
tag.save()
return redirect(url_for("index_route"))
示例2: index_route
# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import from_path [as 别名]
def index_route():
audio_files = os.listdir(WORKING_DIR)
songs = [Song.from_path(os.path.join(WORKING_DIR, f)) for f in audio_files]
return render_template("index.html",
songs=songs)