Skip to content

Use name.utf-8 and path.utf-8 when present#2076

Merged
cvium merged 1 commit intoFlexget:developfrom
sarbian:utf-8_tags
Feb 5, 2018
Merged

Use name.utf-8 and path.utf-8 when present#2076
cvium merged 1 commit intoFlexget:developfrom
sarbian:utf-8_tags

Conversation

@sarbian
Copy link
Copy Markdown
Contributor

@sarbian sarbian commented Feb 3, 2018

Motivation for changes:

I had some crash in bittorent.py when handling torrents that included a directory using Chinese chars.
Looking at others torrent python code (deluge) I see that they use the dictionary keys name.utf-8/path.utf-8 instead of name/path when present.
In the torrent that crashed those keys are present and contains proper utf-8 while path/name contains some bytes that are not UTF-8

Detailed changes:

  • ins bittorent.py get_filelist check if the name.utf-8/path.utf-8 keys are present and use them if they are.

Addressed issues:

name = self.content['info']['name.utf-8']
else:
name = self.content['info']['name']
t = {'name': name,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer 'name': self.content['info'].get('name.utf-8') or self.content['info']['name'] or 'name': self.content['info'].get('name.utf-8', self.content['info']['name']), but that's purely a stylistic preference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My python is limited 😄 it does indeed look cleaner

@cvium cvium merged commit 77c81f5 into Flexget:develop Feb 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants