-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lyrics Support
- Loading branch information
Showing
32 changed files
with
825 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
`v1.3.1` is a patch release to fix issue #149 | ||
This version adds a few new features and minor bug fixes. | ||
|
||
# Bug fix | ||
✅ `ValueError: Decompressed Data Too Large` error when processing images with large album covers. | ||
# What's new? | ||
|
||
--- | ||
1. Synced lyrics support #126 | ||
2. Lyrics finder plugin (experimental) | ||
3. Context option to search artist or album on streaming platforms | ||
|
||
_See [changelog for `v1.3.0`](https://github.com/swing-opensource/swingmusic/releases/tag/v1.3.0) for all main changes since `v1.2.0`._ | ||
### Lyrics support | ||
|
||
Have fun! | ||
You can now sing along your music with the new lyrics feature. Click the lyrics button in the bottom bar to view lyrics. | ||
|
||
### Lyrics finder plugin | ||
|
||
This experimental will find synced lyrics for you. Go to `settings > plugins` to start using it. When lyrics are found, they will be saved to a lrc file in the same directory as the playing track. | ||
|
||
# Bug fixes | ||
1. Blank page on safari #155 | ||
2. Telemetry has been removed #153 | ||
3. Seeking before playing will maintain the position when playback starts | ||
4. A forgotten few | ||
|
||
_PS: I also attempted to add a cool fullscreen standby view, but I couldn't animate the images when going to the next/prev track, so I ditched it_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from flask import Blueprint, request | ||
|
||
from app.lib.lyrics import ( | ||
get_lyrics, | ||
check_lyrics_file, | ||
get_lyrics_from_duplicates, | ||
get_lyrics_from_tags, | ||
) | ||
|
||
api = Blueprint("lyrics", __name__, url_prefix="") | ||
|
||
|
||
@api.route("/lyrics", methods=["POST"]) | ||
def send_lyrics(): | ||
""" | ||
Returns the lyrics for a track | ||
""" | ||
data = request.get_json() | ||
|
||
filepath = data.get("filepath", None) | ||
trackhash = data.get("trackhash", None) | ||
|
||
if filepath is None or trackhash is None: | ||
return {"error": "No filepath or trackhash provided"}, 400 | ||
|
||
is_synced = True | ||
lyrics, copyright = get_lyrics(filepath) | ||
|
||
if not lyrics: | ||
lyrics, copyright = get_lyrics_from_duplicates(trackhash, filepath) | ||
|
||
if not lyrics: | ||
lyrics, is_synced, copyright = get_lyrics_from_tags(filepath) | ||
|
||
if not lyrics: | ||
return {"error": "No lyrics found"} | ||
|
||
return {"lyrics": lyrics, "synced": is_synced, "copyright": copyright}, 200 | ||
|
||
|
||
@api.route("/lyrics/check", methods=["POST"]) | ||
def check_lyrics(): | ||
data = request.get_json() | ||
|
||
filepath = data.get("filepath", None) | ||
trackhash = data.get("trackhash", None) | ||
|
||
if filepath is None or trackhash is None: | ||
return {"error": "No filepath or trackhash provided"}, 400 | ||
|
||
exists = check_lyrics_file(filepath, trackhash) | ||
|
||
if exists: | ||
return {"exists": exists}, 200 | ||
|
||
exists = get_lyrics_from_tags(filepath, just_check=True) | ||
|
||
return {"exists": exists}, 200 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from flask import Blueprint, request | ||
|
||
from app.db.sqlite.plugins import PluginsMethods | ||
|
||
|
||
api = Blueprint("plugins", __name__, url_prefix="/plugins") | ||
|
||
|
||
@api.route("/", methods=["GET"]) | ||
def get_all_plugins(): | ||
plugins = PluginsMethods.get_all_plugins() | ||
|
||
return {"plugins": plugins} | ||
|
||
|
||
@api.route("/setactive", methods=["GET"]) | ||
def activate_deactivate_plugin(): | ||
name = request.args.get("plugin", None) | ||
state = request.args.get("state", None) | ||
|
||
if not name or not state: | ||
return {"error": "Missing plugin or state"}, 400 | ||
|
||
PluginsMethods.plugin_set_active(name, int(state)) | ||
|
||
return {"message": "OK"}, 200 | ||
|
||
|
||
@api.route("/settings", methods=["POST"]) | ||
def update_plugin_settings(): | ||
data = request.get_json() | ||
|
||
plugin = data.get("plugin", None) | ||
settings = data.get("settings", None) | ||
|
||
if not plugin or not settings: | ||
return {"error": "Missing plugin or settings"}, 400 | ||
|
||
PluginsMethods.update_plugin_settings(plugin_name=plugin, settings=settings) | ||
plugin = PluginsMethods.get_plugin_by_name(plugin) | ||
|
||
return {"status": "success", "settings": plugin.settings} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from flask import Blueprint, request | ||
from app.lib.lyrics import format_synced_lyrics | ||
|
||
from app.plugins.lyrics import Lyrics | ||
from app.utils.hashing import create_hash | ||
|
||
api = Blueprint("lyricsplugin", __name__, url_prefix="/plugins/lyrics") | ||
|
||
|
||
@api.route("/search", methods=["POST"]) | ||
def search_lyrics(): | ||
data = request.get_json() | ||
|
||
trackhash = data.get("trackhash", "") | ||
title = data.get("title", "") | ||
artist = data.get("artist", "") | ||
album = data.get("album", "") | ||
filepath = data.get("filepath", None) | ||
|
||
finder = Lyrics() | ||
|
||
data = finder.search_lyrics_by_title_and_artist(title, artist) | ||
|
||
if not data: | ||
return {"trackhash": trackhash, "lyrics": None} | ||
|
||
perfect_match = data[0] | ||
|
||
for track in data: | ||
i_title = track["title"] | ||
i_album = track["album"] | ||
|
||
if create_hash(i_title) == create_hash(title) and create_hash( | ||
i_album | ||
) == create_hash(album): | ||
perfect_match = track | ||
|
||
track_id = perfect_match["track_id"] | ||
lrc = finder.download_lyrics(track_id, filepath) | ||
|
||
if lrc is not None: | ||
lines = lrc.split("\n") | ||
lyrics = format_synced_lyrics(lines) | ||
|
||
return {"trackhash": trackhash, "lyrics": lyrics}, 200 | ||
|
||
return {"trackhash": trackhash, "lyrics": lrc}, 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.