Exemplo n.º 1
0
def test_resolve_absoloute_episode():
    """Test resolving by absolute episode number
    """

    conf = """
    {"always_rename": true,
    "select_first": true}
    """

    out_data = run_tvnamer(
        with_files = ['[Bleachverse]_BLEACH_310.avi'],
        with_config = conf,
        with_input = "")

    expected_files = ['[Bleachverse] Bleach - 310 - Ichigo\'s Resolution.avi']

    verify_out_data(out_data, expected_files)

    print("Checking output files are re-parsable")
    out_data = run_tvnamer(
        with_files = expected_files,
        with_config = conf,
        with_input = "")

    expected_files = ['[Bleachverse] Bleach - 310 - Ichigo\'s Resolution.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 2
0
def test_skipping_after_replacements():
    """When custom-replacement is specified, should still skip file if name is correct
    """

    conf = """
    {"select_first": true,
    "input_filename_replacements": [
        {"is_regex": false,
        "match": "v",
        "replacement": "u"}
    ],
    "output_filename_replacements": [
        {"is_regex": false,
        "match": "u",
        "replacement": "v"}
    ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['Scrvbs - [01x01] - My First Day.avi'],
        with_config = conf,
        with_input = "")

    expected_files = ['Scrvbs - [01x01] - My First Day.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 3
0
def test_simple_blacklist_mixed():
    """Blacklist with simple strings, mixed with the more complex dict
    option (which allows regexs and matching against extension)
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
            "scrubs.s02e01.avi",
            {"is_regex": true,
             "match": ".*s\\\\d+e02.*"}
        ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi', 'scrubs.s02e01.avi', 'scrubs.s02e02.avi'],
        with_config = conf)

    expected_files = [
        'Scrubs - [01x01] - My First Day.avi',
        'scrubs.s02e01.avi',
        'scrubs.s02e02.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 4
0
def test_replacements_applied_before_force_name():
    """input_filename_replacements apply to filename, before --name=SeriesName takes effect
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true,

    "force_name": "Scrubs",

    "input_filename_replacements": [
        {"is_regex": true,
        "match": "S01E02 - ",
        "replacement": ""}
    ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['S01E02 - Some File.avi'],
        with_config = conf)

    expected_files = ['S01E02 - Some File.avi']

    verify_out_data(out_data, expected_files, expected_returncode = 2)
Exemplo n.º 5
0
def test_extension_pattern_default():
    """Test default extension handling, no language codes
    """

    conf = r"""
    {"extension_pattern": "(\\.[a-zA-Z0-9]+)$",
    "batch": true,
    "valid_extensions": ["avi", "srt"]}
    """

    input_files = [
        "scrubs.s01e01.hdtv.fake.avi",
        "scrubs.s01e01.hdtv.fake.srt",
        "my.name.is.earl.s01e01.fake.avi",
        "my.name.is.earl.s01e01.some.other.fake.eng.srt",
    ]
    expected_files = [
        "Scrubs - [01x01] - My First Day.avi",
        "Scrubs - [01x01] - My First Day.srt",
        "My Name Is Earl - [01x01] - Pilot.avi",
        "My Name Is Earl - [01x01] - Pilot.srt",
    ]

    out_data = run_tvnamer(
        with_files = input_files,
        with_config = conf,
        with_input = "")

    verify_out_data(out_data, expected_files)
Exemplo n.º 6
0
def test_replace_ands_in_output_also():
    """Test replace "and" "&" for search, and replace & in output filename
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true,
    "input_filename_replacements": [
        {"is_regex": true,
        "match": "(\\Wand\\W| & )",
        "replacement": " "}
    ],
    "output_filename_replacements": [
        {"is_regex": true,
        "match": " & ",
        "replacement": " and "}
    ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['Brothers.and.Sisters.S05E16.HDTV.XviD-LOL.avi'],
        with_config = conf,
        with_input = "",
        run_on_directory = True)

    expected_files = ['Brothers and Sisters - [05x16] - Home Is Where The Fort Is.avi']

    verify_out_data(out_data, expected_files)
def test_replacing_ands():
    """Tests removind "and" and "&" from input files
    """
    out_data = run_tvnamer(
        with_files = ['Law & Order s01e01.avi'],
        with_config = """
{
    "input_filename_replacements": [
        {"is_regex": true,
        "match": "( and | & )",
        "replacement": " "}
    ],
    "output_filename_replacements": [
        {"is_regex": false,
        "match": " & ",
        "replacement": " and "}
    ],
    "always_rename": true,
    "select_first": true
}
""")

    expected_files = ['Law and Order - [01x01] - Prescription for Death.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 8
0
def test_extension_pattern_custom():
    """Test custom extension pattern, multiple language codes
    """

    conf = r"""
    {"extension_pattern": "((\\.|-)(eng|cze|EN|CZ)(?=\\.(sub|srt)))?(\\.[a-zA-Z0-9]+)$",
    "batch": true,
    "valid_extensions": ["avi", "srt"]}
    """

    input_files = [
        "scrubs.s01e01.hdtv.fake.avi",
        "scrubs.s01e01.hdtv.fake.srt",
        "scrubs.s01e01.hdtv.fake-CZ.srt",
        "scrubs.s01e01.hdtv.fake-EN.srt",
        "my.name.is.earl.s01e01.fake.avi",
        "my.name.is.earl.s01e01.some.other.fake.eng.srt",
        "my.name.is.earl.s01e01.fake.cze.srt",
    ]
    expected_files = [
        "Scrubs - [01x01] - My First Day.avi",
        "Scrubs - [01x01] - My First Day.srt",
        "Scrubs - [01x01] - My First Day-CZ.srt",
        "Scrubs - [01x01] - My First Day-EN.srt",
        "My Name Is Earl - [01x01] - Pilot.avi",
        "My Name Is Earl - [01x01] - Pilot.eng.srt",
        "My Name Is Earl - [01x01] - Pilot.cze.srt",
    ]

    out_data = run_tvnamer(
        with_files = input_files,
        with_config = conf,
        with_input = "")

    verify_out_data(out_data, expected_files)
def test_multiep_different_names():
    """Default config - two different names are joined with 'multiep_join_name_with', 'multiep_format' doesn't matter
    """

    conf = """
    {
    "output_filename_replacements": [
        {"is_regex": false,
        "match": ":",
        "replacement": " -"}
    ],

    "multiep_join_name_with": ", ",
    "batch": true,
    "multiep_format": "%(foo)s"}
    """

    out_data = run_tvnamer(
        with_files = ["star.trek.enterprise.s01e03e04.avi"],
        with_config = conf,
        with_input = "")

    expected_files = ['Star Trek - Enterprise - [01x03-04] - Fight or Flight, Strange New World.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 10
0
def test_dvd_order():
    """Tests TvDB dvd order naming
    """

    input_files = [
        'batman the animated series s01e01.xvid']

    expected_files = [
        'Batman - The Animated Series - [01x01] - On Leather Wings.xvid']

    conf = r"""
    {
      "output_filename_replacements": [
        {"is_regex": true,
        "match": ": ",
        "replacement": " - "}
      ]
    }
    """

    out_data = run_tvnamer(
        with_files = input_files,
        with_flags = ["--order", 'dvd'],
        with_input = "1\ny\n",
        with_config = conf)

    verify_out_data(out_data, expected_files)
def test_partial_blacklist_using_mix():
    """Tests single match of filename blacklist using a mix of regex and simple match
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
        {"is_regex": true,
         "match": ".*s02e01.*"},
        {"is_regex": false,
         "match": "s02e02"}
        ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi', 'scrubs.s02e01.avi', 'scrubs.s02e02.avi'],
        with_config = conf)

    expected_files = [
        'Scrubs - [01x01] - My First Day.avi',
        'scrubs.s02e01.avi',
        'scrubs.s02e02.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 12
0
def test_name_arg_skips_replacements():
    """Should not apply input_filename_replacements to --name=SeriesName arg value
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true,

    "force_name": "Scrubs",

    "input_filename_replacements": [
        {"is_regex": true,
        "match": "Scrubs",
        "replacement": "Blahblahblah"}
    ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['S01E02 - Some File.avi'],
        with_config = conf)

    expected_files = ['Scrubs - [01x02] - My Mentor.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 13
0
def test_multiep_same_names_without_number():
    """Default config - same names, ensure that missing number doesn't matter
    """

    conf = """
    {
    "output_filename_replacements": [
        {"is_regex": false,
        "match": ":",
        "replacement": " -"}
    ],

    "multiep_join_name_with": ", ",
    "batch": true,
    "multiep_format": "%(epname)s (Parts %(episodemin)s-%(episodemax)s)"}
    """

    out_data = run_tvnamer(
        with_files = ["star.trek.deep.space.nine.s01e01e02.avi"],
        with_config = conf,
        with_input = "")

    expected_files = ['Star Trek - Deep Space Nine - [01x01-02] - Emissary (Parts 1-2).avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 14
0
def test_simple_single_file():
    """Test most simple usage
    """

    out_data = run_tvnamer(with_files=["scrubs.s01e01.avi"], with_input="1\ny\n")

    expected_files = ["Scrubs - [01x01] - My First Day.avi"]

    verify_out_data(out_data, expected_files)
Exemplo n.º 15
0
def test_filename_already_exists():
    """If the filename is already correct, don't prompt
    """

    out_data = run_tvnamer(with_files=["Scrubs - [01x01] - My First Day.avi", "scrubs.s01e01.avi"], with_input="1\ny\n")

    expected_files = ["Scrubs - [01x01] - My First Day.avi", "scrubs.s01e01.avi"]

    verify_out_data(out_data, expected_files)
Exemplo n.º 16
0
def test_simple_single_file():
    """Files without series name should be skipped
    """

    out_data = run_tvnamer(with_files=["S01E02 - Some File.avi"], with_flags=["--batch"])

    expected_files = ["S01E02 - Some File.avi"]

    verify_out_data(out_data, expected_files, expected_returncode=2)
Exemplo n.º 17
0
def test_renaming_always_doesnt_overwrite():
    """If trying to rename a file that exists, should not create new file
    """
    input_files = ["Scrubs.s01e01.avi", "Scrubs - [01x01] - My First Day.avi"]

    expected_files = ["Scrubs.s01e01.avi", "Scrubs - [01x01] - My First Day.avi"]

    out_data = run_tvnamer(with_files=input_files, with_flags=["--batch"])

    verify_out_data(out_data, expected_files)
Exemplo n.º 18
0
def test_unicode_in_inputname():
    """Tests parsing a file with unicode in the input filename
    """
    input_files = [u"The Big Bang Theory - S02E07 - The Panty Pin\u0303ata Polarization.avi"]

    expected_files = [u"The Big Bang Theory - [02x07] - The Panty Pin\u0303ata Polarization.avi"]

    out_data = run_tvnamer(with_files=input_files, with_flags=["--batch"])

    verify_out_data(out_data, expected_files)
Exemplo n.º 19
0
def test_not_recursive():
    """Tests the nested files aren't found when not recursive
    """
    input_files = ["Scrubs.s01e01.avi", "nested/subdir/Scrubs.s01e02.avi"]

    expected_files = ["Scrubs - [01x01] - My First Day.avi", "nested/subdir/Scrubs.s01e02.avi"]

    out_data = run_tvnamer(with_files=input_files, with_flags=["--not-recursive", "--batch"], run_on_directory=True)

    verify_out_data(out_data, expected_files)
Exemplo n.º 20
0
def test_unicode_in_search_results():
    """Show with unicode in search results
    """
    input_files = ["psych.s04e11.avi"]

    expected_files = ["Psych - [04x11] - Thrill Seekers & Hell Raisers.avi"]

    out_data = run_tvnamer(with_files=input_files, with_input="1\ny\n")

    verify_out_data(out_data, expected_files)
Exemplo n.º 21
0
def test_cli_destination():
    """Tests specifying the destination via command line argument
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi'],
        with_flags = ['--batch', '--move', '--movedestination=season %(seasonnumber)d/'])

    expected_files = ['season 1/Scrubs - [01x01] - My First Day.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 22
0
def test_simple_single_file():
    """Boring example
    """

    out_data = run_tvnamer(
        with_files = ['Some File.avi'],
        with_flags = ["--batch"])

    expected_files = ['Some File.avi']

    verify_out_data(out_data, expected_files, expected_returncode = 2)
Exemplo n.º 23
0
def test_simple_single_file_with_forced_seriesnames():
    """Specifying 's01e01.avi' should parse when --name=SeriesName arg is specified
    """

    out_data = run_tvnamer(
        with_files = ['S01E02 - Some File.avi'],
        with_flags = ["--batch", '--name', 'Scrubs'])

    expected_files = ['Scrubs - [01x02] - My Mentor.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 24
0
def test_no_series_name():
    """File without series name should be skipped (unless '--name=MySeries' arg is supplied)
    """

    out_data = run_tvnamer(
        with_files = ['s01e01 Some File.avi'],
        with_flags = ["--batch"])

    expected_files = ['s01e01 Some File.avi']

    verify_out_data(out_data, expected_files, expected_returncode = 2)
Exemplo n.º 25
0
def test_no_seasonnumber():
    """Test episode with no series number
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.e01.avi'],
        with_flags = ['--batch'])

    expected_files = ['Scrubs - [01] - My First Day.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 26
0
def test_correct_filename():
    """If the filename is already correct, don't prompt
    """

    out_data = run_tvnamer(
        with_files = ['Scrubs - [01x01] - My First Day.avi'],
        with_input = "1\ny\n")

    expected_files = ['Scrubs - [01x01] - My First Day.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 27
0
def test_no_blacklist():
    """Tests empty list of filename regexps is parsed as expected
    """

    conf = """
    {"batch": true,
    "filename_blacklist": []}
    """

    out_data = run_tvnamer(with_files=["scrubs.s01e01.avi", "scrubs.s01e02.avi"], with_config=conf)

    expected_files = ["Scrubs - [01x01] - My First Day.avi", "Scrubs - [01x02] - My Mentor.avi"]

    verify_out_data(out_data, expected_files)
Exemplo n.º 28
0
def test_temp_override():
    """Test --name argument
    """

    conf = """
    {"batch": true}
    """

    out_data = run_tvnamer(
        with_files=["scrubs.s01e01.avi"], with_config=conf, with_flags=["--name", "lost"], with_input=""
    )

    expected_files = ["Lost - [01x01] - Pilot (1).avi"]

    verify_out_data(out_data, expected_files)
Exemplo n.º 29
0
def test_dynamic_destination():
    """Move file to simple relative static dir
    """

    conf = """
    {"move_files_destination": "tv/%(seriesname)s/season %(seasonnumber)d/",
    "batch": true}
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi'],
        with_config = conf)

    expected_files = ['tv/Scrubs/season 1/Scrubs - [01x01] - My First Day.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 30
0
def test_group_no_epname():
    """Anime filename, on episode with no name [#100]
    """
    out_data = run_tvnamer(
        with_files = ['[Some Group] Somefakeseries - 01 [A1B2C3].avi'],
        with_config = """
{
    "batch": true,

    "filename_anime_without_episode": "[%(group)s] %(seriesname)s - %(episode)s [%(crc)s]%(ext)s"
}
""")

    expected_files = ['[Some Group] Somefakeseries - 01 [A1B2C3].avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 31
0
def test_skip_behaviour_error():
    """With skip_behaviour:error, should end process
    """

    conf = """
    {"skip_file_on_error": false,
    "batch": true,
    "skip_behaviour": "warn"}
    """

    out_data = run_tvnamer(with_files=[
        'scrubs.s01e01.avi', 'a.fake.episode.s01e01.avi', 'scrubs.s01e02.avi'
    ],
                           with_config=conf,
                           with_input="")

    expected_files = [
        'a fake episode - [01x01].avi', 'Scrubs - [01x01] - My First Day.avi',
        'Scrubs - [01x02] - My Mentor.avi'
    ]

    verify_out_data(out_data, expected_files)
Exemplo n.º 32
0
def test_blacklist_fullpath():
    """Blacklist against full path
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
        {"is_regex": true,
         "full_path": true,
         "match": ".*/subdir/.*"}
        ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['subdir/scrubs.s01e01.avi'],
        with_config = conf)

    expected_files = ['subdir/scrubs.s01e01.avi']

    verify_out_data(out_data, expected_files, expected_returncode = 2)
Exemplo n.º 33
0
def test_move_files_full_filepath_with_origfilename():
    """Moving file destination including a filename
    """

    conf = """
    {"move_files_enable": true,
    "move_files_destination": "TestDir/%(seriesname)s/season %(seasonnumber)02d/%(episodenumbers)s/%(originalfilename)s",
    "move_files_destination_is_filepath": true,
    "batch": true}
    """

    out_data = run_tvnamer(
        with_files=['scrubs.s01e01.avi', 'scrubs.s01e02.avi'],
        with_config=conf,
        with_input="")

    expected_files = [
        'TestDir/Scrubs/season 01/01/scrubs.s01e01.avi',
        'TestDir/Scrubs/season 01/02/scrubs.s01e02.avi'
    ]

    verify_out_data(out_data, expected_files)
Exemplo n.º 34
0
def test_own_api_key():
    """Check overriding API key works
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true,
    "tvdb_api_key": "xxxxxxxxx",
    "skip_behaviour": "error
    }
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi'],
        with_config = conf,
        with_input = "",
        with_flags=['-vvv'],
        run_on_directory = True)

    expected_files = ['scrubs.s01e01.avi']

    verify_out_data(out_data, expected_files, expected_returncode=1)
Exemplo n.º 35
0
def test_with_invalid_seriesname_test2():
    """Another test for series name containing invalid filename characters
    """

    conf = """
    {"move_files_enable": true,
    "move_files_destination": "%(seriesname)s",
    "batch": true,
    "move_files_fullpath_replacements": [
         {"is_regex": true,
          "match": "CSI_ Miami",
          "replacement": "CSI"}]
    }
    """

    out_data = run_tvnamer(
        with_files = ['csi.miami.s01e01.avi'],
        with_config = conf)

    expected_files = ['CSI/CSI - [01x01] - Golden Parachute.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 36
0
def test_fullpath_replacements():
    """Tests replacing strings in output path
    """
    out_data = run_tvnamer(
    with_files = ['scrubs.s01e01.avi'],
    with_config = """
{
    "move_files_enable": true,
    "move_files_destination": "%(seriesname)s",
    "move_files_fullpath_replacements": [
        {"is_regex": true,
        "match": "Scr.*?s",
        "replacement": "A Test"}
    ],
    "always_rename": true,
    "select_first": true
}
""")

    expected_files = ['A Test/A Test - [01x01] - My First Day.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 37
0
def test_force_overwrite_default():
    """Forceful-overwrite should be disabled by default
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true
    }
    """

    out_data = run_tvnamer(with_files=[
        'Scrubs - [01x01] - My First Day.avi', 'scrubs - [01x01].avi'
    ],
                           with_config=conf,
                           with_input="",
                           run_on_directory=True)

    expected_files = [
        'Scrubs - [01x01] - My First Day.avi', 'scrubs - [01x01].avi'
    ]

    verify_out_data(out_data, expected_files)
Exemplo n.º 38
0
def test_multiple_replacements():
    """Tests multiple replacements on one file
    """
    out_data = run_tvnamer(with_files=['scrubs.s01e01.avi'],
                           with_config="""
{
    "output_filename_replacements": [
        {"is_regex": true,
        "match": "[ua]+",
        "replacement": "v"},
        {"is_regex": false,
        "match": "v",
        "replacement": "_"}
    ],
    "always_rename": true,
    "select_first": true
}
""")

    expected_files = ['Scr_bs - [01x01] - My First D_y.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 39
0
def test_move_interactive_somefiles():
    """Tests interactive UI allows not renaming some files, renaming/moving others

    Rename and move first file, don't rename second file (so no move), and
    rename but do not move last file (Input is: y/y, n, y/n)
    """

    conf = """
    {"move_files_enable": true,
    "move_files_destination": "test",
    "select_first": true}
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi', 'scrubs.s01e02.avi', 'scrubs.s01e03.avi'],
        with_config = conf,
        with_input = "y\ny\nn\ny\nn\n")

    expected_files = ['test/Scrubs - [01x01] - My First Day.avi',
        'scrubs.s01e02.avi',
        'Scrubs - [01x03] - My Best Friend\'s Mistake.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 40
0
def test_force_overwrite_disabled():
    """Explicitly disabling forceful-overwrite
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true,
    "overwrite_destination_on_rename": false
    }
    """

    out_data = run_tvnamer(with_files=[
        'Scrubs - [01x01] - My First Day.avi', 'scrubs - [01x01].avi'
    ],
                           with_config=conf,
                           with_input="",
                           run_on_directory=True)

    expected_files = [
        'Scrubs - [01x01] - My First Day.avi', 'scrubs - [01x01].avi'
    ]

    verify_out_data(out_data, expected_files)
Exemplo n.º 41
0
def test_unicode_in_inputname():
    """Tests parsing a file with unicode in the input filename
    """

    import os, sys
    if os.getenv("TRAVIS",
                 "false") == "true" and sys.version_info[0:2] == (2.6):
        from nose.plugins.skip import SkipTest
        raise SkipTest(
            "Ignoring test which triggers bizarre bug in nosetests, in python 2.6, only on travis."
        )

    input_files = [
        u'The Big Bang Theory - S02E07 - The Panty Pin\u0303ata Polarization.avi'
    ]

    expected_files = [
        u'The Big Bang Theory - [02x07] - The Panty Pin\u0303ata Polarization.avi'
    ]

    out_data = run_tvnamer(with_files=input_files, with_flags=["--batch"])

    verify_out_data(out_data, expected_files)
Exemplo n.º 42
0
def test_simple_blacklist():
    """Blacklist with simple strings
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
            "scrubs.s02e01.avi"
        ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi', 'scrubs.s02e01.avi', 'scrubs.s02e02.avi'],
        with_config = conf)

    expected_files = [
        'Scrubs - [01x01] - My First Day.avi',
        'scrubs.s02e01.avi',
        'Scrubs - [02x02] - My Nightingale.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 43
0
def test_blacklist_exclude_extension():
    """Blacklist against full path
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
        {"is_regex": true,
         "full_path": true,
         "exclude_extension": true,
         "match": "\\\\.avi"}
        ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi'],
        with_config = conf)

    expected_files = ['Scrubs - [01x01] - My First Day.avi']

    verify_out_data(out_data, expected_files, expected_returncode = 0)
Exemplo n.º 44
0
def test_dotfiles():
    """Tests blacklisting filename beginning with "."
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
        {"is_regex": true,
         "match": "^\\\\..*"}
        ]
    }
    """

    out_data = run_tvnamer(
        with_files=['.scrubs.s01e01.avi', 'scrubs.s02e02.avi'],
        with_config=conf)

    expected_files = [
        '.scrubs.s01e01.avi', 'Scrubs - [02x02] - My Nightingale.avi'
    ]

    verify_out_data(out_data, expected_files, expected_returncode=0)
Exemplo n.º 45
0
def test_dotfiles():
    """Tests complete blacklist of all filenames with a regex
    """

    from nose.plugins.skip import SkipTest
    raise SkipTest("Not working yet")

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
        {"is_regex": true,
         "match": "^\\\\..*"}
        ]
    }
    """

    out_data = run_tvnamer(
        with_files=['.scrubs.s01e01.avi', 'scrubs.s02e02.avi'],
        with_config=conf)

    expected_files = ['.scrubs.s01e01.avi', 'Scrubs - [02x02] - Blah.avi']

    verify_out_data(out_data, expected_files, expected_returncode=2)
Exemplo n.º 46
0
def test_name_arg_skips_replacements():
    """Should not apply input_filename_replacements to --name=SeriesName arg value
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true,

    "force_name": "Scrubs",

    "input_filename_replacements": [
        {"is_regex": true,
        "match": "Scrubs",
        "replacement": "Blahblahblah"}
    ]
    }
    """

    out_data = run_tvnamer(with_files=['S01E02 - Some File.avi'],
                           with_config=conf)

    expected_files = ['Scrubs - [01x02] - My Mentor.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 47
0
def test_single_extension_with_subdirs():
    """Tests one valid extension recursing into sub-dirs
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "valid_extensions": ["avi"],
    "recursive": true}
    """

    out_data = run_tvnamer(with_files=[
        'scrubs.s01e01.avi', 'testdir/scrubs.s01e02.mkv',
        'testdir/scrubs.s01e04.avi'
    ],
                           with_config=conf,
                           run_on_directory=True)

    expected_files = [
        'Scrubs - [01x01] - My First Day.avi', 'testdir/scrubs.s01e02.mkv',
        'testdir/Scrubs - [01x04] - My Old Lady.avi'
    ]

    verify_out_data(out_data, expected_files)
Exemplo n.º 48
0
def test_replacing_ands():
    """Tests removind "and" and "&" from input files
    """
    out_data = run_tvnamer(with_files=['Law & Order s01e01.avi'],
                           with_config="""
{
    "input_filename_replacements": [
        {"is_regex": true,
        "match": "( and | & )",
        "replacement": " "}
    ],
    "output_filename_replacements": [
        {"is_regex": false,
        "match": " & ",
        "replacement": " and "}
    ],
    "always_rename": true,
    "select_first": true
}
""")

    expected_files = ['Law and Order - [01x01] - Prescription for Death.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 49
0
def test_full_blacklist():
    """Tests complete blacklist of all filenames with a regex
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
        {"is_regex": true,
         "match": ".*"}
        ]
    }
    """

    out_data = run_tvnamer(with_files=[
        'scrubs.s01e01.avi', 'scrubs.s02e01.avi', 'scrubs.s02e02.avi'
    ],
                           with_config=conf)

    expected_files = [
        'scrubs.s01e01.avi', 'scrubs.s02e01.avi', 'scrubs.s02e02.avi'
    ]

    verify_out_data(out_data, expected_files, expected_returncode=2)
Exemplo n.º 50
0
def test_partial_blacklist_using_regex():
    """Tests single match of filename blacklist using a regex match
    """

    conf = """
    {"always_rename": true,
    "select_first": true,
    "filename_blacklist": [
        {"is_regex": true,
         "match": ".*s02e01.*"}
        ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['scrubs.s01e01.avi', 'scrubs.s02e01.avi', 'scrubs.s02e02.avi'],
        with_config = conf)

    expected_files = [
        'Scrubs - [01x01] - My First Day.avi',
        'scrubs.s02e01.avi',
        'Scrubs - [02x02] - My Nightingale.avi']

    verify_out_data(out_data, expected_files)
Exemplo n.º 51
0
def test_simple_batch_functionality():
    """Tests renaming single files at a time, in batch mode
    """

    tests = [
        {
            'in': 'scrubs.s01e01.hdtv.fake.avi',
            'expected': 'Scrubs - [01x01] - My First Day.avi'
        },
        {
            'in': 'my.name.is.earl.s01e01.fake.avi',
            'expected': 'My Name Is Earl - [01x01] - Pilot.avi'
        },
        {
            'in': 'a.fake.show.s12e24.fake.avi',
            'expected': 'a.fake.show.s12e24.fake.avi'
        },
        {
            'in': 'total.access.s01e01.avi',
            'expected': 'Total Access 24_7 - [01x01] - Episode #1.avi'
        },
    ]

    for curtest in tests:

        print("Expecting %r to turn into %r" %
              (curtest['in'], curtest['expected']))
        out_data = run_tvnamer(
            with_files=[
                curtest['in'],
            ],
            with_flags=['--batch'],
        )
        verify_out_data(out_data, [
            curtest['expected'],
        ])
Exemplo n.º 52
0
def test_replacements_applied_before_force_name():
    """input_filename_replacements apply to filename, before --name=SeriesName takes effect
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true,

    "force_name": "Scrubs",

    "input_filename_replacements": [
        {"is_regex": true,
        "match": "S01E02 - ",
        "replacement": ""}
    ]
    }
    """

    out_data = run_tvnamer(with_files=['S01E02 - Some File.avi'],
                           with_config=conf)

    expected_files = ['S01E02 - Some File.avi']

    verify_out_data(out_data, expected_files, expected_returncode=2)
Exemplo n.º 53
0
def test_replace_ands():
    """Test replace "and" "&"
    """

    conf = r"""
    {"always_rename": true,
    "select_first": true,
    "input_filename_replacements": [
        {"is_regex": true,
        "match": "(\\Wand\\W| & )",
        "replacement": " "}
    ]
    }
    """

    out_data = run_tvnamer(
        with_files = ['Brothers.and.Sisters.S05E16.HDTV.XviD-LOL.avi'],
        with_config = conf,
        with_input = "",
        run_on_directory = True)

    expected_files = ['Brothers & Sisters - [05x16] - Home Is Where The Fort Is.avi']

    verify_out_data(out_data, expected_files)