Skip to content

Commit

Permalink
Fix "Part III" to "Part 3" and "-" empty title issue
Browse files Browse the repository at this point in the history
  • Loading branch information
thcolin committed Sep 13, 2019
1 parent e536d49 commit d3722b2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 17 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,24 @@ console.log(release)
## Issues :
| Original | Generated |
| -------- | --------- |
| 40 JOURS ET 40 NUITS HDTV 1080p MULTI FR-EN AC3 .ts | 40.Jours.Et.40.Nuits.Hdtv.MULTI.1080p.CAM.AC3-NOTEAM |
| Reviens-moi .2007.MULTi.1080p.BluRay.DTS.HDMA.x265.AZAZE | Reviens.2007.MULTI.1080p.BLURAY.x265-moi |
| The Good German (2006).VOSTR.720p.WEBDL.h264.aac | The.Good.2006.GERMAN.720p.WEB-DL.h264-NOTEAM |
| La.French.2014.FRENCH.SUBFORCED.BRRip.XviD-VENUM.avi | La.2014.FRENCH.BDRip.XviD-VENUM |
| The French Connection 2 (1975) MULTI. VFF. VO. 1080p BluRay REMUX AVC H264 DTS-HD.MA.5.1 SEL | The.1975.MULTI.1080p.HDRip.h264-NOTEAM |
| Johnny English Contre-Attaque 2018 FRENCH WEBRip 720p x264-Notag | Johnny.2018.FRENCH.720p.WEB-DL.x264-Notag |
| Nurse.3D.2013.German.DL.720p.BluRay.x264-PussyFoot | Nurse.2013.GERMAN.720p.BLURAY.x264.3D.DL-PussyFoot |
| Faster, Pussycat ! Kill ! Kill !. 1965.Russ Meyer.VOSTFR.Blu-Ray 720p.Liosaa (RU) / Popo | Faster,.Pussycat.Kill.Kill.1965.VOSTFR.720p.BLURAY-NOTEAM |
| Kiss the blood off my hands - (Norman FOSTER) - 1948 - VOSTFR - Dvdrip-x264 - kerfiche | Kiss.The.Blood.Off.My.Hands.-.Norman.Foster.-.-.1948.VOSTFR.DVDRip.x264-.kerfiche |
| Friday.The.13th.Part.III.3D.1982.iNTERNAL.BDRip.x264-MARS | Friday.The.13th.Part.Iii.1982.BDRip.x264.3D.INTERNAL-MARS |
| Le Nouveau Stagiaire (2015) The Intern - Multi 1080p - x264 AAC 5.1 - CCATS | Le.Nouveau.Stagiaire.-.2015.MULTI.1080p.x264.AAC.DD5.1-.CCATS |
| La.Planete.Des.Singes.L'affrontement.TRUEFRENCH.720p.x264.HDLIGHT | La.Planete.Des.Singes.L'affrontement.TRUEFRENCH.720p.HDRip.x264-NOTEAM |
<!-- | 馃懟 | 馃懟 | -->

## Results :
| Original | Generated |
| -------- | --------- |
| [ www.Torrent*.** ] The.Darkest.Minds.2018.MULTi.1080p.WEB-DL.DD5.1.H264-ACOOL.mkv | The.Darkest.Minds.2018.MULTI.1080p.WEB-DL.h264.DD5.1-ACOOL |
| Reviens-moi (2007) [1080p] BluRay MULTi x264-PopHD.mkv | Reviens.Moi.2007.MULTI.1080p.BLURAY.x264-PopHD |
| Spider-Man.Into.The.Spider-Verse.2018.TRUEFRENCH.BDRip.x264-NEO | Spider.Man.Into.The.Spider-Verse.2018.TRUEFRENCH.BDRip.x264-NEO |
| The.Lion.in.Winter.1968.RESTORED.VOSTFR.1080p.BluRay.X264-AMIABLE | The.Lion.In.Winter.1968.VOSTFR.1080p.BLURAY.x264.RESTORED-AMIABLE |
| Escape.from.New.York.1981.COMPLETE.UHD.BLURAY-COASTER | Escape.From.New.York.1981.2160p.BLURAY.COMPLETE-COASTER |
| Escape From New York 1981 MULTi VFF BluRay 4K HDR DTS-HD MA AC3 x265-HD2 | Escape.From.New.York.1981.MULTI.2160p.HDRip.x265.AC3.DTS-HD2 |
Expand All @@ -130,7 +132,7 @@ console.log(release)
| Shortland.Street.S23E180.720p.HDTV.x264-FiHTV | Shortland.Street.S23E180.720p.HDTV.x264-FiHTV |
| Rules.of.Engagement.S05E24.German.DVDRip.x264-iNTENTiON | Rules.Of.Engagement.S05E24.GERMAN.DVDRip.x264-iNTENTiON |
| Edge.of.Tomorrow.3D.HOU.German.DL.1080p.BluRay.x264-EXQUiSiTE | Edge.Of.Tomorrow.GERMAN.1080p.BLURAY.x264.3D.DL.HOU-EXQUiSiTE |
| Friday.The.13th.Part.III.3D.1982.iNTERNAL.BDRip.x264-MARS | Friday.The.13th.Part.Iii.1982.BDRip.x264.3D.INTERNAL-MARS |
| Friday.The.13th.Part.III.3D.1982.iNTERNAL.BDRip.x264-MARS | Friday.The.13th.Part.3.1982.BDRip.x264.3D.INTERNAL-MARS |
| Free.Birds.Esst.uns.an.einem.anderen.Tag.3D.HSBS.German.DL.1080p.BluRay.x264-EXQUiSiTE | Free.Birds.Esst.Uns.An.Einem.Anderen.Tag.GERMAN.1080p.BLURAY.x264.3D.DL.HSBS-EXQUiSiTE |
| Nurse.3D.2013.German.DL.720p.BluRay.x264-PussyFoot | Nurse.2013.GERMAN.720p.BLURAY.x264.3D.DL-PussyFoot |
| Dumb.And.Dumber.1994.iNTERNAL.BDRip.x264-LiBRARiANS | Dumb.And.Dumber.1994.BDRip.x264.INTERNAL-LiBRARiANS |
Expand All @@ -153,7 +155,7 @@ console.log(release)
| Scary Movie 1 (2000) - 1080p FR EN x264 ac3 mHDgz | Scary.Movie.1.2000.MULTI.1080p.x264.AC3-.mHDgz |
| Elektra 2005 [J.Garner, T.Stamp] BRRIP-H264-720P & AC3-5.1-VFF-STFR [Calinos1] | Elektra.2005.MULTI.720p.BDRip.h264.AC3.DD5.1-NOTEAM |
| Tower Heist [1080p] MULTI 2011 BluRay x264-Pop .Le casse De Central Park. | Tower.Heist.2011.MULTI.1080p.BLURAY.x264-Pop |
| Star.Wars.Episode.I.The.Phantom.Menace.1999.MULTi.1080p.BluRay.x264-LOST | Star.Wars.Episode.I.The.Phantom.Menace.1999.MULTI.1080p.BLURAY.x264-LOST |
| Star.Wars.Episode.I.The.Phantom.Menace.1999.MULTi.1080p.BluRay.x264-LOST | Star.Wars.Episode.1.The.Phantom.Menace.1999.MULTI.1080p.BLURAY.x264-LOST |
| Star Wars Episode 6 Le Retour du Jedi 1983 Truefrench BDrip x264-BBer | Star.Wars.Episode.6.Le.Retour.Du.Jedi.1983.TRUEFRENCH.BDRip.x264-BBer |
| Star Wars Episode 5 L'Empire contre-attaque 1980 Truefrench BDrip x264-BBer | Star.Wars.Episode.5.L'empire.Contre-Attaque.1980.TRUEFRENCH.BDRip.x264-BBer |
| Star Wars Episode 4 Un Nouvel espoir 1977 Truefrench BDrip x264-BBer | Star.Wars.Episode.4.Un.Nouvel.Espoir.1977.TRUEFRENCH.BDRip.x264-BBer |
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function deduce(property, name, multi = false) {
const rule = rules[property]
const tags = Object.keys(rule)

single:
single: {
for (let i = 0; i < tags.length; i++) {
const tag = tags[i]
const patterns = (Array.isArray(rule[tag]) ? rule[tag] : [rule[tag]])
Expand All @@ -143,8 +143,8 @@ function deduce(property, name, multi = false) {
break
}
}

}
}

return result
}
Expand Down Expand Up @@ -184,7 +184,7 @@ function parse(name, options = { strict: false, flagged: true, erase: [], defaul

const cleaned = clean(name, [...(options.erase ||[]), ...rules.erase])

let words = cleaned.split('.')
let words = cleaned.replace(/[\.\-]+/, '.').split('.')
let waste = cleaned
let handicap = []

Expand All @@ -209,6 +209,7 @@ function parse(name, options = { strict: false, flagged: true, erase: [], defaul
.replace(/[\.\-]+/, '.')
.split('.')
.filter((word, position) => word === words[position])
.map(word => word.split('').every(char => ['i', 'I'].includes(char)) ? word.length : word)
.join(' ')
.toLowerCase()
.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g, s => s.toUpperCase()) // ucwords
Expand Down
56 changes: 48 additions & 8 deletions tests/fixtures/releases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
{
"Reviens-moi (2007) [1080p] BluRay MULTi x264-PopHD.mkv": {
"original": "Reviens-moi (2007) [1080p] BluRay MULTi x264-PopHD.mkv",
"language": "MULTI",
"source": "BLURAY",
"encoding": "x264",
"resolution": "1080p",
"dub": null,
"year": "2007",
"flags": null,
"season": null,
"episode": null,
"episodes": [],
"type": "movie",
"group": "PopHD",
"title": "Reviens Moi",
"generated": "Reviens.Moi.2007.MULTI.1080p.BLURAY.x264-PopHD",
"score": 6,
"guess": {}
},
"Spider-Man.Into.The.Spider-Verse.2018.TRUEFRENCH.BDRip.x264-NEO": {
"original": "Spider-Man.Into.The.Spider-Verse.2018.TRUEFRENCH.BDRip.x264-NEO",
"language": "TRUEFRENCH",
"source": "BDRip",
"encoding": "x264",
"resolution": null,
"dub": null,
"year": "2018",
"flags": null,
"season": null,
"episode": null,
"episodes": [],
"type": "movie",
"group": "NEO",
"title": "Spider Man Into The Spider-Verse",
"generated": "Spider.Man.Into.The.Spider-Verse.2018.TRUEFRENCH.BDRip.x264-NEO",
"score": 5,
"guess": {
"resolution": "SD"
}
},
"The.Lion.in.Winter.1968.RESTORED.VOSTFR.1080p.BluRay.X264-AMIABLE": {
"original": "The.Lion.in.Winter.1968.RESTORED.VOSTFR.1080p.BluRay.X264-AMIABLE",
"language": "VOSTFR",
Expand Down Expand Up @@ -81,8 +121,8 @@
"score": 6,
"guess": {}
},
"[ www.Torrent9.PH ] The.Darkest.Minds.2018.MULTi.1080p.WEB-DL.DD5.1.H264-ACOOL.mkv": {
"original": "[ www.Torrent9.PH ] The.Darkest.Minds.2018.MULTi.1080p.WEB-DL.DD5.1.H264-ACOOL.mkv",
"[ www.Torrent*.** ] The.Darkest.Minds.2018.MULTi.1080p.WEB-DL.DD5.1.H264-ACOOL.mkv": {
"original": "[ www.Torrent*.** ] The.Darkest.Minds.2018.MULTi.1080p.WEB-DL.DD5.1.H264-ACOOL.mkv",
"language": "MULTI",
"source": "WEB-DL",
"encoding": "h264",
Expand Down Expand Up @@ -121,8 +161,8 @@
"score": 5,
"guess": {}
},
"Dragon.Ball.Super.E89.FRENCH.1080P.HDTV.x264-R342 [ www.Torrent9.PH ].mkv": {
"original": "Dragon.Ball.Super.E89.FRENCH.1080P.HDTV.x264-R342 [ www.Torrent9.PH ].mkv",
"Dragon.Ball.Super.E89.FRENCH.1080P.HDTV.x264-R342 [ www.Torrent*.** ].mkv": {
"original": "Dragon.Ball.Super.E89.FRENCH.1080P.HDTV.x264-R342 [ www.Torrent*.** ].mkv",
"language": "FRENCH",
"source": "HDTV",
"encoding": "x264",
Expand Down Expand Up @@ -592,8 +632,8 @@
"episodes": [],
"type": "movie",
"group": "MARS",
"title": "Friday The 13th Part Iii",
"generated": "Friday.The.13th.Part.Iii.1982.BDRip.x264.3D.INTERNAL-MARS",
"title": "Friday The 13th Part 3",
"generated": "Friday.The.13th.Part.3.1982.BDRip.x264.3D.INTERNAL-MARS",
"score": 5,
"guess": {
"resolution": "SD"
Expand Down Expand Up @@ -1094,8 +1134,8 @@
"episodes": [],
"type": "movie",
"group": "LOST",
"title": "Star Wars Episode I The Phantom Menace",
"generated": "Star.Wars.Episode.I.The.Phantom.Menace.1999.MULTI.1080p.BLURAY.x264-LOST",
"title": "Star Wars Episode 1 The Phantom Menace",
"generated": "Star.Wars.Episode.1.The.Phantom.Menace.1999.MULTI.1080p.BLURAY.x264-LOST",
"score": 6,
"guess": {}
},
Expand Down
6 changes: 4 additions & 2 deletions tests/fixtures/releases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ The.Good.German.2006.DVDRip.MULTI.H264.720x480.AAC.MK2017
Ugly Americans - S02 STFR 720p.WEB-DL.x264 AC3 MpEbUtCh3r
2.Fast.2.Furious.2003.MULTi.2160p.UHD.BluRay.x265-OohLaLa
The Hitmans BodyGuard (2017) VFQ-ENG AC3 BluRay 1080p x264.GHT (Mon meilleur ennemi)
Dragon.Ball.Super.E89.FRENCH.1080P.HDTV.x264-R342 [ www.Torrent9.PH ].mkv
Dragon.Ball.Super.E89.FRENCH.1080P.HDTV.x264-R342 [ www.Torrent*.** ].mkv
Serendipity (2001) MULTi VF2 [1080p] BluRay x264-PopHD ("Un amour 脿 New York" ou "Heureux hasard")
[ www.Torrent9.PH ] The.Darkest.Minds.2018.MULTi.1080p.WEB-DL.DD5.1.H264-ACOOL.mkv
[ www.Torrent*.** ] The.Darkest.Minds.2018.MULTi.1080p.WEB-DL.DD5.1.H264-ACOOL.mkv
Syngue.Sabour.Pierre.de.Patience.The.Patience.Stone.2012.SUBFRENCH.720p.BluRay.x264-ROUGH
Escape From New York 1981 MULTi VFF BluRay 4K HDR DTS-HD MA AC3 x265-HD2
Escape.from.New.York.1981.COMPLETE.UHD.BLURAY-COASTER
The.Lion.in.Winter.1968.RESTORED.VOSTFR.1080p.BluRay.X264-AMIABLE
Spider-Man.Into.The.Spider-Verse.2018.TRUEFRENCH.BDRip.x264-NEO
Reviens-moi (2007) [1080p] BluRay MULTi x264-PopHD.mkv

0 comments on commit d3722b2

Please sign in to comment.