aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2024-01-21 17:54:50 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2024-01-21 17:54:50 +0100
commit4adf8d5182b7ad3720e3160e0f4530547625dbce (patch)
tree57efd7c801e04f011f743f0408e5c3e98002d49b
parente4131beafc0686efe52d57512fdce1bf012fcdaf (diff)
Update genius integration2.0.1
-rw-r--r--Sources/lyricli/lyricli.swift2
-rw-r--r--Sources/lyricli/lyrics_engine.swift8
2 files changed, 6 insertions, 4 deletions
diff --git a/Sources/lyricli/lyricli.swift b/Sources/lyricli/lyricli.swift
index 13f8f18..d5e5b91 100644
--- a/Sources/lyricli/lyricli.swift
+++ b/Sources/lyricli/lyricli.swift
@@ -2,7 +2,7 @@
class Lyricli {
// Version of the application
- static var version = "2.0.0"
+ static var version = "2.0.1"
// Flag that controls whether we should show the track artist and name before
// the lyrics
diff --git a/Sources/lyricli/lyrics_engine.swift b/Sources/lyricli/lyrics_engine.swift
index 620e521..e0752d7 100644
--- a/Sources/lyricli/lyrics_engine.swift
+++ b/Sources/lyricli/lyrics_engine.swift
@@ -73,9 +73,11 @@ class LyricsEngine {
if let data = data {
if let jsonResponse = try? JSONSerialization.jsonObject(with: data) {
if let jsonResponse = jsonResponse as? [String: Any] {
- if let response = jsonResponse["response"] as? [String:Any] {
- if let hits = response["hits"] as? [Any] {
- if let firstHit = hits[0] as? [String: Any] {
+ if let response = jsonResponse["response"] as? [String: Any] {
+ if let hits = response["hits"] as? [[String: Any]] {
+ let filteredHits = hits.filter { $0["type"] as? String == "song" }
+ if filteredHits.count > 0 {
+ let firstHit = hits[0]
if let firstHitData = firstHit["result"] as? [String: Any] {
if let lyricsUrlString = firstHitData["url"] as? String {
if let lyricsUrl = URL(string: lyricsUrlString) {