Skip to content

Commit

Permalink
修正电视剧合集
Browse files Browse the repository at this point in the history
  • Loading branch information
fengqi committed May 21, 2023
1 parent c59174f commit 2861fc7
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions shows/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (c *Collector) showsDirProcess() {

dir.downloadImage(detail)

files := make(map[int]map[string]*File, 0)
if dir.IsCollection { // 合集
subDir, err := c.scanDir(dir.GetFullDir())
if err != nil {
Expand All @@ -71,26 +70,29 @@ func (c *Collector) showsDirProcess() {
}

for _, item := range subDir {
subFiles, err := c.scanShowsFile(item)
err := c.watcher.Add(item.Dir + "/" + item.OriginTitle)
utils.Logger.DebugF("runCronScan add shows dir: %s to watcher", item.Dir+"/"+item.OriginTitle)
if err != nil {
utils.Logger.ErrorF("scan collection sub dir: %s err: %v", item.OriginTitle, err)
continue
utils.Logger.FatalF("add shows dir: %s to watcher err: %v", item.Dir+"/"+item.OriginTitle, err)
}

if len(subFiles) > 0 {
files[item.Season] = subFiles
}
}
} else { // 普通剧集
subFiles, err := c.scanShowsFile(dir)
if err != nil {
utils.Logger.ErrorF("scan shows dir: %s err: %v", dir.OriginTitle, err)
continue
item.TvId = dir.TvId
c.dirChan <- item
}

if len(subFiles) > 0 {
files[dir.Season] = subFiles
}
continue
}

// 普通剧集
subFiles, err := c.scanShowsFile(dir)
if err != nil {
utils.Logger.ErrorF("scan shows dir: %s err: %v", dir.OriginTitle, err)
continue
}

files := make(map[int]map[string]*File, 0)
if len(subFiles) > 0 {
files[dir.Season] = subFiles
}

if len(files) == 0 {
Expand Down Expand Up @@ -250,6 +252,14 @@ func (c *Collector) runCronScan() {
utils.Logger.FatalF("add shows dir: %s to watcher err: %v", showDir.Dir+"/"+showDir.OriginTitle, err)
}

// 预留50%空间给可能重新放回队列的任务
for {
if len(c.dirChan) < 100*0.5 {
break
}
time.Sleep(time.Second * 2)
}

c.dirChan <- showDir
}
}
Expand Down

0 comments on commit 2861fc7

Please sign in to comment.