mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
[CD] flathub update_release bugfix
getLyrics now ranks result for maximum match rate
This commit is contained in:
parent
46b5ec7c22
commit
94cec4290c
3
.github/workflows/release-build.yml
vendored
3
.github/workflows/release-build.yml
vendored
@ -216,11 +216,8 @@ jobs:
|
||||
uses: dawidd6/action-get-tag@v1
|
||||
with:
|
||||
strip_v: true
|
||||
- run: sudo apt-get install tree -y
|
||||
- run: tree .
|
||||
- run: |
|
||||
python3 spotube/scripts/update_flathub_version.py ${{ steps.tag.outputs.tag }}
|
||||
- run: cat com.github.KRTirtho.Spotube.yml
|
||||
- uses: EndBug/add-and-commit@v9
|
||||
with:
|
||||
message: v${{ steps.tag.outputs.tag }} Update
|
||||
|
@ -5,6 +5,7 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:spotube/helpers/get-random-element.dart';
|
||||
import 'package:spotube/models/Logger.dart';
|
||||
import 'package:spotube/models/generated_secrets.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
final logger = getLogger("GetLyrics");
|
||||
|
||||
@ -113,7 +114,7 @@ Future<List?> searchSong(
|
||||
|
||||
Future<String?> getLyrics(
|
||||
String title,
|
||||
List<String> artist, {
|
||||
List<String> artists, {
|
||||
required String apiKey,
|
||||
bool optimizeQuery = false,
|
||||
bool authHeader = false,
|
||||
@ -121,13 +122,31 @@ Future<String?> getLyrics(
|
||||
try {
|
||||
final results = await searchSong(
|
||||
title,
|
||||
artist,
|
||||
artists,
|
||||
apiKey: apiKey,
|
||||
optimizeQuery: optimizeQuery,
|
||||
authHeader: authHeader,
|
||||
);
|
||||
if (results == null) return null;
|
||||
String? lyrics = await extractLyrics(Uri.parse(results.first["url"]));
|
||||
final worthyOne = results
|
||||
.map((result) {
|
||||
final gTitle = (result["title"] as String).toLowerCase();
|
||||
int points = 0;
|
||||
final hasTitle = gTitle.contains(title.toLowerCase());
|
||||
final hasAllArtists =
|
||||
artists.every((artist) => gTitle.contains(artist.toLowerCase()));
|
||||
|
||||
for (var criteria in [hasTitle, hasAllArtists]) {
|
||||
if (criteria) points++;
|
||||
}
|
||||
return {"result": result, "points": points};
|
||||
})
|
||||
.sorted(
|
||||
(a, b) => ((b["points"] as int).compareTo(a["points"] as int)),
|
||||
)
|
||||
.first;
|
||||
|
||||
String? lyrics = await extractLyrics(Uri.parse(worthyOne["url"]));
|
||||
return lyrics;
|
||||
} catch (e, stack) {
|
||||
logger.e("getLyrics", e, stack);
|
||||
|
@ -13,10 +13,11 @@ with open(YAML_FILENAME, mode="r", encoding="utf-8") as input:
|
||||
config = yaml.safe_load(input)
|
||||
|
||||
# Requires the 2nd VERSION argument to be passed
|
||||
version = sys.argv[1:][1:]
|
||||
version = sys.argv[1:][0]
|
||||
|
||||
tar_url = f"https://github.com/{REPO}/releases/download/v{version}/Spotube-linux-x86_64.tar.xz"
|
||||
tar_sha256 = hashlib.sha256()
|
||||
print(f"Downloading file {tar_url} to generete sha256 sum")
|
||||
tar = requests.get(tar_url)
|
||||
for chunk in tar.iter_content():
|
||||
if chunk:
|
||||
|
Loading…
Reference in New Issue
Block a user