I'm struggling to find a good way to implement my system, which essentially matches the season and episode number of the show from the line, here you can see the current working code: https://github.com/huddy/tvfilename
I am currently rewriting this library and I want to get a more convenient way to implement how the match happens, at present, essentially, the way it works:
There is a folder with classes (called handlers), each handler is a class that implements an interface to provide a method called match (); exists, this matching method uses the regular expression stored in the property of this handler class (of which there are many) to try and match the season and episode.
The class loads all of these handlers, creating an instance of each of them in the array stored in the property, when I want to try and match some lines that the method iterates over these objects that call match (); and the first that returns true, then returns in the result set with the season and episode that it matched.
I don’t like this way of doing it, it’s somehow hacked for me, and I hope the design template can help, my ultimate goal is to do it using best practices, and I wondered which one should I use?
Other existing issues:
More than one handler can match a string, so they should be fine to prevent the greedier from matching, not sure if this is allowed, as some of the regex patterns should be greedy, but maybe a scoring system that shows a percentage of how much likely coincidence, I would not know how to actually implement it.
, - , , , - . , , , , ..