aboutsummaryrefslogtreecommitdiff
path: root/Sources
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2017-05-17 23:23:18 -0500
committerBen Beltran <ben@nsovocal.com>2017-05-17 23:23:18 -0500
commita968bff7e21c9372deca5fce5921999b45d5d348 (patch)
treebca17656820ba12db12a63f7d94764a857a5a8c7 /Sources
parentcadf28c5831b225abf9da650127659c0b0bf6e39 (diff)
Simulate lyrics engine
Diffstat (limited to 'Sources')
-rw-r--r--Sources/lyricli.swift28
-rw-r--r--Sources/lyrics_engine.swift20
-rw-r--r--Sources/main.swift2
-rw-r--r--Sources/source_manager.swift2
-rw-r--r--Sources/track.swift6
5 files changed, 46 insertions, 12 deletions
diff --git a/Sources/lyricli.swift b/Sources/lyricli.swift
index d55b500..c44a7f4 100644
--- a/Sources/lyricli.swift
+++ b/Sources/lyricli.swift
@@ -2,23 +2,33 @@
public class Lyricli {
public static var version = "0.0.0-feature/option-parsing"
+ public static var showTitle = false
+
public static func printLyrics() {
let sourceManager = SourceManager()
if let currentTrack = sourceManager.currentTrack {
- print(currentTrack.artist)
- print(currentTrack.name)
+
+ let engine = LyricsEngine(withTrack: currentTrack)
+
+ if let lyrics = engine.lyrics {
+ if showTitle {
+ printTitle(currentTrack)
+ }
+
+ print(lyrics)
+ }
+ else {
+ print("Lyrics not found :(")
+ }
+
}
else {
- print("Current track not found")
+ print("No Artist/Song could be found :(")
}
}
- public static func printTitle() {
- print("Getting Song Title: Not yet implemented")
- }
-
public static func printSources() {
print("Listing Sources: Not yet implemented")
}
@@ -34,4 +44,8 @@ public class Lyricli {
public static func resetSource(_ sourceName: String) {
print("Reset source \(sourceName): Not yet implemented")
}
+
+ private static func printTitle(_ track: Track) {
+ print("\(track.artist) - \(track.name)")
+ }
}
diff --git a/Sources/lyrics_engine.swift b/Sources/lyrics_engine.swift
new file mode 100644
index 0000000..661ce86
--- /dev/null
+++ b/Sources/lyrics_engine.swift
@@ -0,0 +1,20 @@
+/// Looks for lyrics on the internet
+class LyricsEngine {
+
+ let track: Track
+
+ var lyrics: String? {
+ get {
+ if track.artist == "test" && track.name == "test" {
+ return "Doo doo doo"
+ }
+
+ return nil
+ }
+ }
+
+ init(withTrack targetTrack: Track) {
+
+ track = targetTrack
+ }
+}
diff --git a/Sources/main.swift b/Sources/main.swift
index 0ae48bc..e4b2760 100644
--- a/Sources/main.swift
+++ b/Sources/main.swift
@@ -80,7 +80,7 @@ func main() {
if let titleFlag = flags["title"] as? BoolOption {
if titleFlag.value == true {
- Lyricli.printTitle()
+ Lyricli.showTitle = true
}
}
diff --git a/Sources/source_manager.swift b/Sources/source_manager.swift
index d0af817..dd956ad 100644
--- a/Sources/source_manager.swift
+++ b/Sources/source_manager.swift
@@ -1,5 +1,5 @@
/// Manages the different sources. Keeps track of them, lists and toggles
-public class SourceManager {
+class SourceManager {
private var availableSources: [String: Source] = [
"arguments": ArgumentsSource()
diff --git a/Sources/track.swift b/Sources/track.swift
index efc09f4..d2a9047 100644
--- a/Sources/track.swift
+++ b/Sources/track.swift
@@ -1,7 +1,7 @@
/// Contains the artist and name of a track
-public class Track {
- public let name: String
- public let artist: String
+class Track {
+ let name: String
+ let artist: String
init(withName trackName: String, andArtist trackArtist: String) {