JohnDoee / autotorrent

Matches torrents with files and gets them seeded
MIT License
269 stars 34 forks source link

Fixed some unicode parsing bugs. #16

Closed philspins closed 4 years ago

philspins commented 6 years ago

I ran into problems when importing some foreign music torrents, so I did a bit of debugging and was able fixe the issues by adding some ".encode('utf-8')" commands.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.1%) to 78.473% when pulling 4fd0fb7a31363bc2c12652e5b6ae7efd13c271cd on philspins:develop into 9f6a250dce6f6927b85b214c390b1dca37cc32bb on JohnDoee:develop.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.1%) to 78.473% when pulling 4fd0fb7a31363bc2c12652e5b6ae7efd13c271cd on philspins:develop into 9f6a250dce6f6927b85b214c390b1dca37cc32bb on JohnDoee:develop.

JohnDoee commented 6 years ago

So, one of the big problems with encoding stuff in autotorrent is that it's both Python 2 and 3 compatible. The way you've solved the issues you've hit broke Python 3 support but that should be fixable though.

Can you include a testcase or two that this pull-request fixes for you ? That's the easiest way to see if it's a python 2 issue only.

philspins commented 6 years ago

I tried writing some test cases but honestly I'm lost as to how to write them.

I'm trying to write a case for a torrent that includes a file called "file-エンドレス.txt" but I can't get shutil to copy it...

        f = u'file-\xe3\x82\xa8\xe3\x83\xb3\xe3\x83\x89\xe3\x83\xac\xe3\x82\xb9.txt'
        src = os.path.join(dirname, f)
        dst = os.path.join(self.src, f)

        shutil.copy(src.decode('utf-8'), dst.decode('utf-8'))
JohnDoee commented 4 years ago

Thanks for trying to fix this, I did try your solution originally but it is all related to varying encoding when it comes to Python 2. I've folded all this into #45 and will try to solve it.