dbr / tvnamer

Automatic TV episode file renamer, uses data from thetvdb.com via tvdb_api
https://pypi.python.org/pypi/tvnamer/
The Unlicense
907 stars 115 forks source link

Improve configuration of filename patterns #191

Open dbr opened 3 years ago

dbr commented 3 years ago

Currently saving the config includes the complete list of regex patterns

This probably isn't too good, as most of the time people a) wont change them, or b) won't remove that option and this wont pick up improvements to the default patterns

Instead the default patterns should be moved out of the config, and instead:

  1. New option to add custom patterns.
  2. Need a way to control if these patterns are checked before or after the built-in patterns
  3. Need a way to control if the custom patterns completely replace the built-in ones or not (e.g someone might only want to match a very strict set of patterns)

Should use v4.0 to deprecate the filename_patterns option - keep respecting it for now, but emit warning that this option will be removed soon

dbr commented 3 years ago

Most flexible way would be to have a custom_patterns = {'pattern': '...', order: '...'} or something, but that seems a bit clunky

Instead maybe just:

  1. A custom_patterns config option, default empty, with a list of regexs
  2. A second option, something like custom_patterns_order which can be either before, after, or replace (i.e before builtins, after builtins, or replace them entirely). Default would probably be "before".

This makes it easy to just add one or two custom patterns, and either prefer them tot eh builtins, or use them as a fallback. The "replace" option would be useful to customize the pattern matching in more complex ways (or only handle a very specific set of patterns)