parsers/parsers.go

129 lines
3.2 KiB
Go

package parsers
import "git.milar.in/nyaanime/model"
/*
how to get all torrent names on a nyaa page:
let s = "";
document.querySelectorAll("tr > td:nth-child(2) > a:not(.comments)").forEach(element => {
s += element.textContent + "\n";
})
console.log(s);
*/
var Parsers = []model.Parser{
{
Identity: "Erai-Raws",
TorrentParser: RegexTorrentParser(
`^\[Erai-raws\] (.*) - (.*?) (?:END )?(?:\[v\d+\])?\[(.*?)p\](?:\[HEVC\])?(?:\[Multiple Subtitle\])?(?:\s(\[.*?\]+)?|\[[A-Z0-9]{8}\]\.mkv)$`,
TorrentParseOptions{
Name: 1,
Episode: 2,
Resolution: 3,
Subtitles: 4,
SubtitleParser: SquareBracketsLanguageParser,
DefaultLanguages: []string{"ja"},
},
),
FileParser: RegexFileParser(
`^\[Erai-raws\] (.*?) - (\d+?) .*?\.mkv$`,
FileParseOptions{
Name: 1,
Episode: 2,
},
),
},
{
Identity: "SubsPlease",
TorrentParser: RegexTorrentParser(
`^\[SubsPlease\] (.*) - (\d+?) \((.*?)\) \[.*?\].mkv$`,
TorrentParseOptions{
Name: 1,
Episode: 2,
Resolution: 3,
DefaultLanguages: []string{"ja"},
DefaultSubtitles: []string{"en"},
},
),
FileParser: RegexFileParser(
`^\[SubsPlease\] (.*?) - (\d+?) .*?\.mkv$`,
FileParseOptions{
Name: 1,
Episode: 2,
},
),
},
{
Identity: "PuyaSubs!",
TorrentParser: RegexTorrentParser(
`^\[PuyaSubs!\] (.*) - (\d+?) \[ESP-ENG\]\[(.*?)\]\[.*?\]\.mkv$`,
TorrentParseOptions{
Name: 1,
Episode: 2,
Resolution: 3,
DefaultLanguages: []string{"ja"},
DefaultSubtitles: []string{"en"},
},
),
FileParser: RegexFileParser(
`^\[PuyaSubs!\] (.*?) - (\d+?) .*?\.mkv$`,
FileParseOptions{
Name: 1,
Episode: 2,
},
),
// tag 0th audio stream as japanese language and copy all other streams unchanged into output file
FileEncoding: "-map 0 -c:v copy -c:a copy -c:s copy -metadata:s:a:0 language=jpn",
},
{
Identity: "NanakoRaws-JP",
TorrentParser: RegexTorrentParser(
`^\[NanakoRaws\] (.*?) - (\d+?)(?:v\d+)?(?: END)? \((.*?)p\)(?: \(.*?\))?\.mkv \(include JPsub\)`,
TorrentParseOptions{
Name: 1,
Episode: 2,
Resolution: 3,
DefaultLanguages: []string{"ja"},
DefaultSubtitles: []string{"ja"},
},
),
FileParser: RegexFileParser(
`^\[NanakoRaws\] (.*?) - (\d+?)(?:v\d+)?(?: END)? \((.*?)p\)(?: \(.*?\))?\.mkv`,
FileParseOptions{
Name: 1,
Episode: 2,
},
),
// tag 0th audio stream as japanese language and copy all other streams unchanged into output file
FileEncoding: "-map 0 -c:v copy -c:a copy -c:s copy -metadata:s:a:0 language=jpn -metadata:s:s:0 language=jpn",
},
{
Identity: "Ohys-Raws",
TorrentParser: RegexTorrentParser(
`^\[Ohys-Raws\] (.*?) - (\d+?) \(.*? \d+x(\d+?) .*?\)(?: v2)?\.mp4$`,
TorrentParseOptions{
Name: 1,
Episode: 2,
Resolution: 3,
DefaultLanguages: []string{"ja"},
DefaultSubtitles: []string{},
},
),
FileParser: RegexFileParser(
`^\[Ohys-Raws\] (.*) - (.*?) (?:END )?\(.*?\)(?: v2)?\.mp4$`,
FileParseOptions{
Name: 1,
Episode: 2,
},
),
},
}