Repository: xbmc/xbmc
File: xbmc/video/test/TestVideoInfoScanner.cpp (C++)

Code before:

static const TestEntry TestData[] = {
    //season+episode
    {"foo.S02E03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.S2E3.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.S02.E03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.S02_E03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.S02xE03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.2x03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.203.mkv", {{2, 3}}, {{2, 3}}},
    //episode only
    {"foo.Ep03.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.Ep_03.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.Part.III.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.Part.3.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.E03.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.2009.E03.mkv", {{1, 3}}, {{1, 3}}},
    // multi-episode (not ranges)
    {"The Legend of Korra - S01E01-02 - Welcome to Republic City & A Leaf in the Wind.mkv",
     {{1, 1}, {1, 2}},
     {{1, 1}, {1, 2}}},
    {"foo s01e01-episode1.title-s01e02-episode2.title.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}},
    {"foo.S01E01E02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}},
    {"foo.S01E03E04E05.mkv", {{1, 3}, {1, 4}, {1, 5}}, {{1, 3}, {1, 4}, {1, 5}}},
    {"foo.S02E01-S02E02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}},
    {"foo S02E01-bar-S02E02-bar.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}},
    {"foo S02E01-S02E02-S02E03.mkv", {{2, 1}, {2, 2}, {2, 3}}, {{2, 1}, {2, 2}, {2, 3}}},
    {"foo 2x01-2x02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}},
    {"foo ep01-ep02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}},
    {"foo S02E01-02-03.mkv", {{2, 1}, {2, 2}, {2, 3}}, {{2, 1}, {2, 2}, {2, 3}}},
    {"foo 2x01x02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}},
    {"foo ep01-02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}},
    {"foo.S02E01S02E03.mkv", {{2, 1}, {2, 3}}, {{2, 1}, {2, 3}}},
    // spanning episode ranges
    {"foo.ep03-ep05.mkv", {{1, 3}, {1, 4}, {1, 5}}, {{1, 3}, {1, 5}}},
    {"foo.S05E03-E05.mkv", {{5, 3}, {5, 4}, {5, 5}}, {{5, 3}, {5, 5}}},
    {"foo.S05E03-S05E05.mkv", {{5, 3}, {5, 4}, {5, 5}}, {{5, 3}, {5, 5}}},
    {"foo.S05E01-E03-E05.mkv", {{5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}}, {{5, 1}, {5, 3}, {5, 5}}},
    {"foo.S05E01-S05E03-S05E05.mkv",
     {{5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}},
     {{5, 1}, {5, 3}, {5, 5}}},
    {"foo.5x03-5x05.mkv", {{5, 3}, {5, 4}, {5, 5}}, {{5, 3}, {5, 5}}},
    // not ranges
    {"foo.E03-05.mkv", {{1, 3}, {1, 5}}, {{1, 3}, {1, 5}}},
    {"foo.ep03-05.mkv", {{1, 3}, {1, 5}}, {{1, 3}, {1, 5}}},
    {"foo.S05E03-05.mkv", {{5, 3}, {5, 5}}, {{5, 3}, {5, 5}}},
    // multi-season
    {"foo.S00E100S05E03E04E05.mkv",
     {{0, 100}, {5, 3}, {5, 4}, {5, 5}},
     {{0, 100}, {5, 3}, {5, 4}, {5, 5}}},
    {"foo.S01E01E02S02E01.mkv", {{1, 1}, {1, 2}, {2, 1}}, {{1, 1}, {1, 2}, {2, 1}}},

Review comment (suggestion):
As mentioned in an earlier comment, it's difficult to impossible to make this one work reliably, the episode title could be a number that will be interpreted as an episode number. Impact was low before episode ranges, it's higher now. Low priority as far as I am concerned.

Code after:

static const TestEntry TestData[] = {
    //season+episode
    {"foo.S02E03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.S2E3.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.S02.E03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.S02_E03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.S02xE03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.2x03.mkv", {{2, 3}}, {{2, 3}}},
    {"foo.203.mkv", {{2, 3}}, {{2, 3}}},
    {"24 S01E01 12:00AM - 1:00AM.mkv", {{1, 1}}, {{1, 1}}},
    {"Miracle Workers S01E02 13 Days.mkv", {{1, 2}}, {{1, 2}}},
    //episode only
    {"foo.Ep03.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.Ep_03.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.Part.III.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.Part.3.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.pt.III.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.pt_IV.mkv", {{1, 4}}, {{1, 4}}},
    {"foo.E03.mkv", {{1, 3}}, {{1, 3}}},
    {"foo.2009.E03.mkv", {{1, 3}}, {{1, 3}}},
    // multi-episode (not ranges)
    {"The Legend of Korra - S01E01-02 - Welcome to Republic City & A Leaf in the Wind.mkv",
     {{1, 1}, {1, 2}},
     {{1, 1}, {1, 2}}},
    {"foo s01e01-episode1.title-s01e02-episode2.title.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}},
    {"foo.S01E01E02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}},
    {"foo.S01E03E04E05.mkv", {{1, 3}, {1, 4}, {1, 5}}, {{1, 3}, {1, 4}, {1, 5}}},
    {"foo.S02E01-S02E02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}},
    {"foo S02E01-bar-S02E02-bar.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}},
    {"foo S02E01-S02E02-S02E03.mkv", {{2, 1}, {2, 2}, {2, 3}}, {{2, 1}, {2, 2}, {2, 3}}},
    {"foo 2x01-2x02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}},
    {"foo ep01-ep02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}},
    {"foo S02E01-02-03.mkv", {{2, 1}, {2, 2}, {2, 3}}, {{2, 1}, {2, 2}, {2, 3}}},
    {"foo 2x01x02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}},
    {"foo ep01-02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}},
    {"foo.S02E01S02E03.mkv", {{2, 1}, {2, 3}}, {{2, 1}, {2, 3}}},
    // spanning episode ranges
    {"foo.ep03-ep05.mkv", {{1, 3}, {1, 4}, {1, 5}}, {{1, 3}, {1, 5}}},
    {"foo.S05E03-E05.mkv", {{5, 3}, {5, 4}, {5, 5}}, {{5, 3}, {5, 5}}},
    {"foo.S05E03-S05E05.mkv", {{5, 3}, {5, 4}, {5, 5}}, {{5, 3}, {5, 5}}},
    {"foo.S05E01-E03-E05.mkv", {{5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}}, {{5, 1}, {5, 3}, {5, 5}}},
    {"foo.S05E01-S05E03-S05E05.mkv",
     {{5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}},
     {{5, 1}, {5, 3}, {5, 5}}},
    {"foo.5x03-5x05.mkv", {{5, 3}, {5, 4}, {5, 5}}, {{5, 3}, {5, 5}}},
    // not ranges
    {"foo.E03-05.mkv", {{1, 3}, {1, 5}}, {{1, 3}, {1, 5}}},
    {"foo.ep03-05.mkv", {{1, 3}, {1, 5}}, {{1, 3}, {1, 5}}},
    {"foo.S05E03-05.mkv", {{5, 3}, {5, 5}}, {{5, 3}, {5, 5}}},
    // multi-season