# Buggy code
def _parse_date(self, date_text):
    date_match = date_regex.search(date_text)
    days_ago_match = days_ago_regex.search(date_text)
    first_word = date_text.split(" ")[0].lower().strip()

    if date_match:
        day = int(date_match.group(1))
        month = months.index(date_match.group(2)) + 1

        year = date_match.group(3)
        if year is None:
            year = date.today().year
        else:
            year = int(year)

        return date(year, month, day)
    elif days_ago_match:
        days_ago = int(days_ago_match.group(1))
        return date.today() - timedelta(days=days_ago)
    elif first_word in ["vandaag", "vanochtend", "vanmiddag", "vanavond"]:
        return date.today()
    elif first_word == "gisteren":
        return date.today() - timedelta(days=1)
    elif first_word == "eergisteren":
        return date.today() - timedelta(days=2)
    elif first_word == "kijk":
        return None
    else:
        log.error("Cannot understand date '%s'", date_text)
        return date.today()


# Traceback (ValueError)
2016-12-25 22:53 CRITICAL task          NPO series      BUG: Unhandled error in plugin npo_watchlist: u'min' is not in list
2016-12-25 22:53 CRITICAL manager       NPO series      An unexpected crash has occurred. Writing crash report to /home/pi/.flexget/crash_report.2016.12.25.225356276310.log. Please verify you are running the latest version of flexget by using "flexget -V" from CLI or by using version_checker plugin at http://flexget.com/wiki/Plugins/version_checker. You are currently using version 2.8.11
2016-12-25 22:53 WARNING  task          NPO series      Aborting task (plugin: npo_watchlist)
2016-12-25 22:55 INFO     search_npo    NPO series      Retrieving npo.nl episode watchlist for maxdaniel98@gmail.com
2016-12-25 22:55 CRITICAL task          NPO series      BUG: Unhandled error in plugin npo_watchlist: u'min' is not in list
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flexget/task.py", line 483, in __run_plugin
return method(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/event.py", line 23, in __call__
return self.func(*args, **kwargs)
File "/home/pi/.flexget/plugins/input/npo_watchlist.py", line 317, in on_task_input
entries = self._get_watchlist_entries(task, config)
File "/home/pi/.flexget/plugins/input/npo_watchlist.py", line 148, in _get_watchlist_entries
entry_date = self._parse_date(listItem.find('span', class_='global__content-info').text)
File "/home/pi/.flexget/plugins/input/npo_watchlist.py", line 81, in _parse_date
month = months.index(date_match.group(2)) + 1
ValueError: u'min' is not in list

# Fixed code
def _parse_date(self, date_text):
    date_match = date_regex.search(date_text)
    days_ago_match = days_ago_regex.search(date_text)
    first_word = date_text.split(" ")[0].lower().strip()

    if first_word in ["vandaag", "vanochtend", "vanmiddag", "vanavond"]:
        return date.today()
    elif first_word == "gisteren":
        return date.today() - timedelta(days=1)
    elif first_word == "eergisteren":
        return date.today() - timedelta(days=2)
    elif first_word == "kijk":
        return None
    elif date_match:
        day = int(date_match.group(1))
        month = months.index(date_match.group(2)) + 1
        year = date_match.group(3)
        if year is None:
            year = date.today().year
        else:
            year = int(year)
        return date(year, month, day)
    elif days_ago_match:
        days_ago = int(days_ago_match.group(1))
        return date.today() - timedelta(days=days_ago)
    else:
        log.error("Cannot understand date '%s'", date_text)
        return date.today()