# Buggy code
def to_parse_result(self, name, guess):
    """Guess the episode information from a given release name.

    Uses guessit and returns a dictionary with keys and values according to ParseResult
    :param name:
    :type name: str
    :param guess:
    :type guess: dict
    :return:
    :rtype: ParseResult
    """
    season_numbers = helpers.ensure_list(guess.get("season"))
    if len(season_numbers) > 1 and not self.allow_multi_season:
        raise InvalidNameException(
            "Discarding result. Multi-season detected for '{name}': {guess}".format(
                name=name, guess=guess
            )
        )

    return ParseResult(
        guess,
        original_name=name,
        series_name=guess.get("alias") or guess.get("title"),
        season_number=helpers.single_or_list(season_numbers, self.allow_multi_season),
        episode_numbers=helpers.ensure_list(guess.get("episode"))
        if guess.get("episode") != guess.get("absolute_episode")
        else [],
        ab_episode_numbers=helpers.ensure_list(guess.get("absolute_episode")),
        air_date=guess.get("date"),
        release_group=guess.get("release_group"),
        proper_tags=helpers.ensure_list(guess.get("proper_tag")),
        version=guess.get("version", -1),
    )


# Traceback (TypeError)
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: The.Walking.Dead.S08E06.VOSTFR.1080p.WEB-DL.DD5.1.H264-ARK01.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Skipping already processed file: The.Walking.Dead.S08E06.VOSTFR.1080p.WEB-DL.DD5.1.H264-ARK01.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Outlander.S03E11.MULTi.1080p.WEB.x264-CiELOS.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Skipping already processed file: Outlander.S03E11.MULTi.1080p.WEB.x264-CiELOS.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Shameless.US.S08E04.VOSTFR.1080p.WEB.H264-SCTE.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Skipping already processed file: Shameless.US.S08E04.VOSTFR.1080p.WEB.H264-SCTE.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Vikings.S05E01-E02.FASTSUB.VOSTFR.720p.HDTV.x264-ZT.WwW.Torrent9.tv.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Skipping already processed file: Vikings.S05E01-E02.FASTSUB.VOSTFR.720p.HDTV.x264-ZT.WwW.Torrent9.tv.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Shameless.US.S08E05.PROPER.VOSTFR.1080p.AMZN.WEB-DL.DDP5.1.H.264-Pastaga.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Skipping already processed file: Shameless.US.S08E05.PROPER.VOSTFR.1080p.AMZN.WEB-DL.DDP5.1.H.264-Pastaga.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Mr.Robot.S03E08.SUBFRENCH.720p.WEB-DL.H264-EXTREME.WwW.Torrent9.tv.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Skipping already processed file: Mr.Robot.S03E08.SUBFRENCH.720p.WEB-DL.H264-EXTREME.WwW.Torrent9.tv.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: The.Walking.Dead.S08E07.VOSTFR.720p.HDTV.x264-WEEDS.WwW.Torrent9.tv.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Skipping already processed file: The.Walking.Dead.S08E07.VOSTFR.720p.HDTV.x264-WEEDS.WwW.Torrent9.tv.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Mr.Robot.S03E09.FASTSUB.VOSTFR.720p.WEB.H264-ZT.WwW.Torrent9.tv.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Skipping already processed file: Mr.Robot.S03E09.FASTSUB.VOSTFR.720p.WEB.H264-ZT.WwW.Torrent9.tv.mkv
2017-12-11 21:30:45 INFO     Thread-17 :: [1a8dc66] Processing /media/NAS/Series/Telechargements/Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Analyzing name: Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Using cached parse result for Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Show information parsed from file name
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Retrieving episode object for Food Wars!: Shokugeki no Soma S03E01
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] The episode file has a quality in it, using that: 720p WEB-DL
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Quality of the episode we are processing: 720p WEB-DL
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Snatch in history: False
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Manually snatched: False
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Current quality: 720p WEB-DL
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] New quality: 720p WEB-DL
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] Proper: False
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] This episode is a priority download: False
2017-12-11 21:30:45 INFO     Thread-17 :: [1a8dc66] New file: /media/NAS/Series/Telechargements/Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv
2017-12-11 21:30:45 INFO     Thread-17 :: [1a8dc66] New size: 329.74 MB
2017-12-11 21:30:45 DEBUG    Thread-17 :: [1a8dc66] There is no existing file so there's no worries about replacing it
2017-12-11 21:30:45 ERROR    Thread-17 :: [1a8dc66] Exception generated: int() argument must be a string or a number, not 'NoneType'
Traceback (most recent call last):
  File "/home/**********/medusa/medusa/server/web/core/base.py", line 263, in async_call
    result = function(**kwargs)
  File "/home/**********/medusa/medusa/server/web/home/post_process.py", line 50, in processEpisode
    ignore_subs=argToBool(ignore_subs)
  File "/home/**********/medusa/medusa/process_tv.py", line 146, in process
    ignore_subs=ignore_subs)
  File "/home/**********/medusa/medusa/process_tv.py", line 335, in process_files
    self.process_media(path, self.video_files, force, is_priority, ignore_subs)
  File "/home/**********/medusa/medusa/process_tv.py", line 536, in process_media
    self.result = processor.process()
  File "/home/**********/medusa/medusa/post_processor.py", line 1068, in process
    if int(ep_obj.season) > int(max_season[0][0]):
TypeError: int() argument must be a string or a number, not 'NoneType'
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Processing path: /media/NAS/Series/Telechargements
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Processing folder: /media/NAS/Series/Telechargements
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Post-processing files: [u'House.Of.Cards.S03E13.FINAL.FRENCH.WEBRIP.XviD-ZT.avi', u'.DS_Store', u'mr.robot.s03e07.subfrench.720p.web.h264-cielos.WwW.Torrent9.tv.mkv', u'The.Walking.Dead.S08E06.VOSTFR.1080p.WEB-DL.DD5.1.H264-ARK01.mkv', u'Outlander.S03E11.MULTi.1080p.WEB.x264-CiELOS.mkv', u'Shameless.US.S08E04.VOSTFR.1080p.WEB.H264-SCTE.mkv', u'Vikings.S05E01-E02.FASTSUB.VOSTFR.720p.HDTV.x264-ZT.WwW.Torrent9.tv.mkv', u'Shameless.US.S08E05.PROPER.VOSTFR.1080p.AMZN.WEB-DL.DDP5.1.H.264-Pastaga.mkv', u'Mr.Robot.S03E08.SUBFRENCH.720p.WEB-DL.H264-EXTREME.WwW.Torrent9.tv.mkv', u'The.Walking.Dead.S08E07.VOSTFR.720p.HDTV.x264-WEEDS.WwW.Torrent9.tv.mkv', u'Mr.Robot.S03E09.FASTSUB.VOSTFR.720p.WEB.H264-ZT.WwW.Torrent9.tv.mkv', u'Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv', u'Shokugeki.no.Soma S03E03.SUBFRENCH.720p.WEBRip.x264-BSD.mkv', u'Shokugeki.no.Soma.San.no.Sara.S03E02.SUBFRENCH.720p.WEBRip.x264-BSD.mkv', u'Shokugeki.no.Soma.San.no.Sara.S03E04.SUBFRENCH.720p.WEBRip.x264-BSD.mkv']
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Post-processing video files: [u'House.Of.Cards.S03E13.FINAL.FRENCH.WEBRIP.XviD-ZT.avi', u'mr.robot.s03e07.subfrench.720p.web.h264-cielos.WwW.Torrent9.tv.mkv', u'The.Walking.Dead.S08E06.VOSTFR.1080p.WEB-DL.DD5.1.H264-ARK01.mkv', u'Outlander.S03E11.MULTi.1080p.WEB.x264-CiELOS.mkv', u'Shameless.US.S08E04.VOSTFR.1080p.WEB.H264-SCTE.mkv', u'Vikings.S05E01-E02.FASTSUB.VOSTFR.720p.HDTV.x264-ZT.WwW.Torrent9.tv.mkv', u'Shameless.US.S08E05.PROPER.VOSTFR.1080p.AMZN.WEB-DL.DDP5.1.H.264-Pastaga.mkv', u'Mr.Robot.S03E08.SUBFRENCH.720p.WEB-DL.H264-EXTREME.WwW.Torrent9.tv.mkv', u'The.Walking.Dead.S08E07.VOSTFR.720p.HDTV.x264-WEEDS.WwW.Torrent9.tv.mkv', u'Mr.Robot.S03E09.FASTSUB.VOSTFR.720p.WEB.H264-ZT.WwW.Torrent9.tv.mkv', u'Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv', u'Shokugeki.no.Soma S03E03.SUBFRENCH.720p.WEBRip.x264-BSD.mkv', u'Shokugeki.no.Soma.San.no.Sara.S03E02.SUBFRENCH.720p.WEBRip.x264-BSD.mkv', u'Shokugeki.no.Soma.San.no.Sara.S03E04.SUBFRENCH.720p.WEBRip.x264-BSD.mkv']
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Found unwanted files: [u'.DS_Store']
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: House.Of.Cards.S03E13.FINAL.FRENCH.WEBRIP.XviD-ZT.avi
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: House.Of.Cards.S03E13.FINAL.FRENCH.WEBRIP.XviD-ZT.avi
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: mr.robot.s03e07.subfrench.720p.web.h264-cielos.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: mr.robot.s03e07.subfrench.720p.web.h264-cielos.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: The.Walking.Dead.S08E06.VOSTFR.1080p.WEB-DL.DD5.1.H264-ARK01.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: The.Walking.Dead.S08E06.VOSTFR.1080p.WEB-DL.DD5.1.H264-ARK01.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Outlander.S03E11.MULTi.1080p.WEB.x264-CiELOS.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: Outlander.S03E11.MULTi.1080p.WEB.x264-CiELOS.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Shameless.US.S08E04.VOSTFR.1080p.WEB.H264-SCTE.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: Shameless.US.S08E04.VOSTFR.1080p.WEB.H264-SCTE.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Vikings.S05E01-E02.FASTSUB.VOSTFR.720p.HDTV.x264-ZT.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: Vikings.S05E01-E02.FASTSUB.VOSTFR.720p.HDTV.x264-ZT.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Shameless.US.S08E05.PROPER.VOSTFR.1080p.AMZN.WEB-DL.DDP5.1.H.264-Pastaga.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: Shameless.US.S08E05.PROPER.VOSTFR.1080p.AMZN.WEB-DL.DDP5.1.H.264-Pastaga.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Mr.Robot.S03E08.SUBFRENCH.720p.WEB-DL.H264-EXTREME.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: Mr.Robot.S03E08.SUBFRENCH.720p.WEB-DL.H264-EXTREME.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: The.Walking.Dead.S08E07.VOSTFR.720p.HDTV.x264-WEEDS.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: The.Walking.Dead.S08E07.VOSTFR.720p.HDTV.x264-WEEDS.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] You're trying to post-process a file that has already been processed, skipping: Mr.Robot.S03E09.FASTSUB.VOSTFR.720p.WEB.H264-ZT.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Skipping already processed file: Mr.Robot.S03E09.FASTSUB.VOSTFR.720p.WEB.H264-ZT.WwW.Torrent9.tv.mkv
2017-12-11 21:30:50 INFO     Thread-19 :: [1a8dc66] Processing /media/NAS/Series/Telechargements/Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Analyzing name: Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Using cached parse result for Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Show information parsed from file name
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Retrieving episode object for Food Wars!: Shokugeki no Soma S03E01
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] The episode file has a quality in it, using that: 720p WEB-DL
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Quality of the episode we are processing: 720p WEB-DL
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Snatch in history: False
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Manually snatched: False
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Current quality: 720p WEB-DL
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] New quality: 720p WEB-DL
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] Proper: False
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] This episode is a priority download: False
2017-12-11 21:30:50 INFO     Thread-19 :: [1a8dc66] New file: /media/NAS/Series/Telechargements/Shokugeki.no.Soma S03E01.SUBFRENCH.720p.WEBRip.x264-BSD.mkv
2017-12-11 21:30:50 INFO     Thread-19 :: [1a8dc66] New size: 329.74 MB
2017-12-11 21:30:50 DEBUG    Thread-19 :: [1a8dc66] There is no existing file so there's no worries about replacing it
2017-12-11 21:30:50 ERROR    Thread-19 :: [1a8dc66] Exception generated: int() argument must be a string or a number, not 'NoneType'
Traceback (most recent call last):
  File "/home/**********/medusa/medusa/server/web/core/base.py", line 263, in async_call
    result = function(**kwargs)
  File "/home/**********/medusa/medusa/server/web/home/post_process.py", line 50, in processEpisode
    ignore_subs=argToBool(ignore_subs)
  File "/home/**********/medusa/medusa/process_tv.py", line 146, in process
    ignore_subs=ignore_subs)
  File "/home/**********/medusa/medusa/process_tv.py", line 335, in process_files
    self.process_media(path, self.video_files, force, is_priority, ignore_subs)
  File "/home/**********/medusa/medusa/process_tv.py", line 536, in process_media
    self.result = processor.process()
  File "/home/**********/medusa/medusa/post_processor.py", line 1068, in process
    if int(ep_obj.season) > int(max_season[0][0]):
TypeError: int() argument must be a string or a number, not 'NoneType'

# Fixed code
def to_parse_result(self, name, guess):
    """Guess the episode information from a given release name.

    Uses guessit and returns a dictionary with keys and values according to ParseResult
    :param name:
    :type name: str
    :param guess:
    :type guess: dict
    :return:
    :rtype: ParseResult
    """
    if not self.allow_multi_season:
        season_numbers = helpers.ensure_list(guess.get("season"))
        if len(season_numbers) > 1:
            raise InvalidNameException(
                "Discarding result. Multi-season detected for '{name}': {guess}".format(
                    name=name, guess=guess
                )
            )

        versions = helpers.ensure_list(guess.get("version"))
        if len(versions) > 1:
            raise InvalidNameException(
                "Discarding result. Multi-version detected for '{name}': {guess}".format(
                    name=name, guess=guess
                )
            )

    return ParseResult(
        guess,
        original_name=name,
        series_name=guess.get("alias") or guess.get("title"),
        season_number=helpers.single_or_list(season_numbers, self.allow_multi_season),
        episode_numbers=helpers.ensure_list(guess.get("episode"))
        if guess.get("episode") != guess.get("absolute_episode")
        else [],
        ab_episode_numbers=helpers.ensure_list(guess.get("absolute_episode")),
        air_date=guess.get("date"),
        release_group=guess.get("release_group"),
        proper_tags=helpers.ensure_list(guess.get("proper_tag")),
        version=guess.get("version", -1),
    )