divijbindlish / parse-torrent-name

Extract media information from a filename
MIT License
215 stars 60 forks source link

Torrent name caused PTN to crash. #1

Closed davidvuong closed 8 years ago

davidvuong commented 8 years ago

When testing parse-torrent-name, I noticed that when I try to parse:

PTN.parse('30 Rock S05e08[Mux - XviD - Ita Mp3][TntVillage]')

It gives the following error:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    PTN.parse('30 Rock S05e08[Mux - XviD - Ita Mp3][TntVillage]')
  File "/Users/davidvuong/Dropbox/workspace/parse-torrent-name/PTN/__init__.py", line 14, in parse
    return ptn.parse(name)
  File "/Users/davidvuong/Dropbox/workspace/parse-torrent-name/PTN/parse.py", line 88, in parse
    match[index['raw']], '{episode}', self.torrent['name']
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 251, in _compile
    raise error, v # invalid expression
sre_constants.error: unexpected end of regular expression

I've fixed it by simply wrapping match[index['raw']] inside the _escape_regex method you had written. Other changes were just syntax related.

divijbindlish commented 8 years ago

Thanks for the fix as well as the syntax changes.

One thing I realized was that the test cases would always mess up due to episodeName, group and excess fields by simply using the _escape_regex function at multiple places. So I have removed them for now (from the testcases) and I plan on adding them later.