# Buggy code
def _guessit_options(options):
    settings = {
        "name_only": True,
        "allowed_languages": ["en", "fr"],
        "allowed_countries": ["us", "uk", "gb"],
    }
    options["episode_prefer_number"] = not options.get("identified_by") == "ep"
    if options.get("allow_groups"):
        options["expected_group"] = options["allow_groups"]
    if "date_yearfirst" in options:
        options["date_year_first"] = options["date_yearfirst"]
    if "date_dayfirst" in options:
        options["date_day_first"] = options["date_dayfirst"]
    else:
        # See https://github.com/guessit-io/guessit/issues/329
        # https://github.com/guessit-io/guessit/pull/333
        # They made changes that break backward compatibility, so we have to make do this hackery
        if options.get("date_year_first"):
            options["date_day_first"] = True
    settings.update(options)
    return settings


# Traceback (InterfaceError)
2018-11-10 13:01 DEBUG    manager                       Config file /config/config.yml selected
2018-11-10 13:02 INFO     scheduler                     Starting scheduler
2018-11-10 13:02 INFO     web_server_daemon                 Running web server at IP 0.0.0.0:5050
2018-11-10 13:02 INFO     web_server_daemon                 Initiating API
2018-11-10 13:02 INFO     web_server_daemon                 Registering WebUI v2
2018-11-10 13:02 INFO     web_server_daemon                 Registering WebUI v1
2018-11-10 13:02 INFO     web_server                    Web interface available at http://172.17.0.4:5050
2018-11-10 13:03 WARNING  imdb_lookup   mov_xbytes task IMDB lookup failed for [MicroHD] Persecucion al limite (estreno 2018)(2016/MHD/1080P/AC3 5.1/DUAL/SUB) [SEEDERS (29)/LEECHERS (2)]
2018-11-10 13:03 INFO     imdb_lookup   mov_xbytes task Title `[microhd] persecucion al limite (estreno 2018)(2016/mhd/1080p/ac3 5.1/dual/sub) [seeders (29)/leechers (2)]` lookup failed
2018-11-10 13:03 CRITICAL task          mov_xbytes task BUG: Unhandled error in plugin list_match: (sqlite3.InterfaceError) Error binding parameter 2 - probably unsupported type. [SQL: u'SELECT movie_list_movies.id AS movie_list_movies_id, movie_list_movies.added AS movie_list_movies_added, movie_list_movies.title AS movie_list_movies_title, movie_list_movies.year AS movie_list_movies_year, movie_list_movies.list_id AS movie_list_movies_list_id \nFROM movie_list_movies \nWHERE ? = movie_list_movies.list_id AND lower(movie_list_movies.title) = ? AND movie_list_movies.year = ?\n LIMIT ? OFFSET ?'] [parameters: (3, u'persecucion al limite', [2018, 2016], 1, 0)] (Background on this error at: http://sqlalche.me/e/rvf5)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/flexget/task.py", line 486, in __run_plugin
return method(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/flexget/event.py", line 23, in __call__
return self.func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/flexget/plugins/filter/list_match.py", line 41, in on_task_filter
result = thelist.get(entry)
File "/usr/lib/python2.7/site-packages/flexget/utils/database.py", line 34, in wrapper
return func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/flexget/plugins/list/movie_list.py", line 228, in get
match = self._find_entry(entry=entry, session=session)
File "/usr/lib/python2.7/site-packages/flexget/utils/database.py", line 31, in wrapper
return func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/flexget/plugins/list/movie_list.py", line 202, in _find_entry
.filter(MovieListMovie.year == year).first())
File "/usr/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2789, in first
ret = list(self[0:1])
File "/usr/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2581, in __getitem__
return list(res)
File "/usr/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2889, in __iter__
return self._execute_and_instances(context)
File "/usr/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2912, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/usr/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/usr/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
cursor.execute(statement, parameters)
InterfaceError: (sqlite3.InterfaceError) Error binding parameter 2 - probably unsupported type. [SQL: u'SELECT movie_list_movies.id AS movie_list_movies_id, movie_list_movies.added AS movie_list_movies_added, movie_list_movies.title AS movie_list_movies_title, movie_list_movies.year AS movie_list_movies_year, movie_list_movies.list_id AS movie_list_movies_list_id \nFROM movie_list_movies \nWHERE ? = movie_list_movies.list_id AND lower(movie_list_movies.title) = ? AND movie_list_movies.year = ?\n LIMIT ? OFFSET ?'] [parameters: (3, u'persecucion al limite', [2018, 2016], 1, 0)] (Background on this error at: http://sqlalche.me/e/rvf5)

# Fixed code
def _guessit_options(options):
    settings = {
        "name_only": True,
        "allowed_languages": ["en", "fr"],
        "allowed_countries": ["us", "uk", "gb"],
        "single_value": True,
    }
    options["episode_prefer_number"] = not options.get("identified_by") == "ep"
    if options.get("allow_groups"):
        options["expected_group"] = options["allow_groups"]
    if "date_yearfirst" in options:
        options["date_year_first"] = options["date_yearfirst"]
    if "date_dayfirst" in options:
        options["date_day_first"] = options["date_dayfirst"]
    else:
        # See https://github.com/guessit-io/guessit/issues/329
        # https://github.com/guessit-io/guessit/pull/333
        # They made changes that break backward compatibility, so we have to make do this hackery
        if options.get("date_year_first"):
            options["date_day_first"] = True
    settings.update(options)
    return settings