fix(indexers): improve animebytes parsing (#477)

* Fixed typo for "Aweomse Raw Novel"
Added one missing whitespace after "manga" tag for "Awesome Live Action Special" test
Changed regex expression to fix AB parsing

* Fixed regex to acknowledge "uploader" var in case there is no tags in the announce.
Added test line for announces without tags.

* chore: update rls package

* fix(release): don't overwrite season and episode
This commit is contained in:
xoaaC 2022-10-13 20:35:48 +02:00 committed by GitHub
parent bc335ccf1f
commit 2777f8c3cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 34 deletions

View file

@ -102,8 +102,7 @@ func (a *announceProcessor) processQueue(queue chan string) {
rls := domain.NewRelease(a.indexer.Identifier)
// on lines matched
err := a.onLinesMatched(a.indexer, tmpVars, rls)
if err != nil {
if err := a.onLinesMatched(a.indexer, tmpVars, rls); err != nil {
a.log.Debug().Msgf("error match line: %v", "")
continue
}
@ -164,20 +163,18 @@ func (a *announceProcessor) parseExtract(pattern string, vars []string, tmpVars
// onLinesMatched process vars into release
func (a *announceProcessor) onLinesMatched(def *domain.IndexerDefinition, vars map[string]string, rls *domain.Release) error {
var err error
err = rls.MapVars(def, vars)
if err != nil {
if err := rls.MapVars(def, vars); err != nil {
a.log.Error().Stack().Err(err).Msg("announce: could not map vars for release")
return err
}
// parse fields
// run before ParseMatch to not potentially use a reconstructed TorrentName
rls.ParseString(rls.TorrentName)
// parse torrentUrl
err = def.Parse.ParseMatch(vars, def.SettingsMap, rls)
if err != nil {
if err := def.Parse.ParseMatch(vars, def.SettingsMap, rls); err != nil {
a.log.Error().Stack().Err(err).Msgf("announce: %v", err)
return err
}
@ -219,8 +216,7 @@ func (a *announceProcessor) processTorrentUrl(match string, vars map[string]stri
}
var b bytes.Buffer
err = tmpl.Execute(&b, &tmpVars)
if err != nil {
if err := tmpl.Execute(&b, &tmpVars); err != nil {
a.log.Error().Err(err).Msg("could not write torrent url template output")
return "", err
}

View file

@ -162,8 +162,7 @@ func (p *IndexerParse) ParseMatch(vars map[string]string, extraVars map[string]s
}
var urlBytes bytes.Buffer
err = tmpl.Execute(&urlBytes, &tmpVars)
if err != nil {
if err := tmpl.Execute(&urlBytes, &tmpVars); err != nil {
return errors.New("could not write torrent url template output")
}
@ -178,8 +177,7 @@ func (p *IndexerParse) ParseMatch(vars map[string]string, extraVars map[string]s
}
var nameBytes bytes.Buffer
err = tmplName.Execute(&nameBytes, &tmpVars)
if err != nil {
if err := tmplName.Execute(&nameBytes, &tmpVars); err != nil {
return errors.New("could not write torrent name template output")
}

View file

@ -192,8 +192,6 @@ func (r *Release) ParseString(title string) {
r.Title = rel.Title
r.Source = rel.Source
r.Resolution = rel.Resolution
r.Season = rel.Series
r.Episode = rel.Episode
r.Region = rel.Region
r.Audio = rel.Audio
r.AudioChannels = rel.Channels
@ -203,6 +201,13 @@ func (r *Release) ParseString(title string) {
r.Other = rel.Other
r.Artists = rel.Artist
if r.Season == 0 {
r.Season = rel.Series
}
if r.Episode == 0 {
r.Episode = rel.Episode
}
if r.Year == 0 {
r.Year = rel.Year
}

View file

@ -49,15 +49,16 @@ parse:
type: single
lines:
- test:
- "Aweomse Raw Novel - Light Novel [2005] :: Raw / EPUB || https://animebytes.tv/torrents.php?id=00000&torrentid=00000 || supernatural || Uploaded by: Test-Uploader"
- "Awesome Raw Novel - Light Novel [2005] :: Raw / EPUB || https://animebytes.tv/torrents.php?id=00000&torrentid=00000 || supernatural || Uploaded by: Test-Uploader"
- "Awesome Translated Novel - Light Novel [2018] :: Translated (Translation Group) / EPUB || https://animebytes.tv/torrents.php?id=00000&torrentid=000000 || adventure, comedy, fantasy, harem, school.life, magic, action || Uploaded by: UPLOADER"
- "Great BluRay SoftSubbed Anime - TV Series [2020] :: Blu-ray / MKV / h264 10-bit / 1080p / FLAC 2.0 / Dual Audio / Softsubs (Sub Group) / Freeleech || https://animebytes.tv/torrents.php?id=00008&torrentid=000000 || comedy, drama, school.life, sports || Uploaded by: Uploader"
- "Awesome Translated Manga - Manga [2019] :: Translated (Translation Group) / Digital / Ongoing || https://animebytes.tv/torrents.php?id=00000&torrentid=000000 || comedy, fantasy, school.life, shounen, slice.of.life"
- "Cool Movie - Movie [2020] :: Blu-ray / MKV / h265 10-bit / 1929x804 / AC3 5.1 / Dual Audio / Softsubs (Sub Group) || https://animebytes.tv/torrents.php?id=000000&torrentid=0000000 || drama, romance, slice.of.life || Uploaded by: Anon-Uploader"
- "Awesome Live Action Special - Live Action TV Special [2021] :: Web / MKV / h264 / 848x480 / AAC 2.0 / Softsubs (Sub Group) || https://animebytes.tv/torrents.php?id=00000&torrentid=00000 || manga|| Uploaded by: Some-Uploader"
- "Awesome Live Action Special - Live Action TV Special [2021] :: Web / MKV / h264 / 848x480 / AAC 2.0 / Softsubs (Sub Group) || https://animebytes.tv/torrents.php?id=00000&torrentid=00000 || manga || Uploaded by: Some-Uploader"
- "Best Visual Novel - Visual Novel [2006] :: Game / PC / Unarchived / Hentai (Censored) || https://animebytes.tv/torrents.php?id=00000&torrentid=00000 || nukige || Uploaded by: Uploader"
- "Artist Name - Album of awesome Music [1991] :: MP3 / V0 (VBR) / CD || https://animebytes.tv/torrents2.php?id=00000&torrentid=000000 || ambient, folk || Uploaded by: Uploader"
pattern: '(.*?)(?: - )?(Visual Novel|Light Novel|TV.*|Movie|Manga|OVA|ONA|DVD Special|BD Special|Oneshot|Anthology|Manhwa|Manhua|Artbook|Game|Live Action.*|)[\s\p{Zs}]{2,}\[(\d+)\] :: (.*?)(?: \/ (?:RAW|Softsubs|Hardsubs|Translated)\s\((.+)\)(?:.*Episode\s(\d+))?(?:.*(Freeleech))?.*)? \|\| (https.*)\/torrents.*\?id=\d+&torrentid=(\d+) \|\| (.+?(?:(?:\|\| Uploaded by|$))?) (?:\|\| Uploaded by: (.*))?$'
- "Awesome Series - TV Series [2022] :: Web / MKV / h264 / 1080p / AAC 2.0 / Softsubs (Sub Group) / Episode 1 / Freeleech || https://animebytes.tv/torrents.php?id=00000&torrentid=000000 || || Uploaded by: Uploader"
pattern: '(.*?)(?: - )?(Visual Novel|Light Novel|TV.*|Movie|Manga|OVA|ONA|DVD Special|BD Special|Oneshot|Anthology|Manhwa|Manhua|Artbook|Game|Live Action.*|)[\s\p{Zs}]{2,}\[(\d+)\] :: (.*?)(?: \/ (?:RAW|Softsubs|Hardsubs|Translated)\s\((.+)\)(?:.*Episode\s(\d+))?(?:.*(Freeleech))?.*)?(?:.?\|\|.?)?(https.*)\/torrents.*\?id=\d+&torrentid=(\d+)(?:.?\|\|.?)?([A-Za-z,. ]+\w)?(?:.?\|\|.?)?(?:Uploaded by: (.*))?'
vars:
- torrentName
- category