示例#1
0
func stopVPN(vpnAppName dna.String, cmd *exec.Cmd) {
	cmdErr := cmd.Process.Kill()
	if cmdErr != nil {
		dna.Log(vpnAppName, "cannot shut it down properly. Error:", cmdErr.Error())
	} else {
		dna.Log(vpnAppName, "was shut down!")
	}
}
示例#2
0
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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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/api?secretkey=nct@mobile_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
}
示例#3
0
文件: song.go 项目: olragon/dna
func getSongLrc(song *Song) {
	result, err := http.Get(song.LrcUrl)
	if err == nil {
		lrc, derr := DecryptLRC(result.Data)
		if derr == nil {
			song.Lrc = lrc
		} else {
			dna.Log("ERR WHILE DECRYPT SONG ", song.Id)
			dna.Log("-----\n")
		}
	}
}
示例#4
0
func ExampleURLBuilder() {
	// Prevent ACCESS_TOKEN_KEY getting updated
	ACCESS_TOKEN_KEY = "1c3102056acd3c12440bd05af8b9c560"
	AccessTokenKeyRenewable = false
	urlb := NewURLBuilder()
	dna.Log("MOVIE  :", urlb.GetMovie(5585))
	dna.Log("EPISOLE:", urlb.GetEpisole(4807, 5))
	dna.Log("CHANNEL:", urlb.GetChannel(8))
	// Output:
	// MOVIE  : https://api.hdviet.com/movie/play?movieid=5585&accesstokenkey=1c3102056acd3c12440bd05af8b9c560&sign=849ac3a1bac4ad70ef424c63d8285d7e
	// EPISOLE: https://api.hdviet.com/movie/play?movieid=4807&accesstokenkey=1c3102056acd3c12440bd05af8b9c560&ep=5&sign=d2bb08aaa5b11ecbe4d58b45b5705890
	// CHANNEL: https://api.hdviet.com/channel/play?channelid=8&accesstokenkey=1c3102056acd3c12440bd05af8b9c560&sign=9f08c9663c064bd6713ded7f8bd4cfd6
}
示例#5
0
func ExampleDecryptLRC() {
	var data dna.String = "0BAF2564A1C1AF9E3AC9A5F6FDC42CA0EBA4A3584FD54C91CF3983538CC761B0EB54E77BFF3994C6188C1C26FEB004C745119E11A53E618DA62754364E842D97900E0F531E872BA76652FAE77EB2FD764DBE11966FA1BF4A96C86BC28F33754B60BF102E9CEF0578531B41315B6398F8A6B35234881FEFC172134FF8B2832D6BEE9A757846AB4020B32E8505730204154480DD0938EE69427D2E42EB48787E9BAD63FAEC9EFA15E0619B6EE55993B824A85F9D2E1E957BCB8EA6B9C1AF45B6C0F607D6D32FFC7A12316829F8B063F86B52C168A2830AECE58E518D8D43D5E9FCE9F771CF716D9741926199613733D2BDEB0FA696FD00910A422DFCCC80E376454DCDEE45439C9F7C52A9453354720BAC5FE03B74C70F4EF98900B82E3A66B4A25F822417107B84F0A77A6DB454896D4F5C969DFF721A494BE8576A7716BE23B3B40203DD07B29DB241F808B2D55629F3C31F13FE780A93F333DA92E227BC6DAEA733F25B8EAF2ACEE2DA5C2F7526103F515B515BDDC57827E45D330096DC1036DA68D723D879A42D5B35CEA9E88CD819121ED9D01D68FFBD40AF2D36073125A344B66B4476F53A91B5E0E2F10E29B44AB1CF0E5D8077DE71FD85B4787EE4DF3AA18C03323A9C4AF8B2E75E049F4FDD470B56C60FCF029422C4D0A12995CC367238E4A6544DF27607CBB0EB8394DC7D320F074F8B323D961EB152999E8E680BBF0B8B2CA5AC435907CAA9B4D3BC1A105B7C02D3CC9EBA76BAA1F33DCBD19D087D7D49B177239991C54E7E600D6CA23298BDA9B32DEACB370BB05192D68F8A372AC376337017AC65B08CBAB24A75615B89E9D23C24B36A47312FA7915E842EAE7BB89C8A7D60ED8A8208B2B53A41664DBA6D0F66511F3BB80A21E0F812554F3FAC8D966332B6B76FA52E3FD3F065D8DD2C287FDEC06C5FCAD9DCC5E9319D3D119A1E23F45077080576D09F1233E7C1AB8C9DA3C898CA5BCBA2443C8077BFAEE2816C3BF54B4A3F51AADDA5BF72DF791C508761411210DA2E1513F3B36393E62692179DF39D563EDED84002EFE51E7DB3F1006473ECE8BE34B86D5FB313AB1E84E3D40E4C9328D7EBF6A2961EC56642222172708DB17006AA31C30C3E206FB2AFA3CEDFA615FF188A581844930C40AD3DDFACA2C238FEEA2349191AF8379F0BAFA487ED7CDBBD38726E9EC6CE137B33FC5C8620F053134291EA9C1AD4A447C2B8D00FB13C05AFC92746F88EFD2E35B39A18F1B3586A6AD1DC12B1DCA0D5B553CD4CC31E63340DD769DC8C1F40A785D42F16C36E1C29DC4EB464770FCA54586BD4563B83E15381167DECB63962359CCC836FBB367C78186D45BDDA8254952C76C30EDEBA5EFA0DB538C4969CF6EE4EAD7FC6B08D1B8E6DA1BCFFD2B38806926663A24B9CB004C1D3695B7072A4C95AEC078AF6FCC292F53B860A4E3E86656833B75F8661F381742A3D628F8B444257E81609566D76D6BBAC87817530065F8222237DAB1C0B39D4080177D558ABBCC991A0519A9703F2A43486EECEBC9BE02578287995A9183C04E353E5DEBB746E2EAAC8316DF517B00E8CFDB73F947F2A9B339915FA6D58EFFAAB9A219C57C20D696E582E5D084DAFA0A250B8A2B0CE9FF9D0D170399EA553D4A6E10A7F4653C030909E2F0261CDA09893E567682069F1C58EF848DC17B583B0E2522730944A931697E4FEEA8313E5B2D8DF708936EBC59677A446515597772076CF11AC3C86A540CFDEE5F425972E1CE8F71083C64F2B046F03BC44E9ABECFFF58223C61A43C3A6D011FE06CE82BF431ECC3ADBA29F747E6814400DDA77BCC4C1EB9AD60B395EBE7763CEC569B6EC6CF0958237CB0F61F5FB838D553CE66CADEF376EF4D63C52AF894D05CD283BCE855AF9D4F7B435B45238516C277C844376A5AE30F2F4486099DEFB1958954E4884ED1DEB5CDA6F87FCB3DC60042770A12ADB100AF2E88A32AB7C13F46B57C78C06D32FAFD449D1A131F01C8A712AAF93D78C2F35EA77AF260454D071A0A0C64B06EA8C813E73298EE9FDF0A1A7CBB7291841B01F1CC12EE0C5978FC7B51C4AAD36B169F8193ACAF09F2983296E3DF6BB590BF1D70D98006B9BEDA0705752AC0C9C000B5A8E9560E4A460C15A1096DDFEA465BC0D8BD4E28A01A41437DC987243EF973643D51AAA323AC6258E99666786EF58DB080CA6ED888E31D9D53504C6886977F9BFB12C82CF2A44366086D1B90F427BA80ED7350FD4D503CFBE03099F3509BB55FE0A257BD93FC868C29F1839609B1408B1C0A03B533A591843B7B08317AE7DC048147B950A885EF72EA39B3455073AE90E8C4DBCED8E17A0D28D7261AC5A715F3D4A6836BFB298A9E817F25169DF2A9157D541D201A115BFDB08E69D92FBFA6D2AAFF8F21BAE49142E63450BF4472645394D8D77DF7A4DB447D3A4D624F6647E0EDCB23C8F121720B9C22FD04DE869B65B6D44C98E89D86A1D1A150EAAF40E6811E53849E5FD8D6A599C9D12EC701FBE1280F9A8AA8E55744A96899B234547F04D59D4B23C9203073F6DE922A57A9D6BE70CBDAAC8D5B31637BB9B58EC87B22ACAFE390C48C853457B97E9E810C2AC03EBB74D9F7B660E4BA608ADD89FE6AC974C371054716B7068D2DA576A5436CA16B291B76F00F4A35CDBE58BB04387062930E89ED31F419337E8549E1DEE2BA17D4AA9B0206AEDA4017C47987E812853ED9BEC37C2ACA941147AF0627BDB893D90D8CB7CA1D363A2087D0652B70BCD4407A706C55FEBB77B916996023E04253F796F0818C4338B90E6471C912D22CA1FCFDAB2ADB0964EC9EB9D853DED8D1F62E0CBD19E1851E6BEB48D527174F6C3E3BD88E5E3FC11A440CBAEFFB7845F08BA75F0E08F0670AD934FDA161470B49A44E3ABDC709534BD28C0E02225B60CEE57151B5240608068F7E1C4314394B81C941904371E58038D3FDCA479A3857A6778C0D75C51E8625682AD9E25960E0073F4E96CCB8A6759C247A537B08A16BA49ABAC0793603D1CD4883C9DE90B2A3B5C998453868DE295B16FF22FB6F1D56222339F11AC6FAEF006507035B8AECAF1DB546307B63040"

	lrc, err := DecryptLRC(data)
	if err == nil {
		if lrc.Match(`Không gian quanh đây`) == true && lrc.Match(`rồi cũng sẽ quen dần`) == true {
			dna.Log("Success")
		} else {
			dna.Log("Failed")
		}
	}
	// Output:
	// Success
}
示例#6
0
func startVPN(vpnAppName, vpnAppUrl dna.String) chan *exec.Cmd {
	c := make(chan *exec.Cmd)
	dna.Log("Starting", vpnAppName)
	go func() {
		cmd := exec.Command(vpnAppUrl.String())
		c <- cmd
		err := cmd.Run()
		if err != nil {
			dna.Log(err.Error())
		}
	}()

	return c
}
示例#7
0
文件: album.go 项目: olragon/dna
func convertCategoryToStringArray(catStr dna.String) dna.StringArray {
	var cats []Category
	var ret = dna.StringArray{}
	err := json.Unmarshal([]byte(string(catStr)), &cats)
	if err != nil {
		dna.Log(catStr)
		dna.Log(err.Error())
		panic("Invalid category string input")
	} else {
		for _, cat := range cats {
			ret.Push(cat.Name)
		}
	}
	return ret
}
示例#8
0
文件: ref.go 项目: olragon/dna
func DumpFiles() {
	var ret = dna.StringArray{}
	for _, table := range GetAlbumTables().Concat(GetSongTables()).Concat(GetVideoTables()) {
		ret.Push(`"` + table + `"`)
	}
	dna.Log(ret.Join(","))
}
示例#9
0
func amRecovery() {
	// Recovering failed ambum ids
	db, err := sqlpg.Connect(sqlpg.NewSQLConfig(SqlConfigPath))
	dna.PanicError(err)
	siteConf, err := LoadSiteConfig("am", SiteConfigPath)
	siteConf.NConcurrent = 30
	dna.PanicError(err)

	// r := NewRange(20987, 30000)
	ids := amGetErrIds("./log/http_error.log", 1)
	tmp := ids.Unique()
	ids = &tmp
	if ids.Length() > 0 {
		state := NewStateHandlerWithExtSlice(new(am.APIAlbum), ids, siteConf, db)
		Update(state)
	} else {
		dna.Log("No need to recover file")
	}

	// Recover failed SQL statements
	RecoverErrorQueries(SqlErrorLogPath, db)

	CountDown(3*time.Second, QuittingMessage, EndingMessage)
	db.Close()
}
示例#10
0
// UpdateNhacvui gets lastest items from nhacvui.vn.
// The update process goes through 5 steps:
// 	Step 1: Initalizing db connection, loading site config and state handler.
// 	Step 2: Updating new songs.
// 	Step 3: Updating new albums.
// 	Step 4: Updating new videos from FoundVideos var.
// 	Step 5: Recovering failed sql statements.
func UpdateNhacvui() {
	db, err := sqlpg.Connect(sqlpg.NewSQLConfig(SqlConfigPath))
	dna.PanicError(err)
	siteConf, err := LoadSiteConfig("nv", SiteConfigPath)
	dna.PanicError(err)

	state := NewStateHandler(new(nv.Song), siteConf, db)
	Update(state)
	//  update album
	state = NewStateHandler(new(nv.Album), siteConf, db)
	Update(state)

	if nv.FoundVideos.Length() > 0 {
		state = NewStateHandlerWithExtSlice(new(nv.Video), nv.FoundVideos, siteConf, db)
		Update(state)
	} else {
		dna.Log("No videos found!")
	}

	RecoverErrorQueries(SqlErrorLogPath, db)

	time.Sleep(3 * time.Second)
	db.Close()

}
示例#11
0
文件: api_test.go 项目: olragon/dna
func ExampleGetAPIArtist() {
	_, err0 := GetAPIArtist(496741)
	if err0 == nil {
		panic("SongArtist id 496741 has to have an error")
	} else {
		if err0.Error() != "NCT - Artist ID:496741 not found" {
			panic("Wrong error message")
		}
	}
	artist, err := GetAPIArtist(49674)
	if err == nil {
		dna.LogStruct(artist)
	} else {
		dna.Log(err.Error())
	}
	if artist.Avatar != "" {
		artist.Avatar = "http://avatar.nct.nixcdn.com/singer/avatar/2013/12/16/7/f/f/7/1387176808800.jpg"
	}
	// Output:
	// Id : 49674
	// Name : "Đàm Vĩnh Hưng"
	// Avatar : "http://avatar.nct.nixcdn.com/singer/avatar/2014/13/7E4149A9_2.jpg"
	// NSongs : 0
	// NAlbums : 0
	// NVideos : 0
	// ObjType : "ARTIST"
}
示例#12
0
// UpdateSongFreaks gets lastest songs,albums,artists and videos from songfreaks.com
// The update process goes through 4 steps:
// 	Step 1: Initalizing db connection, loading site config and state handler.
// 	Step 2: Finding new songs, insert new albums,artists and videos if found.
// 	Step 3: Updating found new albums in Step 2.
// 	Step 4: Recovering failed sql statements in Step 2.
func UpdateSongFreaks() {
	db, err := sqlpg.Connect(sqlpg.NewSQLConfig(SqlConfigPath))
	dna.PanicError(err)
	siteConf, err := LoadSiteConfig("sf", SiteConfigPath)
	siteConf.NConcurrent = 20
	dna.PanicError(err)

	// Update new songs
	state := NewStateHandler(new(sf.APISongFreaksTrack), siteConf, db)
	state.TableName = "sfsongs"
	Update(state)

	// Update "ratings", "songids", "review_author", "review" of song
	ids := &[]dna.Int{}
	query := dna.Sprintf("SELECT id FROM sfalbums where checktime > '%v' AND array_length(songids, 1) is NULL", time.Now().Format("2006-01-02"))
	// dna.Log(query)
	err = db.Select(ids, query)
	if err != nil {
		dna.PanicError(err)
	}
	idsSlice := dna.IntArray(*ids)
	if idsSlice.Length() > 0 {
		state = NewStateHandlerWithExtSlice(new(sf.APISongFreaksAlbum), &idsSlice, siteConf, db)
		Update(state)

	} else {
		dna.Log("No new albums found")
	}

	// Recover failed sql statements
	RecoverErrorQueries(SqlErrorLogPath, db)

	CountDown(3*time.Second, QuittingMessage, EndingMessage)
	db.Close()
}
示例#13
0
文件: post_test.go 项目: olragon/dna
func ExampleGetAPIAlbum() {
	album, err := GetAPIAlbum(86682)

	if err == nil {
		if album.Plays < 44450 {
			panic("Plays has to be greater than 44450")
		}
		album.Plays = 44450
		for _, song := range album.SongList {
			song.Plays = 10129
		}
		var length = len(album.SongList)
		album.SongList = nil
		if album.Coverart == "" {
			panic("WRong covert")
		}
		album.Coverart = "http://media3.keeng.vn:8082/medias/images/images_thumb/f_medias_6/album/image/2014/01/10/27a4cdcbb7f60aa123529a49d76888708ec8872d_103_103.jpg"
		dna.LogStruct(album)
		dna.Log("Lenght :", length)
	} else {
		panic("Error has to be nil")
	}
	// Output:
	// Id : 86682
	// Title : "Chờ Hoài Giấc Mơ"
	// Artists : "Akio Lee ft Akira Phan"
	// Coverart : "http://media3.keeng.vn:8082/medias/images/images_thumb/f_medias_6/album/image/2014/01/10/27a4cdcbb7f60aa123529a49d76888708ec8872d_103_103.jpg"
	// Url : "http://keeng.vn/album/Cho-Hoai-Giac-Mo-Akio-Lee/2K2O4QG8.html"
	// Plays : 44450
	// SongList : []ke.APISong(nil)
	// Lenght : 5

}
示例#14
0
文件: user_test.go 项目: olragon/dna
func ExampleGetUsersWithInitialId() {
	UsersMagnitude = 10
	users, err := GetUsersWithInitialId(1)
	if err != nil {
		dna.PanicError(err)
	} else {
		if len(users.List) != 9 {
			dna.Log("Complete")
		} else {
			dna.Log("Not complete")
		}
	}
	// Output:
	// Complete

}
示例#15
0
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
}
示例#16
0
文件: helpers.go 项目: olragon/dna
// RecoverErrorQueries is a wrapper of RecoverSQLLogError.
// It prints some useful info to console.
func RecoverErrorQueries(path dna.String, db *sqlpg.DB) {
	dna.Print("Recovering all sql queries having errors")
	errCount := RecoverSQLLogError(path, db)
	if errCount == 0 {
		dna.Print(" => Completed!")
	} else {
		dna.Log("\nTotal error count:", errCount)
	}
}
示例#17
0
文件: func_test.go 项目: olragon/dna
func ExampleSelectMissingIds() {
	db, err := sqlpg.Connect(sqlpg.NewSQLConfig("./app.ini"))
	dna.PanicError(err)
	ids, err := SelectMissingIds("ziartists", &dna.IntArray{5, 6, 7, 8, 9}, db)
	dna.PanicError(err)
	dna.Log(ids)
	db.Close()
	// Output:
	// &dna.IntArray{8}
}
示例#18
0
文件: album.go 项目: olragon/dna
func getAlbumFromMainAPI(album *Album) <-chan bool {
	channel := make(chan bool, 1)
	go func() {
		var link dna.String = "http://apiv2.songfreaks.com//lyric.do?"
		// Log(link)
		PostData.SetIdKey(album.Id)
		dna.Log(PostData.Encode())
		result, err := Post(link, PostData.Encode())
		mutex.Lock()
		Cookie = result.Header.Get("Set-Cookie")
		mutex.Unlock()
		if err == nil {
			dna.Log(result.Data)
		}

		channel <- true
	}()
	return channel
}
示例#19
0
// UpdateZing gets lastest items from mp3.zing.vn.
// The update process goes through 8 steps:
// 	Step 1: Initalizing db connection, loading site config and state handler
// 	Step 1: Updating new songs
// 	Step 3: Updating new albums
// 	Step 4: Updating new videos
// 	Step 5: Updating new artists
// 	Step 6: Updating new songids found in new albums
// 	Step 7: Updating new tvs
// 	Step 8: Recovering failed sql statements
func UpdateZing() {
	db, err := sqlpg.Connect(sqlpg.NewSQLConfig(SqlConfigPath))
	dna.PanicError(err)
	siteConf, err := LoadSiteConfig("zi", SiteConfigPath)
	dna.PanicError(err)
	// update song
	state := NewStateHandler(new(zi.Song), siteConf, db)
	Update(state)
	// update album
	state = NewStateHandler(new(zi.Album), siteConf, db)
	Update(state)
	// update video
	state = NewStateHandler(new(zi.Video), siteConf, db)
	Update(state)
	// update artist
	state = NewStateHandler(new(zi.Artist), siteConf, db)
	Update(state)

	// update new songids found in albums
	dna.Log("Update new songs from albums")
	ids := utils.SelectNewSidsFromAlbums("zialbums", time.Now(), db)
	nids, err := utils.SelectMissingIds("zisongs", ids, db)
	if err != nil {
		dna.Log(err.Error())
	} else {
		if nids != nil && nids.Length() > 0 {
			state = NewStateHandlerWithExtSlice(new(zi.Song), nids, siteConf, db)
			Update(state)
		} else {
			dna.Log("No new songs found")
		}

	}

	state = NewStateHandler(new(zi.TV), siteConf, db)
	Update(state)

	RecoverErrorQueries(SqlErrorLogPath, db)

	time.Sleep(3 * time.Second)
	db.Close()
}
示例#20
0
func UpdateLyricFind(vpnAppName, vpnAppUrl dna.String, estConDuration time.Duration) {
	cmd := <-startVPN(vpnAppName, vpnAppUrl)
	CountDown(estConDuration*time.Second, "Establishing VPN connection. Estimated time remaining:", "")

	err := testingSongs()
	if err != nil {
		dna.Log("Error occurs: ", err.Error())
		dna.Log("Operation aborted!")
	} else {
		db, err := sqlpg.Connect(sqlpg.NewSQLConfig(SqlConfigPath))
		dna.PanicError(err)
		siteConf, err := LoadSiteConfig("lf", SiteConfigPath)
		dna.PanicError(err)

		state := NewStateHandler(new(lf.Song), siteConf, db)
		Update(state)

		RecoverErrorQueries(SqlErrorLogPath, db)
		CountDown(3*time.Second, QuittingMessage, EndingMessage)
		db.Close()
	}
	stopVPN(vpnAppName, cmd)
}
示例#21
0
文件: api_test.go 项目: olragon/dna
func ExampleGetAPISong() {
	_, err0 := GetAPISong(28760555)
	if err0 == nil {
		panic("Song id 28760555 has to have an error")
	} else {
		if err0.Error() != "NCT - Song ID:28760555 not found" {
			panic("Wrong error message")
		}
	}
	song, err := GetAPISong(2854574)
	if err == nil {
		if song.Likes < 277 || song.Plays < 416163 {
			panic("Cannot get song likes or plays")
		} else {
			song.Likes = 277
			song.Plays = 416163
		}
		if song.StreamUrl.Match(`\.mp3`) == false || song.Linkdown.Match(`\.mp3`) == false || song.LinkdownHQ.Match(`\.mp3`) == false {
			panic("Song link has to be mp3 format")
		} else {
			song.StreamUrl = "http://a.nixcdn.com/96e84c4eb0e143c6259c6ab2cb533c7a/52f83930/NhacCuaTui844/AnhBiet-HoQuangHieu-2854574.mp3"
			song.Linkdown = "http://download.a.nixcdn.com/96e84c4eb0e143c6259c6ab2cb533c7a/52f83930/NhacCuaTui844/AnhBiet-HoQuangHieu-2854574.mp3"
			song.LinkdownHQ = "http://download.a.nixcdn.com/5ee0ab8b469dc2c9cf9e93a98f46fa0b/52f83930/NhacCuaTui844/AnhBiet-HoQuangHieu-2854574_hq.mp3"
		}
		if song.Image != "" {
			song.Image = "http://avatar.nct.nixcdn.com/singer/avatar/2013/11/28/b/f/8/d/1385631181033.jpg"
		}
		dna.LogStruct(song)
	} else {
		dna.Log(err.Error())
	}
	// Output:
	// Id : 2854574
	// Key : "uUPvpEvU4CmH"
	// Title : "Anh Biết"
	// Artist : "Hồ Quang Hiếu"
	// Likes : 277
	// Plays : 416163
	// LinkShare : "http://www.nhaccuatui.com/bai-hat/anh-biet-ho-quang-hieu.uUPvpEvU4CmH.html"
	// StreamUrl : "http://a.nixcdn.com/96e84c4eb0e143c6259c6ab2cb533c7a/52f83930/NhacCuaTui844/AnhBiet-HoQuangHieu-2854574.mp3"
	// Image : "http://avatar.nct.nixcdn.com/singer/avatar/2013/11/28/b/f/8/d/1385631181033.jpg"
	// Coverart : ""
	// ObjType : "SONG"
	// Duration : 280
	// Linkdown : "http://download.a.nixcdn.com/96e84c4eb0e143c6259c6ab2cb533c7a/52f83930/NhacCuaTui844/AnhBiet-HoQuangHieu-2854574.mp3"
	// LinkdownHQ : "http://download.a.nixcdn.com/5ee0ab8b469dc2c9cf9e93a98f46fa0b/52f83930/NhacCuaTui844/AnhBiet-HoQuangHieu-2854574_hq.mp3"
}
示例#22
0
文件: api.go 项目: olragon/dna
func (apiVideo *APIVideo) FillVideo(video *Video) {
	video.Id = apiVideo.Id
	video.Key = apiVideo.Key
	video.Title = apiVideo.Title
	video.Image = apiVideo.Thumbnail // Image is for small image
	video.Thumbnail = apiVideo.Image // Thumbnail is for the large, kinda opposite
	// Getting dateCreated
	datecreatedArr := video.Thumbnail.FindAllStringSubmatch(`/([0-9]+)_[0-9]+\..+$`, -1)
	if len(datecreatedArr) > 0 {
		// Log(int64(datecreatedArr[0][1].ToInt()))
		video.DateCreated = time.Unix(int64(datecreatedArr[0][1].ToInt()/1000), 0)
	} else {
		dateCreatedArr := video.Thumbnail.FindAllStringSubmatch(`/?(\d{4}/\d{2}/\d{2})`, -1)
		if len(dateCreatedArr) > 0 {
			year := dateCreatedArr[0][1].FindAllStringSubmatch(`(\d{4})/\d{2}/\d{2}`, -1)[0][1].ToInt()
			month := dateCreatedArr[0][1].FindAllStringSubmatch(`\d{4}/(\d{2})/\d{2}`, -1)[0][1].ToInt()
			day := dateCreatedArr[0][1].FindAllStringSubmatch(`\d{4}/\d{2}/(\d{2})`, -1)[0][1].ToInt()
			video.DateCreated = time.Date(int(year), time.Month(month), int(day), 0, 0, 0, 0, time.UTC)
		}
	}
	video.Artists = apiVideo.Artist.Split(",").SplitWithRegexp(" & ")
	durationArr := apiVideo.Time.Split(":")
	switch durationArr.Length() {
	case 2:
		duration, err := time.ParseDuration((durationArr[0] + "m" + durationArr[1] + "s").String())
		if err == nil {
			video.Duration = dna.Int(int(duration.Seconds()))
		} else {
			dna.Log("Critical error: cannot parse duration of video id:", video.Id)
			dna.Log("\n\n\n")
			panic("Cannot parse duration")
		}
	case 3:
		duration, err := time.ParseDuration((durationArr[0] + "h" + durationArr[1] + "m" + durationArr[2] + "s").String())
		if err == nil {
			video.Duration = dna.Int(int(duration.Seconds()))
		} else {
			dna.Log("Critical error: cannot parse duration of video id:", video.Id)
			dna.Log("\n\n\n")
			panic("Cannot parse duration")
		}
	default:
		dna.Log("Critical error: Unknown duration format of video id:", video.Id)
		dna.Log("\n\n\n")
		panic("Cannot parse duration")
	}

	video.Artistid = apiVideo.Artistid
	video.Likes = apiVideo.Likes
	video.Plays = apiVideo.Plays
	video.LinkShare = apiVideo.Linkshare
	video.StreamUrl = apiVideo.StreamUrl
	video.Type = apiVideo.ObjType
}
示例#23
0
func getType(str dna.String) dna.String {
	switch {
	case str.Match(`(?mis)MP3`) == true:
		return "mp3"
	case str.Match(`(?mis)M4A`) == true:
		return "m4a"
	case str.Match(`(?mis)MP4`) == true:
		return "mp4"
	case str.Match(`(?mis)FLAC`) == true:
		return "flac"
	case str.Match(`(?mis)FLV`) == true:
		return "flv"
	default:
		dna.Log("No type found at: " + str.String())
		return ""
	}
}
示例#24
0
文件: funcs.go 项目: olragon/dna
// ExecQueriesInTransaction executes queries in a transaction.
// If one statement fails, the whole queries cannot commit.
//
// The returned error is nil if there is no error.
// If an error occurs, each statement will be enclosed in
// format $$$error$$$.
// 	$$$error$$$ Your Custom Query $$$error$$$
//
// This function is seen in songfreaks and allmusic sites.
func ExecQueriesInTransaction(db *DB, queries *dna.StringArray) error {
	var err error
	globalSqlTransactoNo += 1
	// tx, err := db.Begin()
	// if err != nil {
	// 	dna.Log("Transaction No:" + dna.Sprintf("%v", globalSqlTransactoNo).String() + err.Error() + " Could not create transaction\n")
	// }

	for idx, query := range *queries {
		_, err = db.Exec(query.String())
		// _, err = tx.Exec(query.String())
		if err != nil {
			dna.Log(dna.Sprintf("DNAError: Query series No: %v - %v - %v - %v\n", dna.Sprintf("%v", globalSqlTransactoNo), idx, err.Error(), "Could not execute the statement"))
		}
		// stmt, err := tx.Prepare(query.String())
		// if err != nil {
		// 	dna.Log(dna.Sprintf("DNAError Transaction No: %v - %v - %v - %v \n", dna.Sprintf("%v", globalSqlTransactoNo), idx, err.Error(), "Could not prepare"))
		// } else {
		// 	_, err = stmt.Exec()
		// 	if err != nil {
		// 		dna.Log(dna.Sprintf("DNAError: Transaction No: %v - %v - %v - %v\n", dna.Sprintf("%v", globalSqlTransactoNo), idx, err.Error(), "Could not execute the prepared statement"))
		// 	}

		// 	err = stmt.Close()
		// 	if err != nil {
		// 		dna.Log("Transaction No:" + dna.Sprintf("%v", globalSqlTransactoNo).String() + err.Error() + " Could not close\n")
		// 	}
		// }
	}
	// err = tx.Commit()
	// if err != nil {
	// 	dna.Log("Transaction No:" + dna.Sprintf("%v", globalSqlTransactoNo).String() + err.Error() + " Could not commit transaction\n")
	// }

	if err != nil {
		errQueries := dna.StringArray(queries.Map(func(val dna.String, idx dna.Int) dna.String {
			return "Transaction No:" + dna.Sprintf("%v", globalSqlTransactoNo) + " $$$error$$$" + val + "$$$error$$$"
		}).([]dna.String))
		return errors.New(err.Error() + errQueries.Join("\n").String())
	} else {
		return nil
	}
}
示例#25
0
文件: api_test.go 项目: olragon/dna
func ExampleGetAPIAlbum() {
	_, err0 := GetAPIAlbum(28760555)
	if err0 == nil {
		panic("Album id 28760555 has to have an error")
	} else {
		if err0.Error() != "NCT - Album ID:28760555 not found" {
			panic("Wrong error message")
		}
	}
	album, err := GetAPIAlbum(12255234)
	if err == nil {
		if album.Likes < 128 || album.Plays < 320384 {
			panic("Cannot get album likes or plays")
		} else {
			album.Likes = 128
			album.Plays = 320384
		}
		if len(album.Listsong) != 3 {
			panic("Songs of the album has to have length equal to 3")
		} else {
			album.Listsong = []APISong{}
		}
		dna.LogStruct(album)
	} else {
		dna.Log(err.Error())
	}
	// Output:
	// Id : 12255234
	// Key : "nsnkteavOHbX"
	// Title : "Biết Trước Sẽ Không Mất Nhau (Single)"
	// Thumbnail : "http://avatar.nct.nixcdn.com/playlist/2013/11/28/4/e/9/b/1385644142690_300.jpg"
	// Coverart : "http://avatar.nct.nixcdn.com/playlist/2013/11/28/4/e/9/b/1385644142690_500.jpg"
	// Image : "http://avatar.nct.nixcdn.com/playlist/2013/11/28/4/e/9/b/1385644142690_300.jpg"
	// Artist : "Vĩnh Thuyên Kim, Hồ Quang Hiếu"
	// Likes : 128
	// Plays : 320384
	// Linkshare : "http://www.nhaccuatui.com/playlist/biet-truoc-se-khong-mat-nhau-single-vinh-thuyen-kim-ho-quang-hieu.nsnkteavOHbX.html"
	// Listsong : []nct.APISong{}
	// Description : "Sau sự kết hợp thành công cùng các nữ ca sĩ xinh đẹp trong thời gian gần đây như: Bảo Thy, Nhật Kim Anh, Lương Khánh Vy... Chàng hotboy Hồ Quang Hiếu có sự kết hợp mới cùng Vĩnh Thuyên Kim trong một sáng tác của Lê Chí Trung \"Biết Trước Sẽ Không Mất Nhau\"."
	// Genre : "Nhạc Trẻ"
	// ObjType : "PLAYLIST"
}
示例#26
0
文件: func.go 项目: olragon/dna
// ForeachLine loops through every line a file.
// An anynomous input function has line, index as params
func ForeachLine(filePath dna.String, lineFunc func(dna.String, dna.Int)) {

	var err error
	var line []byte
	f, err := os.Open(filePath.String())
	if err != nil {
		dna.Log("error opening file: %v\n", err)
		os.Exit(1)
	}
	defer f.Close()
	r := bufio.NewReaderSize(f, 4*1024)

	i := 0
	err = nil
	for err == nil {
		i += 1
		line, _, err = r.ReadLine()
		lineFunc(dna.String(string(line)), dna.Int(i))
	}
}
示例#27
0
文件: post_test.go 项目: olragon/dna
func ExampleGetAPIArtistVideos() {
	apiArtistVideos, err := GetAPIArtistVideos(1394, 1, 1)
	if err == nil {
		if len(apiArtistVideos.Data) != 1 {
			panic("Lenght of artist songs has to be one")
		}
		video := &apiArtistVideos.Data[0]
		if video.Plays == 0 {
			dna.Log("Plays has to be greater different from 0")
		}
		video.Plays = 1010
		switch {
		case video.Link == "", video.DownloadUrl == "", video.Url == "":
			panic("Wrong urls")
		}
		dna.LogStruct(video)
	} else {
		panic("Error has to be nil")
	}
}
示例#28
0
func (alca *AlbumCategory) Save(db *sqlpg.DB) error {

	var last error
	var aids = dna.IntArray{}
	albums := &[]Album{}
	for _, album := range *(alca.Albums) {
		aids.Push(album.Id)
		// dna.Log(album)
	}
	query := "SELECT id, topics, genres from nsalbums WHERE id IN (" + aids.Join(",") + ")"
	// dna.Log(query)
	err := db.Select(albums, query)
	if err != nil {
		dna.Log(query, alca, *alca.Albums)
		dna.PanicError(err)
	}

	for _, album := range *(alca.Albums) {
		foundIndex := 0
		for j, anotherAlbum := range *(albums) {
			if album.Id == anotherAlbum.Id {
				foundIndex = j
			}
		}
		if foundIndex < len(*albums) {
			cat := album.Category.Concat((*albums)[foundIndex].Topics).Concat((*albums)[foundIndex].Genres).Unique()
			album.Category = cat.Filter(func(v dna.String, i dna.Int) dna.Bool {
				if v != "" {
					return true
				} else {
					return false
				}
			})

		}
		last = db.Update(album, "id", "category")

	}

	return last
}
示例#29
0
文件: api_test.go 项目: olragon/dna
func ExampleGetAPIVideo() {
	_, err0 := GetAPIVideo(28760555)
	if err0 == nil {
		panic("Video id 28760555 has to have an error")
	} else {
		if err0.Error() != "NCT - Video ID:28760555 not found" {
			panic("Wrong error message")
		}
	}
	video, err := GetAPIVideo(2876055)
	if err == nil {
		if video.Likes < 1474 || video.Plays < 556700 {
			panic("Cannot get video likes or plays")
		} else {
			video.Likes = 1474
			video.Plays = 556700
		}
		if video.StreamUrl.Match(`\.mp4`) == false {
			panic("Video link has to be mp4 format")
		} else {
			video.StreamUrl = "http://nplus.nixcdn.com/bd4aa514acf9173ca298424dce992639/52f83228/PreNCT7/GuiChoAnhPhan2-KhoiMy-2876055.mp4"
		}
		dna.LogStruct(video)
	} else {
		dna.Log(err.Error())
	}
	// Output:
	// Id : 2876055
	// Key : "N5QeESGm7ICBt"
	// Title : "Gửi Cho Anh (Phần 2)"
	// Thumbnail : "http://avatar.nct.nixcdn.com/mv/2013/12/10/e/0/5/3/1386640122904.jpg"
	// Image : "http://avatar.nct.nixcdn.com/mv/2013/12/10/e/0/5/3/1386640122904_536.jpg"
	// Artist : "Khởi My"
	// Time : "46:08"
	// Artistid : 12987
	// Likes : 1474
	// Plays : 556700
	// Linkshare : "http://www.nhaccuatui.com/video/gui-cho-anh-phan-2-khoi-my.N5QeESGm7ICBt.html"
	// StreamUrl : "http://nplus.nixcdn.com/bd4aa514acf9173ca298424dce992639/52f83228/PreNCT7/GuiChoAnhPhan2-KhoiMy-2876055.mp4"
	// ObjType : "VIDEO"
}
示例#30
0
文件: apisong.go 项目: olragon/dna
func (apiSong *APISong) FillSong(song *Song) {
	song.Id = apiSong.Track.Amg
	song.Title = apiSong.Track.Title
	song.Artists = apiSong.Track.Artist.Name.Split(" and ").SplitWithRegexp(", ")
	song.Instrumental = apiSong.Track.Instrumental
	song.Viewable = apiSong.Track.Viewable
	song.HasLrc = apiSong.Track.HasLrc
	song.LrcVerified = apiSong.Track.LrcVerified
	song.Lyric = apiSong.Track.Lyrics
	song.Copyright = apiSong.Track.Copyright
	song.Writers = apiSong.Track.Writer
	// Mon Jan 2 15:04:05 MST 2006
	if apiSong.Track.LastUpdate != "" {
		lastUpdate, err := time.Parse("2006-01-02 15:04:05", apiSong.Track.LastUpdate.String())
		if err == nil {
			song.DateUpdated = lastUpdate
		} else {
			dna.Log(err.Error(), " Song ID:", song.Id, " GOT:", apiSong.Track.LastUpdate, "\n\n")
		}
	}
}