Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
himananiito committed Oct 7, 2018
1 parent 3799af6 commit 0fd4c2e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 37 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
更新履歴

20181008.33
・[Youtube] チャットが取得できない問題を修正
・[Youtube] Streamlinkでダウンロードできない場合にyoutube-dlを使うようにした
・[Youtube] コメントファイルを書き出せるようにした。
・#15 [ニコ生コメント] 出力をCRLFにした。/hbコマンドを出さないオプションを追加

20181003.32
・#14 ★緊急 [ニコ生] 新配信録画のプレイリスト取得にウェイトが入らない問題を修正
・#9 [ニコ生TS] プレイリストの最後で無限ループしてしまう問題を修正
Expand Down
4 changes: 2 additions & 2 deletions src/buildno/buildno.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package buildno

var BuildDate = "20181003"
var BuildNo = "32"
var BuildDate = "20181008"
var BuildNo = "33"
3 changes: 2 additions & 1 deletion src/buildno/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (

func GetBuildNo() string {
return fmt.Sprintf(
"%v.%v-%s",
"%v.%v-%s-%s",
BuildDate,
BuildNo,
runtime.GOOS,
runtime.GOARCH,
)
}
21 changes: 19 additions & 2 deletions src/niconico/nico_hls.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,11 +948,16 @@ func getBytes(uri string) (code int, buff []byte, t int64, err, neterr error) {

func (hls *NicoHls) saveMedia(seqno int, uri string) (is403, is404, is500 bool, neterr, err error) {

var timePassed []int64
if hls.nicoDebug {
timePassed = append(timePassed, time.Now().UnixNano())

start := time.Now().UnixNano()
defer func() {
t := (time.Now().UnixNano() - start) / (1000 * 1000)
fmt.Fprintf(os.Stderr, "%s:saveMedia: seqno=%d, total %d(ms)\n", debug_Now(), seqno, t)
now := time.Now().UnixNano()
timePassed = append(timePassed, now)
t := (now - start) / (1000 * 1000)
fmt.Fprintf(os.Stderr, "%s:saveMedia: seqno=%d, total %d(ms) %v\n", debug_Now(), seqno, t, timePassed)
}()
}

Expand All @@ -975,7 +980,13 @@ func (hls *NicoHls) saveMedia(seqno int, uri string) (is403, is404, is500 bool,
"current": hls.playlist.seqNo,
"notfound": 1,
}
if hls.nicoDebug {
timePassed = append(timePassed, time.Now().UnixNano())
}
hls.dbInsert("media", data)
if hls.nicoDebug {
timePassed = append(timePassed, time.Now().UnixNano())
}
hls.memdbSet404(seqno)
is404 = true
return
Expand All @@ -1000,7 +1011,13 @@ func (hls *NicoHls) saveMedia(seqno int, uri string) (is403, is404, is500 bool,
}
}

if hls.nicoDebug {
timePassed = append(timePassed, time.Now().UnixNano())
}
hls.dbReplace("media", data)
if hls.nicoDebug {
timePassed = append(timePassed, time.Now().UnixNano())
}
hls.memdbSet200(seqno)

return
Expand Down
56 changes: 28 additions & 28 deletions src/niconico/nico_mem_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ func (hls *NicoHls) memdbCreate() (err error) {
return
}
func (hls *NicoHls) memdbSetStopBack(seqno int) {
hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

if hls.nicoDebug {
start := time.Now().UnixNano()
defer func() {
t := (time.Now().UnixNano() - start) / (1000 * 1000)
if t > 100 {
fmt.Fprintf(os.Stderr, "%s:[WARN]memdbSetStopBack: %d(ms)\n", debug_Now(), t)
fmt.Fprintf(os.Stderr, "%s:[WARN][MEMDB]memdbSetStopBack: %d(ms)\n", debug_Now(), t)
}
}()
}

hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

_, err := hls.memdb.Exec(`
INSERT OR IGNORE INTO media (seqno, stopback) VALUES (?, 1);
UPDATE media SET stopback = 1 WHERE seqno=?;
Expand All @@ -104,102 +104,102 @@ func (hls *NicoHls) memdbSetStopBack(seqno int) {
}
}
func (hls *NicoHls) memdbGetStopBack(seqno int) (res bool) {
hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

if hls.nicoDebug {
start := time.Now().UnixNano()
defer func() {
t := (time.Now().UnixNano() - start) / (1000 * 1000)
if t > 100 {
fmt.Fprintf(os.Stderr, "%s:[WARN]memdbGetStopBack: %d(ms)\n", debug_Now(), t)
fmt.Fprintf(os.Stderr, "%s:[WARN][MEMDB]memdbGetStopBack: %d(ms)\n", debug_Now(), t)
}
}()
}

hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

hls.memdb.QueryRow("SELECT IFNULL(stopback, 0) FROM media WHERE seqno=?", seqno).Scan(&res)
return
}
func (hls *NicoHls) memdbSet200(seqno int) {
hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

if hls.nicoDebug {
start := time.Now().UnixNano()
defer func() {
t := (time.Now().UnixNano() - start) / (1000 * 1000)
if t > 100 {
fmt.Fprintf(os.Stderr, "%s:[WARN]memdbSet200: %d(ms)\n", debug_Now(), t)
fmt.Fprintf(os.Stderr, "%s:[WARN][MEMDB]memdbSet200: %d(ms)\n", debug_Now(), t)
}
}()
}

hls.memdb.Exec(`INSERT OR REPLACE INTO media (seqno, is200) VALUES (?, 1)`, seqno)
}
func (hls *NicoHls) memdbSet404(seqno int) {
hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

hls.memdb.Exec(`INSERT OR REPLACE INTO media (seqno, is200) VALUES (?, 1)`, seqno)
}
func (hls *NicoHls) memdbSet404(seqno int) {
if hls.nicoDebug {
start := time.Now().UnixNano()
defer func() {
t := (time.Now().UnixNano() - start) / (1000 * 1000)
if t > 100 {
fmt.Fprintf(os.Stderr, "%s:[WARN]memdbSet404: %d(ms)\n", debug_Now(), t)
fmt.Fprintf(os.Stderr, "%s:[WARN][MEMDB]memdbSet404: %d(ms)\n", debug_Now(), t)
}
}()
}

hls.memdb.Exec(`INSERT OR REPLACE INTO media (seqno, is404) VALUES (?, 1)`, seqno)
}
func (hls *NicoHls) memdbCheck200(seqno int) (res bool) {
hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

hls.memdb.Exec(`INSERT OR REPLACE INTO media (seqno, is404) VALUES (?, 1)`, seqno)
}
func (hls *NicoHls) memdbCheck200(seqno int) (res bool) {
if hls.nicoDebug {
start := time.Now().UnixNano()
defer func() {
t := (time.Now().UnixNano() - start) / (1000 * 1000)
if t > 100 {
fmt.Fprintf(os.Stderr, "%s:[WARN]memdbCheck200: %d(ms)\n", debug_Now(), t)
fmt.Fprintf(os.Stderr, "%s:[WARN][MEMDB]memdbCheck200: %d(ms)\n", debug_Now(), t)
}
}()
}

hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

hls.memdb.QueryRow("SELECT IFNULL(is200, 0) FROM media WHERE seqno=?", seqno).Scan(&res)
return
}
func (hls *NicoHls) memdbDelete(seqno int) {
hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

if hls.nicoDebug {
start := time.Now().UnixNano()
defer func() {
t := (time.Now().UnixNano() - start) / (1000 * 1000)
if t > 100 {
fmt.Fprintf(os.Stderr, "%s:[WARN]memdbDelete: %d(ms)\n", debug_Now(), t)
fmt.Fprintf(os.Stderr, "%s:[WARN][MEMDB]memdbDelete: %d(ms)\n", debug_Now(), t)
}
}()
}

hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

min := seqno - 100
hls.memdb.Exec(`DELETE FROM media WHERE seqno < ?`, min)
}
func (hls *NicoHls) memdbCount() (res int) {
hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

if hls.nicoDebug {
start := time.Now().UnixNano()
defer func() {
t := (time.Now().UnixNano() - start) / (1000 * 1000)
if t > 100 {
fmt.Fprintf(os.Stderr, "%s:[WARN]memdbCount: %d(ms)\n", debug_Now(), t)
fmt.Fprintf(os.Stderr, "%s:[WARN][MEMDB]memdbCount: %d(ms)\n", debug_Now(), t)
}
}()
}

hls.memdbMtx.Lock()
defer hls.memdbMtx.Unlock()

hls.memdb.QueryRow("SELECT COUNT(seqno) FROM media").Scan(&res)
return
}
2 changes: 1 addition & 1 deletion src/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ COMMAND:
-nico-auto-delete-mode 2 (+) 自動変換でMP4が分割されても削除するように設定
-nico-force-reservation=on (+) 視聴にタイムシフト予約が必要な場合に自動的に上書きする
-nico-force-reservation=off (+) 自動的にタイムシフト予約しない(デフォルト)
-nico-skip-hb=(on|off) (+) コメント書き出し時に/hbコマンドを出さない
-nico-skip-hb=(on|off) (+) コメント書き出し時に/hbコマンドを出さない
ツイキャス録画用オプション:
-tcas-retry=on (+) 録画終了後に再試行を行う
Expand Down
2 changes: 1 addition & 1 deletion src/youtube/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func getComment(gm *gorman.GoroutineManager, ctx context.Context, sig <-chan str
}

if continuations, ok := objs.Find(liveChatContinuation, "continuations"); ok {
objs.PrintAsJson(continuations)
//objs.PrintAsJson(continuations)

if c, ok := objs.FindString(continuations, "timedContinuationData", "continuation"); ok {
continuation = c
Expand Down
14 changes: 12 additions & 2 deletions src/youtube/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,13 @@ func execStreamlink(gm *gorman.GoroutineManager, uri, name string) (notSupport b

notSupport = true
procs.Kill(cmd.Process.Pid)
break
} else if strings.HasPrefix(s, "Traceback (most recent call last):") {
fmt.Print(s)

notSupport = true
//procs.Kill(cmd.Process.Pid)
//break
} else {
fmt.Print(s)
}
Expand Down Expand Up @@ -371,9 +377,11 @@ func Record(id string, ytNoStreamlink, ytNoYoutube_dl bool) (err error) {

ctx, cancel := context.WithCancel(context.Background())

var interrupt bool
gm.Go(func(c <-chan struct{}) int {
select {
case <-chInterrupt:
interrupt = true
case <-c:
}

Expand Down Expand Up @@ -401,8 +409,10 @@ func Record(id string, ytNoStreamlink, ytNoYoutube_dl bool) (err error) {
if (! ytNoStreamlink) {
retry, err = execStreamlink(gm, uri, name)
}
if err != nil || retry || (ytNoStreamlink && (! ytNoYoutube_dl)) {
execYoutube_dl(gm, uri, name)
if !interrupt {
if err != nil || retry || (ytNoStreamlink && (! ytNoYoutube_dl)) {
execYoutube_dl(gm, uri, name)
}
}

if continuation != "" {
Expand Down

0 comments on commit 0fd4c2e

Please sign in to comment.