Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added song's Url to page's source #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions internal/lyricfier/general.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package lyricfier

import (
"github.com/emilioastarita/lyricfier2/internal/search"
"regexp"
"strings"

"github.com/emilioastarita/lyricfier2/internal/search"
)

type Song struct {
Expand All @@ -13,12 +14,14 @@ type Song struct {
Lyric string `json:"lyric"`
LyricFound bool `json:"found"`
Source string `json:"source"`
SourceUrl string `json:"sourceUrl"`
}

type SearchResult struct {
Found bool
Lyric string
Source string
Found bool
Lyric string
Source string
SourceUrl string
}

type AppData struct {
Expand Down Expand Up @@ -92,20 +95,22 @@ func (h *Main) ReceiveLyric(newLyric *SearchResult) {
h.AppData.Song.Lyric = newLyric.Lyric
h.AppData.Song.LyricFound = newLyric.Found
h.AppData.Song.Source = newLyric.Source
h.AppData.Song.SourceUrl = newLyric.SourceUrl
h.server.NotifyChanges()
}

func (h *Main) Search(done chan *SearchResult, artist string, title string) {
s := &SearchResult{Found: false}
s.Source = "Wikia"
lyric, e := search.Wikia(artist, normalizeTitle(title))
lyric, SourceUrl, e := search.Wikia(artist, normalizeTitle(title))
if e != nil || lyric != "" {
s.Source = "Genius"
lyric, e = search.Genius(artist, normalizeTitle(title))
lyric, SourceUrl, e = search.Genius(artist, normalizeTitle(title))
}
if lyric != "" {
s.Found = true
s.Lyric = lyric
s.SourceUrl = SourceUrl
}
done <- s
}
Expand Down
Loading