identify-media
Version:
Analyse file path and content to make search criteria for media APIs
64 lines (59 loc) • 3.21 kB
text/typescript
import * as filePath from '../../src/lib/analyseString';
describe('Analyse String methods', () => {
describe('Find year', () => {
test.each([
[undefined, undefined],
['1914 (2020)', {restName: '1914 (', year: 2020}],
['movie (2018).1080p.x256.mp4', {restName: 'movie (', year: 2018}],
['movie (2018).2160p.x256.mp4', {restName: 'movie (', year: 2018}],
['Doctor.Sleep.2019.DiRECTORS.CUT.1080p.WEBRip.1800MB.x264-GalaxyRG.mkv', {restName: 'Doctor.Sleep.', year: 2019}],
['movie.1080p.x256.mp4', undefined],
['title (1987) S01E10.mkv', {restName: 'title (', year: 1987}],
['Perry Mason (2020) Complete Season 1', {restName: 'Perry Mason (', year: 2020}],
['nothing', undefined],
['(2011-2015)', {restName: '(', year: 2011}],
['Monk S01-S08 (2011-)', {restName: 'Monk S01-S08 (', year: 2011}],
['Series S01-S08 (2011-2019)', {restName: 'Series S01-S08 (', year: 2011}],
])('should parse %s to be %s', (input, result) => {
expect(filePath.findYear(input)).toEqual(result);
});
});
describe('Find season', () => {
test.each([
['', undefined],
['season 3', {season: 3, restName: undefined}],
['series season 05', {season: 5, restName: 'series '}],
['series complete season 12', {season: 12, restName: 'series '}],
])('should parse %s to be %s', (input, result) => {
expect(filePath.findSeason(input)).toEqual(result);
});
});
describe('Find season episode', () => {
test.each([
['', undefined],
['series - S03E10 - something.mp4', {restName: 'series - ', season: 3, episodes: [10]}],
['series - S03E10+E11 - something.mp4', {restName: 'series - ', season: 3, episodes: [10,11]}],
['series - S03E10+E11+E12 - something.mp4', {restName: 'series - ', season: 3, episodes: [10,11,12]}],
['series.314.something.mp4', undefined],
['series E10 - something.mp4', {restName: 'series ', season: undefined, episodes: [10]}],
['my series 1x15.mov', {restName: 'my series ', season: 1, episodes: [15]}],
['series (2020) S01E05.plu', {restName: 'series (2020) ', season: 1, episodes: [5]}],
['S01E05.plu', {restName: undefined, season: 1, episodes: [5]}],
['3x7.plu', {restName: undefined, season: 3, episodes: [7]}],
['3x7+8.plu', {restName: undefined, season: 3, episodes: [7, 8]}],
['call-northside777', undefined]
])('should parse %s to be %s', (input, result) => {
expect(filePath.findSeasonEpisode(input)).toEqual(result)
});
});
describe('Find episode', () => {
test.each([
['', undefined],
['test 2 test', undefined],
['2 the 204', {restName: '2 the ', episodes: [4]}],
['test 2 test 204', {restName: 'test 2 test ', episodes: [4]}],
])('should parse %s to be %s', (input, result) => {
expect(filePath.findEpisode(input, 2)).toEqual(result);
});
});
});