aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {