Update supported video extensions
This commit is contained in:
@@ -539,14 +539,14 @@ func checkArithmeticSequenceInFilenames(files []string) bool {
|
|||||||
}
|
}
|
||||||
r := regexp.MustCompile(`\d+`)
|
r := regexp.MustCompile(`\d+`)
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if !utils.IsPlayable(file) {
|
if !utils.IsVideo(file) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
matches := r.FindAllStringIndex(file, -1)
|
matches := r.FindAllStringIndex(file, -1)
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
numSet := make(map[int]struct{})
|
numSet := make(map[int]struct{})
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if !utils.IsPlayable(file) {
|
if !utils.IsVideo(file) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if match[0] >= 0 && match[1] <= len(file) {
|
if match[0] >= 0 && match[1] <= len(file) {
|
||||||
|
|||||||
@@ -233,8 +233,8 @@ func (t *TorrentManager) writeTorrentToFile(torrent *Torrent) {
|
|||||||
func (t *TorrentManager) applyMediaInfoDetails(torrent *Torrent) {
|
func (t *TorrentManager) applyMediaInfoDetails(torrent *Torrent) {
|
||||||
changesApplied := false
|
changesApplied := false
|
||||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||||
isPlayable := utils.IsPlayable(file.Path) || t.IsPlayable(file.Path)
|
isPlayable := utils.IsVideo(file.Path) || t.IsPlayable(file.Path)
|
||||||
if file.MediaInfo != nil || file.State.Is("broken_file") || !isPlayable {
|
if file.MediaInfo != nil || !file.State.Is("ok_file") || !isPlayable {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
unrestrict := t.UnrestrictFileUntilOk(file, true)
|
unrestrict := t.UnrestrictFileUntilOk(file, true)
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool) {
|
|||||||
if file.MediaInfo != nil {
|
if file.MediaInfo != nil {
|
||||||
mediaInfos = append(mediaInfos, file.MediaInfo)
|
mediaInfos = append(mediaInfos, file.MediaInfo)
|
||||||
}
|
}
|
||||||
if utils.IsPlayable(file.Path) || t.IsPlayable(file.Path) {
|
if utils.IsVideo(file.Path) || t.IsPlayable(file.Path) {
|
||||||
unplayable = false
|
unplayable = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ func (t *TorrentManager) repair(torrent *Torrent, wg *sync.WaitGroup) {
|
|||||||
// check if broken files are playable
|
// check if broken files are playable
|
||||||
allPlayable := true
|
allPlayable := true
|
||||||
for _, file := range brokenFiles {
|
for _, file := range brokenFiles {
|
||||||
if utils.IsPlayable(file.Path) {
|
if utils.IsVideo(file.Path) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,7 +394,7 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
|
|||||||
if action == "extract" {
|
if action == "extract" {
|
||||||
videoFiles := []string{}
|
videoFiles := []string{}
|
||||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||||
if utils.IsPlayable(file.Path) {
|
if utils.IsVideo(file.Path) {
|
||||||
videoFiles = append(videoFiles, fmt.Sprintf("%d", file.ID))
|
videoFiles = append(videoFiles, fmt.Sprintf("%d", file.ID))
|
||||||
} else if file.ID != 0 {
|
} else if file.ID != 0 {
|
||||||
t.repairLog.Debugf("Extracting file %s from rar'ed torrent %s", file.Path, t.GetKey(torrent))
|
t.repairLog.Debugf("Extracting file %s from rar'ed torrent %s", file.Path, t.GetKey(torrent))
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ package utils
|
|||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
func IsPlayable(filePath string) bool {
|
func IsVideo(filePath string) bool {
|
||||||
filePath = strings.ToLower(filePath)
|
filePath = strings.ToLower(filePath)
|
||||||
return strings.HasSuffix(filePath, ".avi") ||
|
return strings.HasSuffix(filePath, ".avi") || // confirmed working
|
||||||
strings.HasSuffix(filePath, ".m2ts") ||
|
strings.HasSuffix(filePath, ".m2ts") || // confirmed working
|
||||||
strings.HasSuffix(filePath, ".m4v") ||
|
strings.HasSuffix(filePath, ".m4v") || // confirmed working
|
||||||
strings.HasSuffix(filePath, ".mkv") || // confirmed working
|
strings.HasSuffix(filePath, ".mkv") || // confirmed working
|
||||||
|
strings.HasSuffix(filePath, ".mov") || // confirmed working
|
||||||
strings.HasSuffix(filePath, ".mp4") || // confirmed working
|
strings.HasSuffix(filePath, ".mp4") || // confirmed working
|
||||||
strings.HasSuffix(filePath, ".mpg") ||
|
strings.HasSuffix(filePath, ".mpg") || // confirmed working (no watch option in RD)
|
||||||
strings.HasSuffix(filePath, ".ts") ||
|
strings.HasSuffix(filePath, ".mpeg") || // confirmed working (no watch option in RD)
|
||||||
strings.HasSuffix(filePath, ".wmv") ||
|
strings.HasSuffix(filePath, ".ts") || // confirmed working
|
||||||
strings.HasSuffix(filePath, ".m4b") // confirmed working
|
strings.HasSuffix(filePath, ".wmv") // confirmed working
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user