本文整理匯總了Golang中dna.Int類的典型用法代碼示例。如果您正苦於以下問題:Golang Int類的具體用法?Golang Int怎麽用?Golang Int使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Int類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ToShortForm
// ToShortForm returns a short form string representing a site name.
// For example: NhacSo is for "ns"
func ToShortForm(siteid dna.Int) dna.String {
switch siteid {
case NhacSo:
return "ns"
case Zing:
return "zi"
case NhacCuaTui:
return "nct"
case ChaCha:
return "cc"
case NhacVui:
return "nv"
case ChiaSeNhac:
return "csn"
case HDViet:
return "hdv"
case Keeng:
return "ke"
case SongFreaks:
return "sf"
case AllMusic:
return "am"
case LyricWiki:
return "lw"
case MetroLyrics:
return "ml"
case LyricFind:
return "lf"
case VietGiaiTri:
return "vg"
case MusicVNN:
return "mv"
default:
panic("Cannot convert siteid to short form - GOT:" + siteid.ToString().String())
}
}
示例2: SetIdKey
func (qv *QueryValues) SetIdKey(id dna.Int) {
qv.mutex.Lock()
qv.Values.Set("sfid", id.ToString().String())
qv.mutex.Unlock()
}
示例3: Encrypt
// Encrypt encodes an integer ID into a key
func Encrypt(id dna.Int) dna.String {
return dna.StringArray(id.ToHex().Split("").Map(
func(v dna.String, i dna.Int) dna.String {
return a[b.IndexOf(v)]
}).([]dna.String)).Join("")
}
示例4: getCategory
func getCategory(songs *[]*Song, genre Genre, page dna.Int) <-chan bool {
channel := make(chan bool, 1)
go func() {
link := "http://nhacso.net/bai-hat-theo-the-loai-" + genre.Id.ToString() + "/joke-link-2-" + page.ToString() + ".html"
// dna.Log(link)
result, err := http.Get(link)
if err == nil {
data := &result.Data
// transform string {"2":[0,3,5,7,9,11,13,15,29],"10":[1,2,4,6,8,]}
// to map[dna.Int]dna.Int{20:2, 28:2, 4:10, 12:10} Ex: map[29] = 2
temp := data.FindAllStringSubmatch(`getCategory.+'(\{.+\})'`, -1)
mapping := map[dna.Int]dna.Int{}
if len(temp) > 0 && temp[0].Length() > 0 {
vals := temp[0][1].FindAllString(`"[0-9]+":\[[0-9,]+?\]`, -1)
if vals.Length() > 0 {
for _, val := range vals {
target := val.FindAllStringSubmatch(`"(.+)"`, -1)[0][1].ToInt()
arr := val.FindAllStringSubmatch(`\[(.+)\]`, -1)[0][1].Split(",").ToIntArray()
for _, itm := range arr {
mapping[itm] = target
}
}
}
}
// Finding cat id for each song. cats var is 2-dimentional array.
// Each index of it represents the correspondent song, its value is the categories the song belongs to
catStrings := data.FindAllString(`Thể loại :.+`, -1)
cats := []dna.IntArray{}
for _, val := range catStrings {
tagids := dna.IntArray{}
tmp := val.FindAllStringSubmatch(`cate_tag_song_([0-9]+)`, -1)
if len(tmp) > 0 {
for _, el := range tmp {
tagids.Push(el[1].ToInt())
}
}
cats = append(cats, tagids)
}
// Log(cats)
// get songids
temps := data.FindAllStringSubmatch(`play" id="blocksongtag_([0-9]+)`, -1)
songids := dna.IntArray{}
if len(temps) > 0 {
for _, val := range temps {
songids.Push(val[1].ToInt())
}
}
tmpsongs := &[]*Song{}
for idx, songid := range songids {
song := NewSong()
song.Id = songid
category := dna.StringArray{}
for _, val := range cats[idx] {
if mapping[val] > 0 && mapping[val] < CatTags.Length() {
if CatTags[mapping[val]] != "" {
category.Push(CatTags[mapping[val]])
}
} else {
mess := dna.Sprintf("WRONG INDEX AT CATTAGS: %v %v %v - %v", mapping[val], genre, page, link)
panic(mess.String())
}
}
category.Push(genre.Name)
song.Category = transformCats(category.Unique()).Unique()
*tmpsongs = append(*tmpsongs, song)
}
*songs = *tmpsongs
}
channel <- true
}()
return channel
}
示例5: Encrypt
// This function will encode the Id of nhacso into cipher text.
func Encrypt(id dna.Int) dna.String {
return dna.StringArray(id.ToString().Split("").Map(
func(v dna.String, i dna.Int) dna.String {
return ns[6-i][v.ToInt()]
}).([]dna.String)).Join("")
}
示例6: GetPlaylistsByTopic
func (urlb *URLBuilder) GetPlaylistsByTopic(topicId dna.Int) dna.String {
s1 := "get-playlist-by-topic" + topicId.ToString() + TOKEN_KEY + urlb.tsStr
return dna.Sprintf("%v?secretkey=%v&action=get-playlist-by-topic&deviceinfo=%v&topicid=%v&time=%v&token=%v", BASE_URL, SECRET_KEY, DEVICE_INFOR, topicId, urlb.tsStr, getMD5(s1))
}
示例7: GetPlaylistInfo
func (urlb *URLBuilder) GetPlaylistInfo(albumid dna.Int) dna.String {
//NOT COMPLETE
s1 := "get-playlist-info" + albumid.ToString() + TOKEN_KEY + urlb.tsStr
return dna.Sprintf("%v?secretkey=%v&action=get-playlist-info&deviceinfo=%v&playlistid=%v&time=%v&token=%v", BASE_URL, SECRET_KEY, DEVICE_INFOR, albumid, urlb.tsStr, getMD5(s1))
}
示例8: GetSongLyric
func (urlb *URLBuilder) GetSongLyric(songid dna.Int) dna.String {
s1 := "get-lyric" + songid.ToString() + TOKEN_KEY + urlb.tsStr
return dna.Sprintf("%v?secretkey=%v&action=get-lyric&deviceinfo=%v&songid=%v&time=%v&token=%v", BASE_URL, SECRET_KEY, DEVICE_INFOR, songid, urlb.tsStr, getMD5(s1))
}
示例9: GetVideoInfo
func (urlb *URLBuilder) GetVideoInfo(videoid dna.Int) dna.String {
//NOT COMPLETE
s1 := "get-video-detail" + videoid.ToString() + TOKEN_KEY + urlb.tsStr
return dna.Sprintf("%v?secretkey=%v&action=get-video-detail&deviceinfo=%v&videoid=%v&time=%v&token=%v", BASE_URL, SECRET_KEY, DEVICE_INFOR, videoid, urlb.tsStr, getMD5(s1))
}
示例10: GetSongsOfPlaylist
func (urlb *URLBuilder) GetSongsOfPlaylist(albumid dna.Int) dna.String {
s1 := "get-song-by-playlistid" + albumid.ToString() + TOKEN_KEY + urlb.tsStr
return dna.Sprintf("%v?secretkey=%v&action=get-song-by-playlistid&deviceinfo=%v&playlistid=%v&time=%v&token=%v", BASE_URL, SECRET_KEY, DEVICE_INFOR, albumid, urlb.tsStr, getMD5(s1))
}
示例11: GetSongsByGenre
func (urlb *URLBuilder) GetSongsByGenre(genreId, pageIndex, pageSize dna.Int) dna.String {
s1 := "get-song-by-genre" + genreId.ToString() + pageIndex.ToString() + pageSize.ToString() + TOKEN_KEY + urlb.tsStr
return dna.Sprintf("%v?secretkey=%v&action=get-song-by-genre&deviceinfo=%v&genreid=%v&pageindex=%v&pagesize=%v&time=%v&token=%v", BASE_URL, SECRET_KEY, DEVICE_INFOR, genreId, pageIndex, pageSize, urlb.tsStr, getMD5(s1))
}
示例12: GetArtistInfo
func (urlb *URLBuilder) GetArtistInfo(artistid dna.Int) dna.String {
s1 := "get-artist-detail" + artistid.ToString() + TOKEN_KEY + urlb.tsStr
return dna.Sprintf("%v?secretkey=%v&action=get-artist-detail&deviceinfo=%v&artistid=%v&time=%v&token=%v", BASE_URL, SECRET_KEY, DEVICE_INFOR, artistid, urlb.tsStr, getMD5(s1))
}
示例13: GetPlaylistsRelated
func (urlb *URLBuilder) GetPlaylistsRelated(playlistid dna.Int) dna.String {
s1 := "get-playlist-related" + playlistid.ToString() + TOKEN_KEY + urlb.tsStr
return dna.Sprintf("%v?secretkey=%v&action=get-playlist-related&deviceinfo=%v&playlistid=%v&time=%v&token=%v", BASE_URL, SECRET_KEY, DEVICE_INFOR, playlistid, urlb.tsStr, getMD5(s1))
}
示例14: getAPIFullSongWithMetadata
func getAPIFullSongWithMetadata(id dna.Int) (*APIFullSong, error) {
var apisong = new(APIFullSong)
var link string
link = "http://api.lyricfind.com/metadata.do?apikey=" + METADATA_KEY + "&reqtype=metadata&trackid=amg:" + id.ToString().String() + "&displaykey=" + API_KEY + "&output=json"
result, err := http.Get(dna.String(link))
if err == nil {
data := &result.Data
json.Unmarshal([]byte(*data), apisong)
switch apisong.Response.Code {
case 100, 101, 111, 102:
return apisong, nil
default:
return nil, errors.New(dna.Sprintf("LyricFind - Song ID: %v - %v %v", id, apisong.Response.Code, apisong.Response.Description).String())
}
return apisong, nil
} else {
return nil, err
}
}
示例15: GetAPISong
func GetAPISong(id dna.Int) (*APISong, error) {
var apisong = new(APISong)
link := "https://api.lyricfind.com/lyric.do?apikey=" + API_KEY + "&reqtype=default&trackid=amg:" + id.ToString().String() + "&output=json"
// result, err := GetProxy(dna.String(link), 0)
result, err := http.Get(dna.String(link))
if err == nil {
data := &result.Data
json.Unmarshal([]byte(*data), apisong)
switch apisong.Response.Code {
case 100, 101, 111, 102:
return apisong, nil
default:
return nil, errors.New(dna.Sprintf("LyricFind - Song ID: %v - %v %v", id, apisong.Response.Code, apisong.Response.Description).String())
}
return apisong, nil
} else {
return nil, err
}
}