Skip to content

Commit

Permalink
version 1.5.0 ( updated 02.06.2024 )
Browse files Browse the repository at this point in the history
+ Added
	- Game groups: HHT, PLAYMAGiC
	- Consoles: POCKET, JAG
	- Test cases
	- Release Country parsing (TV Shows)
~ Improved:
	- Release title parsing: Added '&' to regex
	- Release type parsing: check for season and episode if release is from streaming service
	- Group name parsing with brackets
- Fixed:
	- Incorrect season parsing for some release titles
  • Loading branch information
pr0pz committed Jun 2, 2024
1 parent c6a12fb commit 2bd166b
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 12 deletions.
44 changes: 42 additions & 2 deletions ReleaseParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import patterns from './ReleasePatterns.js'
* ReleaseParser - A library for parsing scene release names.
*
* @author Wellington Estevo
* @version 1.4.4
* @version 1.5.0
*
* @module ReleaseParser
* @param {string} releaseName - Original release name.
Expand Down Expand Up @@ -37,6 +37,7 @@ const ReleaseParser = /** @lends module:ReleaseParser */ ( releaseName, section
'os' : null, // For Software/Game rls
'version' : null, // For Software/Game rls
'language' : null, // Object with language code as key and name as value (in english)
'country' : null, // Release country
'type' : null
}

Expand Down Expand Up @@ -709,6 +710,34 @@ const ReleaseParser = /** @lends module:ReleaseParser */ ( releaseName, section
}


/**
* Parses Release country and strips it from title.
*
* @private
* @return {void}
*/
const parseCountry = () =>
{
if ( !get( 'type' ).toLowerCase() === 'tv' ) return

const titleWords = get( 'title' ).split( ' ' )
const lastElement = -1;
const countries = '/^(US|UK|NZ|AU|CA|BE)$/i'
const invalidWordsBefore = '/^(the|of|with|and|between|to)$/i'

if ( !titleWords.at( lastElement - 1 ) ) return

if (
titleWords.at( lastElement ).match( countries.toRegExp() ) &&
!titleWords.at( lastElement - 1 ).match( invalidWordsBefore.toRegExp() )
)
{
set( 'title', titleWords.slice( 0, lastElement ).join(' ') )
set( 'country', titleWords.at( lastElement ) )
}
}


/**
* Check if release is of specific type.
*
Expand Down Expand Up @@ -939,6 +968,14 @@ const ReleaseParser = /** @lends module:ReleaseParser */ ( releaseName, section
{
type = 'MusicVideo'
}
// Probably movie if not episode and season given
else if (
!get( 'episode') &&
!get( 'season')
)
{
type = 'Movie';
}
}
// Description with date inside brackets is nearly always music or musicvideo
else if ( releaseName.match( patterns.REGEX_DATE_MUSIC.toRegExp() ) )
Expand Down Expand Up @@ -2086,17 +2123,19 @@ const ReleaseParser = /** @lends module:ReleaseParser */ ( releaseName, section


/**
* Remove unneeded attributes that were falsely parsed.
* Remove or fix attributes that were falsely parsed.
*
* @private
*/
const cleanupAttributes = () =>
{
let type = get( 'type' ).toLowerCase()
let flags = get( 'flags' )
let title = get( 'title' )

if ( type === 'movie' || type === 'tv' )
{
// Cleanup when source = format
if (
get( 'source' ) &&
get( 'format' ) &&
Expand Down Expand Up @@ -2344,6 +2383,7 @@ const ReleaseParser = /** @lends module:ReleaseParser */ ( releaseName, section

parseType( section )
parseTitle() // Title and extra title
parseCountry() // Parse country
cleanupAttributes()

return {
Expand Down
12 changes: 7 additions & 5 deletions ReleasePatterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* ReleasePatterns - All needed patterns for properly parsing releases.
*
* @author Wellington Estevo
* @version 1.4.4
* @version 1.5.0
*/

// Reusable vars
const regexYear = '(19\\d[\\dx]|20\\d[\\dx])'
const regexDate = '(\\d{2}|\\d{4})[._-](\\d{2})[._-](\\d{2}|\\d{4})'
const regexTitle = '([\\w.()-]+?)' // last ? = JS fix for ungreedy
const regexTitle = '([\\w&.()-]+?)' // last ? = JS fix for ungreedy
const regexEpisodeTv = '(?<!^)(?:(?:(?:[ST]|saison|staffel|temp)[._-]?\\d+)?[._-]?(?:ep?|o[av]+[._-]?|eps[._-]?|episode[._-]?)[\\d-]+|\\d+x\\d+|[STD]\\d+)'
const regexVersionText = '(?:v(?:ersione?)?|Updated?[._-]?v?|Build)'
const regexVersion = regexVersionText + '[._-]?([\\d.]+[a-z\\d]{0,3}(?!.gage))'
Expand All @@ -32,7 +32,7 @@ const patterns =
REGEX_YEAR_SIMPLE: regexYear,
REGEX_YEAR : '/(?=[(._-]' + regexYear + '[)._-])/gi',
// Extract group
REGEX_GROUP : '/-([\\w.]+)$/i',
REGEX_GROUP : '/-([\\w.\\[\\]]+)$/i',
// Extract OS
//REGEX_OS : ''
// Episode pattern matches: S01E01 / 1x01 / E(PS)1 / OVA1 / F123 / Folge_123 / Episode 1 / Issue 1 etc.
Expand All @@ -43,7 +43,7 @@ const patterns =
// For Disc numbers: Disc1 / DVD1 / CD1 / (S01)D01
REGEX_DISC : regexDisc,
// Season pattern matches: S01E01 / 1x01 / S01D01
REGEX_SEASON : '/[._-](?:(?:[ST]|saison|staffel|temp)[._-]?(\\d+)[._-]?(?:(?:ep?|eps[._-]?|episode[._-]?|f(?:olge[._-]?)|d|di[cks][cks]|cd|dvd)\\d+)?|(\\d+)(?:x\\d+))[._-]/i',
REGEX_SEASON : '/[._-](?:(?:[ST]|saison[._-]?|staffel[._-]?|temp[._-]?)(\\d+)[._-]?(?:(?:ep?|eps[._-]?|episode[._-]?|f(?:olge[._-]?)|d|di[cks][cks]|cd|dvd)\\d+)?|(\\d+)(?:x\\d+))[._-]/i',
// Basic title pattern
REGEX_TITLE : regexTitle,
// Good for Ebooks
Expand Down Expand Up @@ -337,6 +337,8 @@ const patterns =
// Game Console patterns
DEVICE : {
'3DO': '3DO',
'Analogue Pocket': 'POCKET$',
'Atari Jaguar': 'JAG',
//'Bandai WonderSwan': 'WS',
'Bandai WonderSwan Color': 'WSC',
'Commodore Amiga': 'AMIGA',
Expand Down Expand Up @@ -742,7 +744,7 @@ const patterns =
],

GROUPS_GAMES : [
'0x0007', '0x0815', '1C', 'ABSiSO', 'ACTiVATED', 'ADDONiA', 'ALiAS', 'ANOMALY', 'AUGETY', 'AVENGED', 'BACKLASH', 'bADkARMA', 'Bamboocha', 'BAT', 'BAZOOKA', 'BFHiSO', 'BiTE', 'BLASTCiTY', 'BReWErS', 'BREWS', 'BREWZ', 'CiFE', 'CLONECD', 'CLS', 'CODEX', 'COGENT', 'CUBiC', 'CXZiSO', 'DARKSiDERS', 'DARKZER0', 'DELiGHT', 'DEViANCE', 'DINOByTES', 'DOGE', 'DVN', 'DVNiSO', 'DYNAMIX', 'ENiGMA', 'FANiSO', 'FAS', 'FASiSO', 'FASDOX', 'FCKDRM', 'FLT', 'FLTDOX', 'GENESIS', 'gimpsRus', 'GMiSO', 'GOW', 'GREENPEACE', 'HATRED', 'HBD', 'HEiST', 'HI2U', 'HOODLUM', 'HR', 'HYBRID', 'I_KnoW', 'iMMERSiON', 'iNLAWS', 'iTWINS', 'JAGDOX', 'JAGUAR', 'LiGHTFORCE', 'LUMA', 'MONEV', 'MYSTERY', 'MYTH', 'NiiNTENDO', 'NNSSWW', 'OUTLAWS', 'PiKMiN', 'PiMoCK', 'PiZZA', 'PiZZADOX', 'PLAZA', 'POSTMORTEM', 'PRELUDE', 'PROPHET', 'PS5B', 'PUSSYCAT', 'PWZ', 'TENOKE', 'TENOKE1', 'THG', 'TiNYiSO', 'TRSi', 'TSC', 'RELOADED', 'RAZOR', 'Razor1911', 'RAZORCD', 'RazorDOX', 'ReVOLVeR', 'RiTUEL', 'RUNE', 'SCRUBS', 'SiLENTGATE', 'SiMPLEX', 'SKIDROW', 'SMACKs', 'Souldrinker', 'SPLATTER', 'SPLATTERKiNGS', 'STEAMPUNKS', 'STRANGE', 'SUXXORS', 'TDUJAM', 'TECHNiC', 'TEDOX', 'TNT', 'VACE', 'VENGEANCE', 'VENOM', 'ViTALiTY', 'VREX', 'Unleashed', 'YOUCANTNUKE', 'ZEKE'
'0x0007', '0x0815', '1C', 'ABSiSO', 'ACTiVATED', 'ADDONiA', 'ALiAS', 'ANOMALY', 'AUGETY', 'AVENGED', 'BACKLASH', 'bADkARMA', 'Bamboocha', 'BAT', 'BAZOOKA', 'BFHiSO', 'BiTE', 'BLASTCiTY', 'BReWErS', 'BREWS', 'BREWZ', 'CiFE', 'CLONECD', 'CLS', 'CODEX', 'COGENT', 'CUBiC', 'CXZiSO', 'DARKSiDERS', 'DARKZER0', 'DELiGHT', 'DEViANCE', 'DINOByTES', 'DOGE', 'DVN', 'DVNiSO', 'DYNAMIX', 'ENiGMA', 'FANiSO', 'FAS', 'FASiSO', 'FASDOX', 'FCKDRM', 'FLT', 'FLTDOX', 'GENESIS', 'gimpsRus', 'GMiSO', 'GOW', 'GREENPEACE', 'HATRED', 'HBD', 'HEiST', 'HHT', 'HI2U', 'HOODLUM', 'HR', 'HYBRID', 'I_KnoW', 'iMMERSiON', 'iNLAWS', 'iTWINS', 'JAGDOX', 'JAGUAR', 'LiGHTFORCE', 'LUMA', 'MONEV', 'MYSTERY', 'MYTH', 'NiiNTENDO', 'NNSSWW', 'OUTLAWS', 'PiKMiN', 'PiMoCK', 'PiZZA', 'PiZZADOX', 'PLAYMAGiC', 'PLAZA', 'POSTMORTEM', 'PRELUDE', 'PROPHET', 'PS5B', 'PUSSYCAT', 'PWZ', 'TENOKE', 'TENOKE1', 'THG', 'TiNYiSO', 'TRSi', 'TSC', 'RELOADED', 'RAZOR', 'Razor1911', 'RAZORCD', 'RazorDOX', 'ReVOLVeR', 'RiTUEL', 'RUNE', 'SCRUBS', 'SiLENTGATE', 'SiMPLEX', 'SKIDROW', 'SMACKs', 'Souldrinker', 'SPLATTER', 'SPLATTERKiNGS', 'STEAMPUNKS', 'STRANGE', 'SUXXORS', 'TDUJAM', 'TECHNiC', 'TEDOX', 'TNT', 'VACE', 'VENGEANCE', 'VENOM', 'ViTALiTY', 'VREX', 'Unleashed', 'YOUCANTNUKE', 'ZEKE'
],

GROUPS_APPS : [
Expand Down
15 changes: 15 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
version 1.5.0 ( updated 02.06.2024 )
+ Added
- Game groups: HHT, PLAYMAGiC
- Consoles: POCKET, JAG
- Test cases
- Release Country parsing (TV Shows)
~ Improved:
- Release title parsing: Added '&' to regex
- Release type parsing: check for season and episode if release is from streaming service
- Group name parsing with brackets
- Fixed:
- Incorrect season parsing for some release titles

***

version 1.4.4 ( updated 12.01.2024 )
+ Added
- App groups: CNC
Expand Down
5 changes: 3 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Thanks to OFfriend for the initial pull request.
*
* @author Wellington Estevo
* @version 1.4.4
* @version 1.5.0
*/

// Flags
Expand All @@ -22,7 +22,7 @@ type releaseResolution = '480p' | '576p' | '720p' | '1080i' | '1080p' | '1920p'
type releaseAudio = '10BIT' | '16BIT' | '24BIT' | '44K' | '48K' | '96K' | '160K' | '176K' | '192K' | 'AAC' | 'AC3' | 'AC3D' | 'EAC3' | 'EAC3D' | 'Dolby Atmos' | 'Dolby Digital' | 'Dolby Digital Plus' | 'Dolby Digital Plus, Dolby Atmos' | 'Dolby trueHD' | 'DTS' | 'DTS-ES' | 'DTS-HD' | 'DTS-HD MA' | 'DTS|X' | 'OGG' | '2.0' | '2.1' | '3.1' | '5.1' | '7.1' | '7.2' | '9.1' | 'Dual Audio' | 'Tripple Audio';

// Device
type releaseDevice = '3DO' | 'Bandai WonderSwan' | 'Bandai WonderSwan Color' | 'Commodore Amiga' | 'Commodore Amiga CD32' | 'Commodore C64' | 'Commodore C264' | 'Nintendo Entertainment System' | 'Super Nintendo Entertainment System' | 'Nintendo GameBoy' | 'Nintendo GameBoy Color' | 'Nintendo GameBoy Advanced' | 'Nintendo Gamecube' | 'Nintendo iQue Player' | 'Nintendo Switch' | 'NEC PC Engine' | 'Nokia N-Gage' | 'Playstation' | 'Playstation 2' | 'Playstation 3' | 'Playstation 4' | 'Playstation 5' | 'Playstation Portable' | 'Playstation Vita' | 'Pocket PC' | 'Sega Dreamcast' | 'Sega Mega CD' | 'Sega Mega Drive' | 'Sega Saturn' | 'Tiger Telematics Gizmondo' | 'VTech V.Flash' | 'Microsoft Xbox' | 'Microsoft Xbox One' | 'Microsoft Xbox360' | 'Nintendo DS' | 'Nintendo 3DS' | 'Nintendo WII' | 'Nintendo WII-U';
type releaseDevice = '3DO' | 'Analogue Pocket' | 'Atari Jaguar' | 'Bandai WonderSwan' | 'Bandai WonderSwan Color' | 'Commodore Amiga' | 'Commodore Amiga CD32' | 'Commodore C64' | 'Commodore C264' | 'Nintendo Entertainment System' | 'Super Nintendo Entertainment System' | 'Nintendo GameBoy' | 'Nintendo GameBoy Color' | 'Nintendo GameBoy Advanced' | 'Nintendo Gamecube' | 'Nintendo iQue Player' | 'Nintendo Switch' | 'NEC PC Engine' | 'Nokia N-Gage' | 'Playstation' | 'Playstation 2' | 'Playstation 3' | 'Playstation 4' | 'Playstation 5' | 'Playstation Portable' | 'Playstation Vita' | 'Pocket PC' | 'Sega Dreamcast' | 'Sega Mega CD' | 'Sega Mega Drive' | 'Sega Saturn' | 'Tiger Telematics Gizmondo' | 'VTech V.Flash' | 'Microsoft Xbox' | 'Microsoft Xbox One' | 'Microsoft Xbox360' | 'Nintendo DS' | 'Nintendo 3DS' | 'Nintendo WII' | 'Nintendo WII-U';

// OS
type releaseOS = 'IBM AIX' | 'Android' | 'BlackBerry' | 'BSD' | 'HP-UX' | 'iOS' | 'Linux' | 'macOS' | 'PalmOS' | 'Solaris' | 'SunOS' | 'Symbian' | 'Ubuntu' | 'Unix' | 'WebOS' | 'Windows' | 'Windows CE' | 'Windows Mobile';
Expand Down Expand Up @@ -112,6 +112,7 @@ type ReleaseData = {
os: releaseOS | null;
version: string | null;
language: releaseLanguage | null;
country: string | null;
type: releaseType | null;
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "release-parser",
"version": "1.4.4",
"version": "1.5.0",
"description": "A library for parsing scene release names into human readable data.",
"main": "ReleaseParser.js",
"bin": "cli.js",
Expand Down
28 changes: 26 additions & 2 deletions test/ReleaseParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import assert from 'assert'
* This are hand selected, at some point 'more complex' releases that need to pass the test.
*
* @author Wellington Estevo
* @version 1.4.4
* @version 1.5.0
*/

describe( 'ReleaseParser', function()
Expand Down Expand Up @@ -241,6 +241,30 @@ describe( 'ReleaseParser', function()
)
})

it( 'Movies #13 - Special char in title', () =>
{
assert.equal(
ReleaseParser( 'Hansel.&.Gretel.Witch.Hunters..2013.DiRFiX.NTSC.MULTi.DVDR-FUTiL', 'PRE' ).toString(),
'Title: Hansel & Gretel Witch Hunters / Group: FUTiL / Year: 2013 / Flags: DIRFiX / Format: DVDR / Resolution: NTSC / Language: Multilingual / Type: Movie'
)
})

it( 'Movies #14 - Don\'t falsely parse season', () =>
{
assert.equal(
ReleaseParser( 'V.H.S.94.2021.BluRay.1080p.DTS-HD.MA.5.1.AVC-GROUPNAME', 'PRE' ).toString(),
'Title: V H S 94 / Group: GROUPNAME / Year: 2021 / Source: Bluray / Format: AVC / Resolution: 1080p / Audio: DTS-HD MA, 5.1 / Type: Movie'
)
})

it( 'Movies #15 - Don\'t falsely parse movie as tv show + special group chars', () =>
{
assert.equal(
ReleaseParser( 'Pay.the.Ghost.2015.1080p.HULU.WEB-DL.DDP.5.1.H.264-PiRaTeS[TGx]', 'PRE' ).toString(),
'Title: Pay the Ghost / Group: PiRaTeS[TGx] / Year: 2015 / Source: Hulu / Resolution: 1080p / Audio: Dolby Digital Plus, 5.1 / Type: Movie'
)
})


// TV
it( 'TV #1 - Multiple episodes: 01-02', () =>
Expand Down Expand Up @@ -295,7 +319,7 @@ describe( 'ReleaseParser', function()
{
assert.equal(
ReleaseParser( 'Riverdale.US.S05.PROPER.FRENCH.WEB.x264-STRINGERBELL', 'tv' ).toString(),
'Title: Riverdale US / Group: STRINGERBELL / Season: 5 / Flags: Proper / Source: WEB / Format: x264 / Language: French / Type: TV'
'Title: Riverdale / Group: STRINGERBELL / Season: 5 / Flags: Proper / Source: WEB / Format: x264 / Language: French / Country: US / Type: TV'
)
})

Expand Down

0 comments on commit 2bd166b

Please sign in to comment.