Automatic media analysis for new items
This commit is contained in:
@@ -27,6 +27,7 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
|
||||
var mergeChan = make(chan *Torrent, len(instances))
|
||||
|
||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||
oldKeys := mapset.NewSet[string](allTorrents.Keys()...)
|
||||
|
||||
freshIDs := mapset.NewSet[string]()
|
||||
freshAccessKeys := mapset.NewSet[string]()
|
||||
@@ -87,9 +88,20 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
|
||||
t.assignDirectory(mainTorrent, !initialRun)
|
||||
}
|
||||
|
||||
// new torrents
|
||||
t.workerPool.Submit(func() {
|
||||
if !t.hasFFprobe {
|
||||
return
|
||||
}
|
||||
freshAccessKeys.Difference(oldKeys).Each(func(accessKey string) bool {
|
||||
torrent, _ := allTorrents.Get(accessKey)
|
||||
t.applyMediaInfoDetails(torrent)
|
||||
return false
|
||||
})
|
||||
})
|
||||
|
||||
// removed torrents
|
||||
oldPlusNewKeys := mapset.NewSet[string](allTorrents.Keys()...)
|
||||
oldPlusNewKeys.Difference(freshAccessKeys).Each(func(accessKey string) bool {
|
||||
oldKeys.Difference(freshAccessKeys).Each(func(accessKey string) bool {
|
||||
t.Delete(accessKey, false)
|
||||
return false
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user