Skip to content

Commit

Permalink
Only return title in search function
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecold committed Nov 23, 2015
1 parent dd33ae3 commit d919ec6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ go:
- tip
script:
- go get github.com/KeluDiao/gotube
- go test -v
- go test -v
branches:
only:
- master
37 changes: 22 additions & 15 deletions script.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,22 @@ func main() {
wg.Add(len(ids))
//Channel is used to control the maximum threads
end := make(chan bool, MaxParallelism())
for _, vid := range ids {
for idx, vid := range ids {
vl, err = GetVideoListFromId(vid)
if err != nil {
log.Fatal(err)
}
go Exec(vl, *isDownload, *isRetList, *rep, *quality, *extension, wg, end)
end <- true
if *isDownload {
go Exec(vl, *isDownload, *isRetList, *rep, *quality, *extension, wg, end)
end <- true
} else {
fmt.Printf("%v. %v\n", idx+1, vl.Title)
}
}
if *isDownload {
wg.Wait()
}
wg.Wait()

return
}
if err != nil {
Expand All @@ -107,13 +114,13 @@ func main() {

/*
* Choose either downloading or retrieving video list
*/
*/
func Exec(vl VideoList, isDownload, isRetList bool, rep, quality, extension string, wg *sync.WaitGroup, end chan bool) {
//Set up synchronization function
defer func() {
<- end
<-end
wg.Done()
} ()
}()

if isDownload {
fmt.Printf("Downloading %v...\n", vl.Title)
Expand All @@ -133,12 +140,12 @@ func Exec(vl VideoList, isDownload, isRetList bool, rep, quality, extension stri

/*
* Find out the maximum go routines allowed
*/
*/
func MaxParallelism() int {
maxProcs := runtime.GOMAXPROCS(0)
numCPU := runtime.NumCPU()
if maxProcs < numCPU {
return maxProcs
}
return numCPU
}
maxProcs := runtime.GOMAXPROCS(0)
numCPU := runtime.NumCPU()
if maxProcs < numCPU {
return maxProcs
}
return numCPU
}

0 comments on commit d919ec6

Please sign in to comment.