Skip to content

Commit

Permalink
go version upd & warn fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
mejgun committed Aug 14, 2021
1 parent a5105dd commit 96796bf
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
bin/
bin/
all.md5
25 changes: 13 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ GoBin=go
BinDir="bin"
FilePrefix="yt-proxy"

OSListStr="aix android darwin dragonfly freebsd hurd illumos js linux nacl netbsd openbsd plan9 solaris windows zos"
OSListStr="aix android darwin dragonfly freebsd hurd illumos ios js linux nacl netbsd openbsd plan9 solaris windows zos"
OSList=($OSListStr)

ArchListStr="386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm"
ArchListStr="386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le loong64 mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm"
ArchList=($ArchListStr)

Total=$((${#OSList[@]}*${#ArchList[@]}))
Total=$((${#OSList[@]} * ${#ArchList[@]}))
Md5File="all.md5"

mkdir -p ${BinDir}
for OS in ${OSListStr}
do
for ARCH in ${ArchListStr}
do
date >${Md5File}

mkdir -p ${BinDir} || exit
rm ${BinDir}/${FilePrefix}* -rf || exit
for OS in ${OSListStr}; do
for ARCH in ${ArchListStr}; do
echo $Total ${OS}/${ARCH}
File=${FilePrefix}-${OS}-${ARCH}
GOPATH=$(pwd) GOOS=${OS} GOARCH=${ARCH} $GoBin build -ldflags '-s -w' -o ${BinDir}/${File} > /dev/null 2>&1 && cd ${BinDir} && md5sum ${File} > ${File}.md5sum && cd ..
((Total=Total-1))
File=${FilePrefix}-${OS}-${ARCH}
GOOS=${OS} GOARCH=${ARCH} $GoBin build -ldflags '-s -w' -o ${BinDir}/${File} >/dev/null 2>&1 && cd ${BinDir} && md5sum ${File} >>../${Md5File} && cd ..
((Total = Total - 1))
done
done

3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module yt-proxy

go 1.16
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func runCmd(cmd *exec.Cmd) (string, error) {
cmd.Stderr = &stderr
err := cmd.Run()
toS := func(s bytes.Buffer) string {
return strings.TrimSpace(string(s.Bytes()))
return strings.TrimSpace(s.String())
}
outStr, errStr := toS(stdout), toS(stderr)
if err != nil {
Expand Down
15 changes: 10 additions & 5 deletions streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
)

const appVersion = "0.6"
const appVersion = "0.6.1"

const defaultVideoHeight = "720"
const defaultVideoFormat = "mp4"
Expand All @@ -32,8 +32,7 @@ func main() {
} else {
extractor = getYTDL()
}
var requests chan requestChan
requests = make(chan requestChan)
var requests = make(chan requestChan)
var links linksCache
links.cache = make(map[string]lnkT)
debug := getDebugFunc(flags.enableDebug)
Expand Down Expand Up @@ -129,7 +128,10 @@ func playVideo(
if res.StatusCode == 206 {
w.WriteHeader(http.StatusPartialContent)
}
io.Copy(w, res.Body)
_, err = io.Copy(w, res.Body)
if err != nil {
log.Println("Proxy error", err)
}
log.Printf("%s disconnected\n", req.RemoteAddr)
}

Expand Down Expand Up @@ -162,7 +164,10 @@ func getSendErrorVideoFunc(errorHeaders bool, errorVideo corruptedT) sendErrorVi
w.Header().Set(hdrs[i], errs[i])
}
}
w.Write(errorVideo.file)
_, err = w.Write(errorVideo.file)
if err != nil {
log.Println("Cannot send error video", err)
}
}
}

Expand Down

0 comments on commit 96796bf

Please sign in to comment.