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
|
uses: dawidd6/action-get-tag@v1
|
||||||
with:
|
with:
|
||||||
strip_v: true
|
strip_v: true
|
||||||
- run: sudo apt-get install tree -y
|
|
||||||
- run: tree .
|
|
||||||
- run: |
|
- run: |
|
||||||
python3 spotube/scripts/update_flathub_version.py ${{ steps.tag.outputs.tag }}
|
python3 spotube/scripts/update_flathub_version.py ${{ steps.tag.outputs.tag }}
|
||||||
- run: cat com.github.KRTirtho.Spotube.yml
|
|
||||||
- uses: EndBug/add-and-commit@v9
|
- uses: EndBug/add-and-commit@v9
|
||||||
with:
|
with:
|
||||||
message: v${{ steps.tag.outputs.tag }} Update
|
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/helpers/get-random-element.dart';
|
||||||
import 'package:spotube/models/Logger.dart';
|
import 'package:spotube/models/Logger.dart';
|
||||||
import 'package:spotube/models/generated_secrets.dart';
|
import 'package:spotube/models/generated_secrets.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
|
|
||||||
final logger = getLogger("GetLyrics");
|
final logger = getLogger("GetLyrics");
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ Future<List?> searchSong(
|
|||||||
|
|
||||||
Future<String?> getLyrics(
|
Future<String?> getLyrics(
|
||||||
String title,
|
String title,
|
||||||
List<String> artist, {
|
List<String> artists, {
|
||||||
required String apiKey,
|
required String apiKey,
|
||||||
bool optimizeQuery = false,
|
bool optimizeQuery = false,
|
||||||
bool authHeader = false,
|
bool authHeader = false,
|
||||||
@ -121,13 +122,31 @@ Future<String?> getLyrics(
|
|||||||
try {
|
try {
|
||||||
final results = await searchSong(
|
final results = await searchSong(
|
||||||
title,
|
title,
|
||||||
artist,
|
artists,
|
||||||
apiKey: apiKey,
|
apiKey: apiKey,
|
||||||
optimizeQuery: optimizeQuery,
|
optimizeQuery: optimizeQuery,
|
||||||
authHeader: authHeader,
|
authHeader: authHeader,
|
||||||
);
|
);
|
||||||
if (results == null) return null;
|
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;
|
return lyrics;
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
logger.e("getLyrics", 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)
|
config = yaml.safe_load(input)
|
||||||
|
|
||||||
# Requires the 2nd VERSION argument to be passed
|
# 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_url = f"https://github.com/{REPO}/releases/download/v{version}/Spotube-linux-x86_64.tar.xz"
|
||||||
tar_sha256 = hashlib.sha256()
|
tar_sha256 = hashlib.sha256()
|
||||||
|
print(f"Downloading file {tar_url} to generete sha256 sum")
|
||||||
tar = requests.get(tar_url)
|
tar = requests.get(tar_url)
|
||||||
for chunk in tar.iter_content():
|
for chunk in tar.iter_content():
|
||||||
if chunk:
|
if chunk:
|
||||||
|
Loading…
Reference in New Issue
Block a user