当前位置: 首页>>代码示例>>Golang>>正文


Golang dna.Int类代码示例

本文整理汇总了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())
	}
}
开发者ID:olragon,项目名称:dna,代码行数:38,代码来源:constants.go

示例2: SetIdKey

func (qv *QueryValues) SetIdKey(id dna.Int) {
	qv.mutex.Lock()
	qv.Values.Set("sfid", id.ToString().String())
	qv.mutex.Unlock()
}
开发者ID:olragon,项目名称:dna,代码行数:5,代码来源:postdata.go

示例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("")
}
开发者ID:olragon,项目名称:dna,代码行数:7,代码来源:zi.go

示例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
}
开发者ID:olragon,项目名称:dna,代码行数:78,代码来源:category_song.go

示例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("")
}
开发者ID:olragon,项目名称:dna,代码行数:7,代码来源:ns.go

示例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))
}
开发者ID:olragon,项目名称:dna,代码行数:4,代码来源:url_builder.go

示例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))
}
开发者ID:olragon,项目名称:dna,代码行数:5,代码来源:url_builder.go

示例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))
}
开发者ID:olragon,项目名称:dna,代码行数:4,代码来源:url_builder.go

示例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))
}
开发者ID:olragon,项目名称:dna,代码行数:6,代码来源:url_builder.go

示例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))
}
开发者ID:olragon,项目名称:dna,代码行数:4,代码来源:url_builder.go

示例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))
}
开发者ID:olragon,项目名称:dna,代码行数:4,代码来源:url_builder.go

示例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))
}
开发者ID:olragon,项目名称:dna,代码行数:4,代码来源:url_builder.go

示例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))
}
开发者ID:olragon,项目名称:dna,代码行数:4,代码来源:url_builder.go

示例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
	}
}
开发者ID:olragon,项目名称:dna,代码行数:20,代码来源:apifullsong.go

示例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
	}
}
开发者ID:olragon,项目名称:dna,代码行数:19,代码来源:apisong.go


注:本文中的dna.Int类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。