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
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) {