Fix resolution check on media info filter
This commit is contained in:
@@ -305,19 +305,19 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torren
|
||||
continue
|
||||
} else if (stream.Width >= 7680 || stream.Height >= 4320) && filter.MediaInfoResolution == "8k" {
|
||||
return true
|
||||
} else if (stream.Width >= 3840 || stream.Height >= 2160) && filter.MediaInfoResolution == "4k" {
|
||||
} else if ((stream.Width < 7680 && stream.Width >= 3840) || (stream.Height < 4320 && stream.Height >= 2160)) && filter.MediaInfoResolution == "4k" {
|
||||
return true
|
||||
} else if (stream.Width >= 1920 || stream.Height >= 1080) && filter.MediaInfoResolution == "1080p" {
|
||||
} else if ((stream.Width < 3840 && stream.Width >= 1920) || (stream.Height < 2160 && stream.Height >= 1080)) && filter.MediaInfoResolution == "1080p" {
|
||||
return true
|
||||
} else if (stream.Width >= 1280 || stream.Height >= 720) && filter.MediaInfoResolution == "720p" {
|
||||
} else if ((stream.Width < 1920 && stream.Width >= 1280) || (stream.Height < 1080 && stream.Height >= 720)) && filter.MediaInfoResolution == "720p" {
|
||||
return true
|
||||
} else if (stream.Width >= 854 || stream.Height >= 480) && filter.MediaInfoResolution == "480p" {
|
||||
} else if ((stream.Width < 1280 && stream.Width >= 854) || (stream.Height < 720 && stream.Height >= 480)) && filter.MediaInfoResolution == "480p" {
|
||||
return true
|
||||
} else if (stream.Width >= 640 || stream.Height >= 360) && filter.MediaInfoResolution == "360p" {
|
||||
} else if ((stream.Width < 854 && stream.Width >= 640) || (stream.Height < 480 && stream.Height >= 360)) && filter.MediaInfoResolution == "360p" {
|
||||
return true
|
||||
} else if (stream.Width >= 426 || stream.Height >= 240) && filter.MediaInfoResolution == "240p" {
|
||||
} else if ((stream.Width < 640 && stream.Width >= 426) || (stream.Height < 360 && stream.Height >= 240)) && filter.MediaInfoResolution == "240p" {
|
||||
return true
|
||||
} else if (stream.Width >= 256 || stream.Height >= 144) && filter.MediaInfoResolution == "144p" {
|
||||
} else if ((stream.Width < 426 && stream.Width >= 256) || (stream.Height < 240 && stream.Height >= 144)) && filter.MediaInfoResolution == "144p" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -336,18 +336,6 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torren
|
||||
}
|
||||
return false
|
||||
}
|
||||
if filter.MediaInfoBitRateLessThanOrEqual > 0 {
|
||||
for _, mediaInfo := range mediaInfos {
|
||||
bitrate, err := strconv.ParseInt(mediaInfo.Format.BitRate, 10, 64)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if bitrate <= filter.MediaInfoBitRateLessThanOrEqual {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if filter.MediaInfoVideoBitRateGreaterThanOrEqual > 0 {
|
||||
for _, mediaInfo := range mediaInfos {
|
||||
for _, stream := range mediaInfo.Streams {
|
||||
@@ -365,23 +353,6 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torren
|
||||
}
|
||||
return false
|
||||
}
|
||||
if filter.MediaInfoVideoBitRateLessThanOrEqual > 0 {
|
||||
for _, mediaInfo := range mediaInfos {
|
||||
for _, stream := range mediaInfo.Streams {
|
||||
if stream.CodecType != "video" || stream.Level <= 0 {
|
||||
continue
|
||||
}
|
||||
bitrate, err := strconv.ParseInt(stream.BitRate, 10, 64)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if bitrate <= filter.MediaInfoVideoBitRateLessThanOrEqual {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if filter.MediaInfoAudioBitRateGreaterThanOrEqual > 0 {
|
||||
for _, mediaInfo := range mediaInfos {
|
||||
for _, stream := range mediaInfo.Streams {
|
||||
@@ -399,23 +370,6 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torren
|
||||
}
|
||||
return false
|
||||
}
|
||||
if filter.MediaInfoAudioBitRateLessThanOrEqual > 0 {
|
||||
for _, mediaInfo := range mediaInfos {
|
||||
for _, stream := range mediaInfo.Streams {
|
||||
if stream.CodecType != "audio" {
|
||||
continue
|
||||
}
|
||||
bitrate, err := strconv.ParseInt(stream.BitRate, 10, 64)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if bitrate <= filter.MediaInfoAudioBitRateLessThanOrEqual {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if filter.MediaInfoDurationGreaterThanOrEqual > 0 {
|
||||
for _, mediaInfo := range mediaInfos {
|
||||
if int64(mediaInfo.Format.DurationSeconds) >= filter.MediaInfoDurationGreaterThanOrEqual {
|
||||
@@ -424,14 +378,6 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torren
|
||||
}
|
||||
return false
|
||||
}
|
||||
if filter.MediaInfoDurationLessThanOrEqual > 0 {
|
||||
for _, mediaInfo := range mediaInfos {
|
||||
if int64(mediaInfo.Format.DurationSeconds) <= filter.MediaInfoDurationLessThanOrEqual {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if filter.MediaInfoWithAudioLanguage != "" {
|
||||
for _, mediaInfo := range mediaInfos {
|
||||
for _, stream := range mediaInfo.Streams {
|
||||
|
||||
Reference in New Issue
Block a user