本文整理汇总了Golang中dna.String.ToStringArray方法的典型用法代码示例。如果您正苦于以下问题:Golang String.ToStringArray方法的具体用法?Golang String.ToStringArray怎么用?Golang String.ToStringArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dna.String
的用法示例。
在下文中一共展示了String.ToStringArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: refineAuthorsOrArtists
func refineAuthorsOrArtists(str dna.String) dna.StringArray {
tmp := str.ToStringArray().SplitWithRegexp(` / `).SplitWithRegexp(` - `).SplitWithRegexp(` – `)
tmp = tmp.SplitWithRegexp(`, `).SplitWithRegexp(` ft `).SplitWithRegexp(` feat `).SplitWithRegexp(` ft. `)
tmp = tmp.SplitWithRegexp(` feat. `).SplitWithRegexp(` Feat. `).SplitWithRegexp(` Ft. `)
tmp = tmp.SplitWithRegexp(` & `).SplitWithRegexp(` vs. `).SplitWithRegexp(`- `).SplitWithRegexp(` & `)
tmp = dna.StringArray(tmp.Map(func(val dna.String, idx dna.Int) dna.String {
rv := val.Replace(`Đang Cập Nhật...`, ``).Replace(`Đang Cập Nhật (QT)`, ``)
rv = rv.Replace(`Đang Cập Nhật (VN)`, ``).Replace(`Nhạc Phim QT`, `Nhạc Phim Quốc Tế`)
rv = rv.Replace(`Đang cập nhật`, ``).Replace(`Nhiều Ca Sỹ`, `Various Artists`)
return rv
}).([]dna.String)).Filter(func(val dna.String, idx dna.Int) dna.Bool {
if val != "" {
return true
} else {
return false
}
})
return tmp
}
示例2: GetSong
func GetSong(artist, title dna.String) (*Song, error) {
link := "http://lyrics.wikia.com/" + artist.Replace(" ", "_") + ":" + title.Replace(" ", "_")
result, err := http.Get(link)
// Log(link)
// Log(result.Data)
song := NewSong()
song.Title = title
song.Artists = artist.ToStringArray()
if err == nil {
data := &result.Data
if data.Match(`class='lyricbox'.+Instrumental.+TrebleClef`) == true {
song.Lyric = "Instrumental"
}
lyricArr := data.FindAllStringSubmatch(`(?mis)<div class='lyricbox'>(.+?)<!--`, 1)
if len(lyricArr) > 0 {
song.Lyric = lyricArr[0][1].Trim().DecodeHTML().ReplaceWithRegexp(`(?mis)^<div.+?</span></div>`, "").Trim().Replace("<br />", "\n")
}
if song.Lyric == "" {
song.DownloadDone = -1
} else {
song.DownloadDone = 1
}
musicBrainzArr := data.FindAllString(`http://musicbrainz.+html`, 1)
if musicBrainzArr.Length() > 0 {
song.MusicbrainzLink = musicBrainzArr[0]
}
allmusicArr := data.FindAllString(`http://www\.allmusic\.com.+`, 1)
if allmusicArr.Length() > 0 {
song.AllmusicLink = allmusicArr[0].ReplaceWithRegexp(`".+$`, "")
}
youtubeArr := data.FindAllString(`http://youtube\.com.+`, 1)
if youtubeArr.Length() > 0 {
song.YoutubeLink = youtubeArr[0].ReplaceWithRegexp(`".+$`, "")
}
if data.Match("View the Gracenote") {
song.IsGracenote = "1"
}
languageArr := data.FindAllStringSubmatch(`category normal" data-name="Language/(.+)" data-namespace`, 1)
if len(languageArr) > 0 {
song.Language = languageArr[0][1]
}
albumArr := data.FindAllStringSubmatch(`appears on the album.+">(.+)</a></i>`, 1)
if len(albumArr) > 0 {
song.AlbumTitle = albumArr[0][1]
}
if song.AlbumTitle.Match(`[0-9]+`) {
song.Year = song.AlbumTitle.FindAllStringSubmatch(`([0-9]+)`, 1)[0][1]
}
if data.Match(`It has been suggested that Gracenote`) {
song.IsGracenote = "1"
getGracenoteSongLyric(artist, title, song)
}
return song, nil
} else {
return nil, err
}
}