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


Golang dna.String类代码示例

本文整理汇总了Golang中dna.String的典型用法代码示例。如果您正苦于以下问题:Golang String类的具体用法?Golang String怎么用?Golang String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: CheckKey

// CheckKey returns true if key is valid
func CheckKey(key dna.String) dna.Bool {
	for _, v := range key.Split("") {
		if a.IndexOf(v) == -1 {
			return false
		}
	}
	return true
}
开发者ID:olragon,项目名称:dna,代码行数:9,代码来源:zi.go

示例2: getAnchorTagsData

func getAnchorTagsData(data dna.String) dna.StringArray {
	return dna.StringArray(data.Split("|").Map(func(val dna.String, idx dna.Int) dna.String {
		return val.RemoveHtmlTags("").Trim()
	}).([]dna.String)).Filter(func(val dna.String, idx dna.Int) dna.Bool {
		if val != "" {
			return true
		} else {
			return false
		}
	})
}
开发者ID:olragon,项目名称:dna,代码行数:11,代码来源:movie.go

示例3: ToSeconds

// ToSeconds returns total seconds from the time format "01:02:03"
func ToSeconds(str dna.String) dna.Int {
	if str == "" {
		return 0
	} else {
		intervals := dna.IntArray(str.Split(":").Map(func(val dna.String, idx dna.Int) dna.Int {
			return val.ToInt()
		}).([]dna.Int))
		switch intervals.Length() {
		case 3:
			return intervals[0]*3600 + intervals[1]*60 + intervals[2]
		case 2:
			return intervals[0]*60 + intervals[1]
		case 1:
			return intervals[0]
		default:
			return 0
		}
	}
}
开发者ID:olragon,项目名称:dna,代码行数:20,代码来源:apialbum.go

示例4: isSongFormat

func isSongFormat(str dna.String) dna.Bool {
	if str.EndsWith("mp3") == true || str.EndsWith("m4a") == true {
		return true
	} else {
		return false
	}
}
开发者ID:olragon,项目名称:dna,代码行数:7,代码来源:funcs.go

示例5: getOptionsForQuestion

func getOptionsForQuestion(tableOptions dna.String, question *Question) {
	// dna.Log(tableOptions)

	options := tableOptions.Replace(`<div class="bix-div-answer"`, "").Trim().Split("tdOptionDt")
	if options.Length() > 6 {
		panic("Answer options greater than 5 at: " + question.Cat.ToString())
	}
	for idx, option := range options {
		if idx > 0 {
			option := option.ReplaceWithRegexp(`^.+?>`, ``).ReplaceWithRegexp(`(?mis)<td class="bix-td-option".+$`, "").ReplaceWithRegexp(`</td>$`, "").ReplaceWithRegexp(`</td></tr><tr>$`, "").ReplaceWithRegexp(`</td></tr></table><input type="hidden".+$`, "").Trim()
			switch idx {
			case 1:
				question.OptionA = option
			case 2:
				question.OptionB = option
			case 3:
				question.OptionC = option
			case 4:
				question.OptionD = option
			case 5:
				question.OptionE = option
			}
		}
	}

}
开发者ID:olragon,项目名称:dna,代码行数:26,代码来源:question.go

示例6: ToSource

// To Source converts string format such as "(12,123123)" to Source Type
func ToSource(sourceStr dna.String) Source {
	if sourceStr.Match(`\([0-9]+,[0-9]+\)`) == false {
		panic("Wrong Source format")
	}
	sourArr := sourceStr.ReplaceWithRegexp(`^\(|\)$`, "").Split(",")
	return Source{sourArr[0].ToInt(), sourArr[1].ToInt()}
}
开发者ID:olragon,项目名称:dna,代码行数:8,代码来源:source.go

示例7: irrcrpt

func irrcrpt(_arg1 dna.String, _arg2 dna.Int) dna.String {
	var _local5 dna.Int
	var _local3 dna.String = ""
	var _local4 dna.Int
	for _local4 < _arg1.Length() {
		_local5 = _arg1.CharCodeAt(_local4)
		if (_local5 >= 48) && (_local5 <= 57) {
			_local5 = ((_local5 - _arg2) - 48)
			if _local5 < 0 {
				_local5 = (_local5 + ((57 - 48) + 1))
			}
			_local5 = ((_local5 % ((57 - 48) + 1)) + 48)
		} else {
			if (_local5 >= 65) && (_local5 <= 90) {
				_local5 = ((_local5 - _arg2) - 65)
				if _local5 < 0 {
					_local5 = (_local5 + ((90 - 65) + 1))
				}
				_local5 = ((_local5 % ((90 - 65) + 1)) + 65)
			} else {
				if (_local5 >= 97) && (_local5 <= 122) {
					_local5 = ((_local5 - _arg2) - 97)
					if _local5 < 0 {
						_local5 = (_local5 + ((122 - 97) + 1))
					}
					_local5 = ((_local5 % ((122 - 97) + 1)) + 97)
				}
			}
		}
		_local3 = (_local3 + dna.FromCharCode(_local5))
		_local4++
	}
	return (_local3)
}
开发者ID:olragon,项目名称:dna,代码行数:34,代码来源:decrypt_lrc.go

示例8: amGetErrIds

func amGetErrIds(inputFile dna.String, mode dna.Int) *dna.IntArray {
	var ret = dna.IntArray{}
	b, err := ioutil.ReadFile(inputFile.String())
	if err != nil {
		panic(err)
	}
	data := dna.String(string(b))
	lines := data.Split("\n")
	for _, line := range lines {
		switch mode {
		case 1:
			idArr := line.FindAllStringSubmatch(`([0-9]+) Post.+no such host`, 1)
			if len(idArr) > 0 {
				ret.Push(idArr[0][1].ToInt())
			}
			idArr = line.FindAllStringSubmatch(`Timeout.+at id :([0-9]+)`, 1)
			if len(idArr) > 0 {
				ret.Push(idArr[0][1].ToInt())
			}
		case 2:
			ret.Push(line.ToInt())
		}
	}
	if mode == 1 {
		err = ioutil.WriteFile(inputFile.String(), []byte{}, 0644)
		if err != nil {
			dna.Log("Cannot write to file1:", err.Error())
		}

	}
	ret = ret.Unique()
	return &ret
}
开发者ID:olragon,项目名称:dna,代码行数:33,代码来源:update_allmusic.go

示例9: getGracenoteSongLyric

func getGracenoteSongLyric(artist, title dna.String, song *Song) {
	link := "http://lyrics.wikia.com/Gracenote:" + artist.Replace(" ", "_") + ":" + title.Replace(" ", "_")
	result, err := http.Get(link)
	if err == nil {
		data := &result.Data

		writersArr := data.FindAllString(`Songwriters.+`, 1)
		if writersArr.Length() > 0 {
			song.GracenoteSongwriters = writersArr[0].GetTags("em")[0].RemoveHtmlTags("").DecodeHTML()
		}

		publisheraArr := data.FindAllString(`Publishers.+`, 1)
		if publisheraArr.Length() > 0 {
			song.GracenotePublishers = publisheraArr[0].GetTags("em")[0].RemoveHtmlTags("").DecodeHTML()
		}

		lyricArr := data.FindAllStringSubmatch(`(?mis)<div class='lyricbox'>(.+?)<\!--`, 1)
		if len(lyricArr) > 0 {
			song.GracenoteLyric = lyricArr[0][1].Trim().DecodeHTML().ReplaceWithRegexp(`(?mis)^<div.+?</span></div>`, "").Trim().Replace("<br />", "\n")
		}

		if song.GracenoteLyric != "" {
			song.DownloadGracenoteDone = 1
		} else {
			song.DownloadGracenoteDone = 0
		}

	}
}
开发者ID:olragon,项目名称:dna,代码行数:29,代码来源:song.go

示例10: IsValidTable

func IsValidTable(tblName dna.String, db *sqlpg.DB) dna.Bool {
	_, err := db.Exec("select * from " + tblName.String() + " limit 0")
	if err == nil {
		return true
	} else {
		return false
	}
}
开发者ID:olragon,项目名称:dna,代码行数:8,代码来源:func.go

示例11: Post

func Post(url, bodyStr dna.String) (*http.Result, error) {
	mutex.Lock()
	http.DefaulHeader = Header
	http.DefaulHeader.Set("Cookie", Cookie)
	http.DefaulHeader.Set("Content-Length", string(bodyStr.Length().ToString()))
	mutex.Unlock()
	// dna.Log(http.DefaulHeader)
	return http.Post(url, bodyStr)
}
开发者ID:olragon,项目名称:dna,代码行数:9,代码来源:header.go

示例12: getNames

func getNames(data, from, to dna.String) dna.StringArray {
	pattern := "(?mis)" + from + "(.+?)" + to
	arr := data.FindAllStringSubmatch(pattern, 1)
	if len(arr) > 0 {
		return getAnchorTagsData(arr[0][1])
	} else {
		return dna.StringArray{}
	}
}
开发者ID:olragon,项目名称:dna,代码行数:9,代码来源:movie.go

示例13: getSongFromMainPage

// getSongFromMainPage returns song from main page
func getSongFromMainPage(song *Song) <-chan bool {

	channel := make(chan bool, 1)
	go func() {
		link := "http://nhacso.net/nghe-nhac/google-bot." + GetKey(song.Id) + "==.html"
		result, err := http.Get(link)
		// Log(link)
		// Log(result.Data)
		if err == nil && !result.Data.Match("Rất tiếc, chúng tôi không tìm thấy thông tin bạn yêu cầu!") {
			data := &result.Data
			if data.Match("official") {
				song.Official = 1
			}

			bitrate := data.FindAllString(`\d+kb\/s`, 1)[0]
			if !bitrate.IsBlank() {
				song.Bitrate = bitrate.FindAllString(`\d+`, 1)[0].ToInt()
			}

			plays := data.FindAllString("total_listen_song_detail_\\d+.+", 1)[0]
			if !plays.IsBlank() {
				song.Plays = plays.ReplaceWithRegexp("<\\/span>.+$", "").ReplaceWithRegexp("^.+>", "").ReplaceWithRegexp("\\.", "").ToInt()
			}

			topics := data.FindAllString("<li><a\\shref\\=\\\"http\\:\\/\\/nhacso\\.net\\/the-loai.+", 1)[0]
			if !topics.IsBlank() {
				topics = topics.ReplaceWithRegexp("^.+\\\">|<\\/a><\\/li>", "")
				song.Topics = topics.ToStringArray().SplitWithRegexp(" - ").SplitWithRegexp("/")
				temp := data.FindAllString("<a.+class=\"casi\".+>(.+?)<\\/a>", 1)
				var singer dna.String
				if temp.Length() > 0 {
					singer = temp[0]
				} else {
					singer = ""
				}
				if topics.Match("Nhạc Hoa") && singer.Match(` / `) {
					song.SameArtist = 1
				}
			}

			lyric := data.FindAllString(`(?mis)txtlyric.+Bạn chưa nhập nội bài hát`, 1)[0]
			if !lyric.IsBlank() {
				song.Islyric = 1
				song.Lyric = lyric.ReplaceWithRegexp("(?mis)<\\/textarea>.+$", "").ReplaceWithRegexp("^.+>", "")
				if song.Lyric.Match("Hãy đóng góp lời bài hát chính xác cho Nhacso nhé") {
					song.Lyric = ``
					song.Islyric = 0
				}
			}
		}
		channel <- true

	}()
	return channel
}
开发者ID:olragon,项目名称:dna,代码行数:56,代码来源:song.go

示例14: getVideoUrl

func getVideoUrl(str, resolution dna.String) *VideoUrl {
	su := NewVideoUrl()
	su.Resolution = resolution
	su.Type = getType(str)
	su.Link = str.GetTagAttributes("href").ReplaceWithRegexp(`(http.+/).+(\..+$)`, "${1}file-name${2}")
	size := str.FindAllString(`[0-9\.]+ MB`, -1)
	if size.Length() > 0 {
		su.Size = size[0].ParseBytesFormat() / 1000
	}
	return su

}
开发者ID:olragon,项目名称:dna,代码行数:12,代码来源:link_formats.go

示例15: DecodePath

// DecodePath decodes encoded string such as "MjAxMyUyRjExJTJGMDUlMkYwJTJGMiUyRjAyN2UzN2M4NDUwMWFlOTEwNGNkZjgyMDZjYWE4OTkzLm1wMyU3QzI="
// into its real path on server such as "/2013/11/05/0/2/027e37c84501ae9104cdf8206caa8993.mp3|2"
func DecodePath(encodedPath dna.String) dna.String {
	ret, err := base64.StdEncoding.DecodeString(encodedPath.String())
	if err == nil {
		escape, err := url.QueryUnescape(string(ret))
		if err == nil {
			return dna.String(escape)
		} else {
			return ""
		}
	} else {
		return ""
	}
}
开发者ID:olragon,项目名称:dna,代码行数:15,代码来源:decode_path.go


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