• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang dna.String函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetEpisole

// GetEpisole returns an episole URL of a series.
func (urlb *URLBuilder) GetEpisole(movieid, ep dna.Int) dna.String {
	str := dna.Sprintf("movieid=%v&accesstokenkey=%v&ep=%v", movieid, ACCESS_TOKEN_KEY, ep)
	data := []byte(str.String())
	strBase64 := base64.StdEncoding.EncodeToString(data)
	sign := getMD5(dna.String(strBase64) + SECRET_KEY)
	return dna.Sprintf("%vmovieid=%v&accesstokenkey=%v&ep=%v&sign=%v", BASE_URL, movieid, ACCESS_TOKEN_KEY, ep, sign)
}
开发者ID:olragon,项目名称:dna,代码行数:8,代码来源:url_builder.go


示例2: RecoverSQLLogError

// RecoverSQLLogError re-executes failed sql queries in sql error log file from specified path.
// It returns the number of failed -reexec queries, and new failed
// queries will be written to the file
//
// The format of error file is:
// 	Error description - $$$error$$$SQL_QUERY$$$error$$$
// Therefore only get statements enclosed by special `$$$error$$$`
func RecoverSQLLogError(sqlErrFilePath dna.String, db *sqlpg.DB) dna.Int {
	var errCount = 0
	var errStrings = dna.StringArray{}
	b, err := ioutil.ReadFile(sqlErrFilePath.String())
	if err != nil {
		panic(err)
	}
	data := dna.String(string(b))
	// dna.Log("\n", data.Length())
	sqlArr := data.FindAllString(`(?mis)\$\$\$error\$\$\$.+?\$\$\$error\$\$\$`, -1)
	// dna.Log("\nTOTAL SQL STATEMENTS FOUND:", sqlArr.Length())
	for _, val := range sqlArr {
		sqlStmtArr := val.FindAllStringSubmatch(`(?mis)\$\$\$error\$\$\$(.+?)\$\$\$error\$\$\$`, -1)
		if len(sqlStmtArr) > 0 {
			_, err := db.Exec(sqlStmtArr[0][1].String())
			if err != nil {
				if dna.String(err.Error()).Contains(`duplicate key value violates unique constraint`) == false {
					errCount += 1
					errStrings.Push("$$$error$$$" + sqlStmtArr[0][1] + "$$$error$$$")
				}
			}
		}
	}
	if errCount == 0 {
		err = ioutil.WriteFile(sqlErrFilePath.String(), []byte{}, 0644)
	} else {
		err = ioutil.WriteFile(sqlErrFilePath.String(), []byte(errStrings.Join("\n").String()), 0644)
	}
	if err != nil {
		panic(err)
	}
	return dna.Int(errCount)
}
开发者ID:olragon,项目名称:dna,代码行数:40,代码来源:sqlrecover.go


示例3: getSrtContent

func getSrtContent(episode *Episode, isEn dna.Bool) <-chan bool {
	channel := make(chan bool, 1)
	go func() {
		var result *http.Result
		var err error
		if isEn == true {
			result, err = http.Get(episode.SubtitleExt[1])
		} else {
			result, err = http.Get(episode.SubtitleExt[0])
		}

		if err == nil {
			if isEn == true {

				// It is hard to detect an encoding of a string.
				// Therefore we convert them to BASE64
				episode.EnSrt = dna.String(base64.StdEncoding.EncodeToString(result.Data.ToBytes()))
				// episode.EnSrt = ISO8859_1ToUTF8String(result.Data.ToBytes())
				// ioutil.WriteFile("./dump/test_en_srt.srt", result.Data.ToBytes(), 0644)
			} else {
				// Vietnamese Subtitle encoded in UTF-16 Little Ending
				// It has to be converted to UTF-8
				if result.Data.Match(`^[0-9a-fA-F]+$`) == false {
					// episode.ViSrt = UTF16ToUTF8String(result.Data.ToBytes(), binary.LittleEndian)
					episode.ViSrt = dna.String(base64.StdEncoding.EncodeToString(result.Data.ToBytes()))
				}

				// dna.Log(result.Data.Substring(0, 100))
			}
		}
		channel <- true

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


示例4: String

func (c Counter) String() string {
	c.mu.RLock()
	if c.Total > 0 {
		format := dna.String("%v✘ | %v✔")
		return string(dna.Sprintf(format, c.Fail, c.Pass))
	} else {
		format := dna.String("t:%v|n:%v|f:%v✘|p:%v✔|v:%v")
		return string(dna.Sprintf(format, getTimeFmt(c.ElapsedTime), c.Count, c.Fail, c.Pass, c.Speed))
	}
	c.mu.RUnlock()
	return ""
}
开发者ID:olragon,项目名称:dna,代码行数:12,代码来源:counter.go


示例5: getVideoPlays

// getVideoPlays returns video plays
func getVideoPlays(video *Video, body dna.String) {
	link := "http://www.nhaccuatui.com/interaction/api/hit-counter?jsoncallback=nct"
	http.DefaulHeader.Set("Content-Type", "application/x-www-form-urlencoded ")
	result, err := http.Post(dna.String(link), body)
	// Log(link)
	if err == nil {
		data := &result.Data
		tpl := dna.String(`{"counter":([0-9]+)}`)
		playsArr := data.FindAllStringSubmatch(tpl, -1)
		if len(playsArr) > 0 {
			video.Plays = playsArr[0][1].ToInt()
		}
	}
}
开发者ID:olragon,项目名称:dna,代码行数:15,代码来源:video.go


示例6: getAPIAlbumAwards

// getAPIAlbumAwards fetches album's awards
// with the following url format:
// http://www.allmusic.com/album/google-bot-mw0002585207/similar/mobile
func getAPIAlbumAwards(album *APIAlbum) <-chan bool {
	channel := make(chan bool, 1)
	go func() {
		link := "http://www.allmusic.com/album/google-bot-mw" + album.Id.ToFormattedString(10, true) + "/awards/mobile"
		result, err := http.Get(link)
		if err == nil {
			data := &result.Data
			var awardSections = []APIAwardSection{}

			sectionsArr := data.FindAllString(`(?mis)<section class=.+?</section>`, -1)
			sectionsArr.ForEach(func(section dna.String, idx dna.Int) {
				awardSections = append(awardSections, getSection(section))
			})

			if len(awardSections) > 0 {
				bAwards, derr := json.Marshal(awardSections)
				if derr == nil {
					album.Awards = dna.String(string(bAwards))
				}
			}
		}

		channel <- true
	}()
	return channel

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


示例7: GetChannel

// GetChannel returns TV channel URL.
func (urlb *URLBuilder) GetChannel(channelid dna.Int) dna.String {
	str := dna.Sprintf("channelid=%v&accesstokenkey=%v", channelid, ACCESS_TOKEN_KEY)
	data := []byte(str.String())
	strBase64 := base64.StdEncoding.EncodeToString(data)
	sign := getMD5(dna.String(strBase64) + SECRET_KEY)
	return dna.Sprintf("%vchannelid=%v&accesstokenkey=%v&sign=%v", CHANNEL_BASE_URL, channelid, ACCESS_TOKEN_KEY, sign)
}
开发者ID:olragon,项目名称:dna,代码行数:8,代码来源:url_builder.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: ISO8859_1ToUTF8String

func ISO8859_1ToUTF8String(iso8859_1_buf []byte) dna.String {
	buf := make([]rune, len(iso8859_1_buf))
	for i, b := range iso8859_1_buf {
		buf[i] = rune(b)
	}
	return dna.String(string(buf))
}
开发者ID:olragon,项目名称:dna,代码行数:7,代码来源:episode.go


示例10: SaveLastedChecktime

func SaveLastedChecktime(db *sqlpg.DB, filePath dna.String) error {
	cf, err := cfg.LoadConfigFile(filePath)
	if err != nil {
		return err
	}
	siteCts, err := GetLastedChecktime(db)
	if err != nil {
		return err
	}
	for site, checktime := range siteCts {
		var key dna.String
		var section dna.String
		switch {
		case site.Match("songs") == true:
			key = "songs"
			section = site.Replace("songs", "")
		case site.Match("albums") == true:
			key = "albums"
			section = site.Replace("albums", "")
		case site.Match("videos") == true:
			key = "videos"
			section = site.Replace("videos", "")
		default:
			panic("site is not valid")
		}
		cf.SetValue(section, key, dna.String(checktime.Format(utils.DefaultTimeLayout)))
	}
	return cfg.SaveConfigFile(cf, filePath)
}
开发者ID:olragon,项目名称:dna,代码行数:29,代码来源:ref.go


示例11: Get

// Get impliments getting site with basic properties.
// Enable gzip, deflat by default to reduce  network data, redirect to new location from response.
// It returns data (String type) and error
// if err is nil then data is "" (empty).
func Get(url dna.String) (*Result, error) {
	req, err := http.NewRequest("GET", url.ToPrimitiveValue(), nil)
	req.Header = DefaulHeader
	// req.Header.Add("Accept-Encoding", "gzip,deflate")
	// req.Header.Add("Accept-Language", "en-US,en")
	// req.Header.Add("Cache-Control", "max-age=0")
	// req.Header.Add("Connection", "keep-alive")
	req.Header.Add("Host", url.ToPrimitiveValue())
	// req.Header.Add("User-Agent", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
	// req.Header.Add("Cookie", "")
	// dna.Log(req.Header)
	res, err := client.Do(req)
	if err != nil {
		return new(Result), err
	}

	var data []byte
	var myErr error

	switch res.Header.Get("Content-Encoding") {
	case "gzip":
		var reader io.ReadCloser
		reader, err := gzip.NewReader(res.Body)
		if err != nil {
			return new(Result), err
		}
		data, myErr = ioutil.ReadAll(reader)
		reader.Close()
	case "deflate":
		// Logv("sdsafsd")
		reader, err := zlib.NewReader(res.Body)
		if err != nil {
			return new(Result), err
		}
		data, myErr = ioutil.ReadAll(reader)
		reader.Close()
	default:
		data, myErr = ioutil.ReadAll(res.Body)
	}

	if myErr != nil {
		return new(Result), myErr
	}

	res.Body.Close()
	return NewResult(dna.Int(res.StatusCode), dna.String(res.Status), res.Header, dna.String(data)), nil
}
开发者ID:olragon,项目名称:dna,代码行数:51,代码来源:http.go


示例12: ToSongFreak

func (sf *APISongFreaksTrack) ToSongFreak() (*SongFreak, error) {
	if sferr := sf.HasError(); sferr != nil {
		return nil, sferr
	}
	sofre := NewSongFreak()
	sofre.Id = sf.Id
	track, err := xml.MarshalIndent(sf.Track, "", "\t")
	if err == nil {
		sofre.Track = dna.String(string(track))
	}
	videos, err := xml.MarshalIndent(sf.Videos, "", "\t")
	if err == nil {
		sofre.Videos = dna.String(string(videos))
	}
	sofre.Checktime = time.Now()
	return sofre, nil
}
开发者ID:olragon,项目名称:dna,代码行数:17,代码来源:apisongfreaks_track.go


示例13: ExampleURLBuilder

func ExampleURLBuilder() {
	logURL := func(descStr, url dna.String) {
		dna.Log(descStr+dna.String(" ").Repeat(23-descStr.Length()), url)
	}
	urlb := NewURLBuilder()
	urlb.SetTimestamp(time.Date(2014, time.February, 4, 12, 12, 12, 12, time.UTC))
	logURL("ARTIST INFO:", urlb.GetArtistInfo(49674))
	logURL("CHECKVERSION:", urlb.GetCheckVersion())
	dna.Log("--------------------------------------------------------")
	logURL("LIST OF GENRES:", urlb.GetListOfGenres("song"))
	logURL("LIST OF TOPICS:", urlb.GetListOfTopics(1, 30))
	dna.Log("--------------------------------------------------------")
	logURL("PLAYLIST INFO:", urlb.GetPlaylistInfo(12255234))
	logURL("PLAYLISTS BY ARTIST:", urlb.GetPlaylistsByArtist(49674, 1, 30))
	logURL("PLAYLISTS BY GENRE:", urlb.GetPlaylistsByGenre(0, 1, 30))
	logURL("PLAYLISTS BY SEARCHING:", urlb.GetPlaylistsBySearching("tell", 1, 30))
	logURL("PLAYLISTS BY TOPIC:", urlb.GetPlaylistsByTopic(51))
	logURL("PLAYLISTS RELATED:", urlb.GetPlaylistsRelated(12336694))
	dna.Log("--------------------------------------------------------")
	logURL("SONG INFO:", urlb.GetSongInfo(2854574))
	logURL("SONG LYRIC:", urlb.GetSongLyric(2909727))
	logURL("SONGS BY ARTIST:", urlb.GetSongsByArtist(49674, 50, 30))
	logURL("SONGS BY GENRE:", urlb.GetSongsByGenre(5015, 34, 30))
	logURL("SONGS BY SEARCHING:", urlb.GetSongsBySearching("man", 1, 30))
	logURL("SONGS OF PLAYLIST", urlb.GetSongsOfPlaylist(12095591))
	dna.Log("--------------------------------------------------------")
	logURL("VIDEO INFO:", urlb.GetVideoInfo(2876055))
	logURL("VIDEOS BY ARTIST:", urlb.GetVideosByArist(49674, 1, 30))
	logURL("VIDEOS BY GENRE:", urlb.GetVideosByGenre(5142, 1, 30))
	logURL("VIDEOS BY SEARCHING:", urlb.GetVideosBySearching("man", 1, 30))
	logURL("VIDEOS RELATED:", urlb.GetVideosRelated(12336694))
	// Output:
	// ARTIST INFO:            http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-artist-detail&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&artistid=49674&time=1391515932000&token=a6ffbbb6da2b822f647829ff6215c210
	// CHECKVERSION:           http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=check-version&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&time=1391515932000&token=31842a81519047f5dd477b54608eb2d7
	// --------------------------------------------------------
	// LIST OF GENRES:         http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-list-genre&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&type=song&time=1391515932000&token=c1b31f50c1ea19250898a1a2e14ca60b
	// LIST OF TOPICS:         http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-list-topic&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&pageindex=1&pagesize=30&time=1391515932000&token=d7abea98a130db44bce09600f25cb316
	// --------------------------------------------------------
	// PLAYLIST INFO:          http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-playlist-info&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&playlistid=12255234&time=1391515932000&token=f1f0b8e4827086b37c3c3accee79017f
	// PLAYLISTS BY ARTIST:    http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-playlist-by-artist&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&artistid=49674&pageindex=1&pagesize=30&time=1391515932000&token=2be9e5d0c3fd1325d2a7ee2426922d5b
	// PLAYLISTS BY GENRE:     http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-playlist-by-genre&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&genreid=0&pageindex=1&pagesize=30&time=1391515932000&token=ec761c1865e50560e61c5036fca893ce
	// PLAYLISTS BY SEARCHING: http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=search-playlist&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&keyword=tell&pageindex=1&pagesize=30&time=1391515932000&token=5370cbfb8040183ad5570b999c813c83
	// PLAYLISTS BY TOPIC:     http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-playlist-by-topic&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&topicid=51&time=1391515932000&token=ff8f012db0d705b3cdf2698ec16536a7
	// PLAYLISTS RELATED:      http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-playlist-related&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&playlistid=12336694&time=1391515932000&token=5c8efd0df7e283a58c28b943b85e1262
	// --------------------------------------------------------
	// SONG INFO:              http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-song-info&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&songid=2854574&time=1391515932000&token=b1db67e99010e541ea910e997350a75d
	// SONG LYRIC:             http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-lyric&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&songid=2909727&time=1391515932000&token=c752ab44e4f60177474b3ff554c380f3
	// SONGS BY ARTIST:        http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-song-by-artist&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&artistid=49674&pageindex=50&pagesize=30&time=1391515932000&token=cb00833e14a158c8eae098be2834e166
	// SONGS BY GENRE:         http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-song-by-genre&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&genreid=5015&pageindex=34&pagesize=30&time=1391515932000&token=21bd96e68c4179d0459f5692e0144ca0
	// SONGS BY SEARCHING:     http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=search-song&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&keyword=man&pageindex=1&pagesize=30&time=1391515932000&token=3ba6c692cd09ef54ee196bc8e3798078
	// SONGS OF PLAYLIST       http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-song-by-playlistid&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&playlistid=12095591&time=1391515932000&token=9e461944fa434c9e197b5bae1ad9cc3f
	// --------------------------------------------------------
	// VIDEO INFO:             http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-video-detail&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&videoid=2876055&time=1391515932000&token=ad13b3cee157e1ab1dfa337ec47ab20e
	// VIDEOS BY ARTIST:       http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-video-by-artist&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&artistid=49674&pageindex=1&pagesize=30&time=1391515932000&token=c1641290c36d3a36590df55cbad083dc
	// VIDEOS BY GENRE:        http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-video-by-genre&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&genreid=5142&pageindex=1&pagesize=30&time=1391515932000&token=270c039a73d299c688d8b3b086ae1e7e
	// VIDEOS BY SEARCHING:    http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=search-video&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&keyword=man&pageindex=1&pagesize=30&time=1391515932000&token=4bce7e9c8333ba31076c3cb1a2b85544
	// VIDEOS RELATED:         http://api.m.nhaccuatui.com/mobile/v5.0/[email protected]_service&action=get-video-related&deviceinfo={"DeviceID":"90c18c4cb3c37d442e8386631d46b46f","OsName":"ANDROID","OsVersion":"10","AppName":"NhacCuaTui","AppVersion":"5.0.1","UserInfo":"","LocationInfo":""}&videoid=12336694&time=1391515932000&token=57aa7164a27ac3dacb25526d7f4a3cbc
}
开发者ID:olragon,项目名称:dna,代码行数:58,代码来源:urlbuilder_test.go


示例14: getTableName

// GetTableName returns table name from a struct.
// Ex: An instance of ns.Song will return nssongs
// An instance of ns.Album will return nsalbums
func getTableName(structValue interface{}) dna.String {
	val := reflect.TypeOf(structValue)
	if val.Kind() != reflect.Ptr {
		panic("StructValue has to be pointer")
		if val.Elem().Kind() != reflect.Struct {
			panic("StructValue has to be struct type")
		}
	}
	return dna.String(val.Elem().String()).Replace(".", "").ToLowerCase() + "s"
}
开发者ID:olragon,项目名称:dna,代码行数:13,代码来源:utils.go


示例15: UTF16ToUTF8String

func UTF16ToUTF8String(b []byte, o binary.ByteOrder) dna.String {
	utf := make([]uint16, (len(b)+(2-1))/2)
	for i := 0; i+(2-1) < len(b); i += 2 {
		utf[i/2] = o.Uint16(b[i:])
	}
	if len(b)/2 < len(utf) {
		utf[len(utf)-1] = utf8.RuneError
	}
	return dna.String(string(utf16.Decode(utf)))
}
开发者ID:olragon,项目名称:dna,代码行数:10,代码来源:episode.go


示例16: Post

func Post(url dna.String, bodyStr dna.String) (*Result, error) {
	client := &http.Client{}
	// dna.Log(bodyStr)
	req, err := http.NewRequest("POST", url.String(), strings.NewReader(bodyStr.String()))
	req.Header = DefaulHeader
	req.Header.Add("Host", url.ToPrimitiveValue())
	res, err := client.Do(req)
	if err != nil {
		return new(Result), err
	}

	var data []byte
	var myErr error

	switch res.Header.Get("Content-Encoding") {
	case "gzip":
		var reader io.ReadCloser
		reader, err := gzip.NewReader(res.Body)
		if err != nil {
			return new(Result), err
		}
		data, myErr = ioutil.ReadAll(reader)
		reader.Close()
	case "deflate":
		// Logv("sdsafsd")
		reader, err := zlib.NewReader(res.Body)
		if err != nil {
			return new(Result), err
		}
		data, myErr = ioutil.ReadAll(reader)
		reader.Close()
	default:
		data, myErr = ioutil.ReadAll(res.Body)
	}

	if myErr != nil {
		return new(Result), myErr
	}

	res.Body.Close()
	return NewResult(dna.Int(res.StatusCode), dna.String(res.Status), res.Header, dna.String(data)), nil
}
开发者ID:olragon,项目名称:dna,代码行数:42,代码来源:http.go


示例17: InsertIgnore

// InsertIgnore runs exactly the same as Insert.
// However if the insert value has already existed in a table,
// it does not return any error.
// It only returns an error if and only if other errors occur.
//
// The error format is the same as the one of sqlpg.DB.Insert()
func (db *DB) InsertIgnore(structValue interface{}) error {
	err := db.Insert(structValue)
	if err != nil {
		if dna.String(err.Error()).Contains(`duplicate key value violates unique constraint`) {
			return nil
		} else {
			return err
		}
	} else {
		return nil
	}
}
开发者ID:olragon,项目名称:dna,代码行数:18,代码来源:db.go


示例18: 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


示例19: atomicUpdate

func atomicUpdate(errChannel chan bool, state *StateHandler) {
	var err error
	var c1 = make(chan error, 1)

	it := state.GetItem().New()
	state.IncreaseCid()
	n := state.GetCid()
	it.Init(n)
	go func() {
		c1 <- it.Fetch()
	}()

	select {
	case err = <-c1:
		// do nothing
	case <-time.After(time.Second * time.Duration(TIMEOUT_SECS)):
		strErr := dna.Sprintf("%v - Timeout after %vs at id :%v", state.GetTableName(), TIMEOUT_SECS, it.GetId())
		err = errors.New(strErr.String())
	}
	state.AddNcCount(1)
	// if it != nil {
	// 	dna.LogStruct(it)
	// }
	if err != nil {
		// dna.Log(err.Error())
		HTTPERROR.Println(it.GetId(), err.Error())
		errChannel <- true
	} else {
		// checking this code.Working only with 1st pattern
		// The goroutine continues to run after DB closed so it will invoke an error
		// state.InsertIgnore(it)
		saveErr := it.Save(state.GetDb())
		if saveErr != nil {
			SQLERROR.Println(dna.String(saveErr.Error()))
		}
		errChannel <- false
	}
	state.AddNcCount(-1)
	if state.IsComplete() == false {
		switch state.GetPattern() {
		case 2:
			if state.GetCid() < state.GetRange().Last {
				go atomicUpdate(errChannel, state)
			}
		default:
			go atomicUpdate(errChannel, state)
		}

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


示例20: ToSong

func (sf *APISongFreaksTrack) ToSong() (*Song, error) {
	if sferr := sf.HasError(); sferr != nil {
		return nil, sferr
	}
	song := NewSong()
	song.Id = sf.Track.Id
	song.TrackGroupId = sf.Track.TrackGroupId
	song.AMG = sf.Track.AMG
	song.UrlSlug = sf.Track.UrlSlug
	song.IsInstrumental = sf.Track.IsInstrumental
	song.Viewable = sf.Track.Viewable
	song.Duration = utils.ToSeconds(sf.Track.Duration)
	song.Lyricid = sf.Track.LyricId
	song.HasLrc = sf.Track.HasLrc
	song.TrackNumber = sf.Track.TrackNumber
	song.DiscNumber = sf.Track.DiscNumber
	song.Title = sf.Track.Title
	song.Rating = dna.IntArray{sf.Track.Rating.AverageRating.ToInt(), sf.Track.Rating.UserRating, sf.Track.Rating.TotalRatings}
	song.Albumid = sf.Track.Album.Id

	artistIds := dna.IntArray{}
	artists := dna.StringArray{}
	for _, artist := range sf.Track.Artists {
		artistIds.Push(artist.Id)
		artists.Push(artist.Name)
	}
	song.Artistids = artistIds
	song.Artists = artists

	if sf.Track.Lrc.Lines != nil && len(sf.Track.Lrc.Lines) > 0 {
		lines, err := json.Marshal(sf.Track.Lrc.Lines)
		if err == nil {
			song.Lrc = dna.String(string(lines))

		}
	}

	song.Link = sf.Track.Link
	song.Lyric = sf.Track.Lyrics
	if song.Lyric != "" {
		song.HasLyric = true
	}
	song.Copyright = sf.Track.Copyright
	song.Writer = sf.Track.Writer
	song.SubmittedLyric = sf.Track.SubmittedLyric
	song.Checktime = time.Now()
	return song, nil
}
开发者ID:olragon,项目名称:dna,代码行数:48,代码来源:apisongfreaks_track.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang dna.Int类代码示例发布时间:2022-05-24
下一篇:
Golang dna.Sprintf函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap