-
Notifications
You must be signed in to change notification settings - Fork 2
/
source.go
29 lines (25 loc) · 835 Bytes
/
source.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package torrentparser
import (
"regexp"
"strings"
)
var (
sourceGeneral = regexp.MustCompile(`(?i)\b(?:(?:HD-?)?CAM|(?:DVD|VHS)scr|TC|HDTV|R5|Blu-?ray|WEB-?(?:DL)?|(?:BR|BD|DVD|PPV|WEB|HD|(?:HD-?)?TV)-?Rip|(?:DL|WEB|BD|BR|BDRE|RE)MUX)\b`)
sourceTelesync = regexp.MustCompile(`(?i)\b(?:HD-?)?T(?:ELE)?S(?:YNC)?\b`)
sourceDvd = regexp.MustCompile(`(?i)(DVD)(?:R[0-9])?`)
)
func init() {
}
func (p *parser) GetSource() string {
source := p.FindString("sourceGeneral", sourceGeneral, FindStringOptions{Handler: func(str string) string {
return strings.ToLower(str)
}})
if source != "" {
return source
}
source = p.FindString("sourceTelesync", sourceTelesync, FindStringOptions{Value: "telesync"})
if source != "" {
return source
}
return p.FindString("sourceDvd", sourceDvd, FindStringOptions{Value: "dvd"})
}