diff options
Diffstat (limited to 'libmat')
| -rw-r--r-- | libmat/misc.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libmat/misc.py b/libmat/misc.py index cc480e5..e5db06d 100644 --- a/libmat/misc.py +++ b/libmat/misc.py | |||
| @@ -54,8 +54,10 @@ class TorrentStripper(parser.GenericParser): | |||
| 54 | """ Remove recursively all compromizing fields | 54 | """ Remove recursively all compromizing fields |
| 55 | """ | 55 | """ |
| 56 | d = dict() | 56 | d = dict() |
| 57 | for i, j in [i for i in list(dictionary.items()) if i in self.fields]: | 57 | for i, j in list(dictionary.items()): |
| 58 | if isinstance(j, dict): | 58 | if not i in self.fields: |
| 59 | continue | ||
| 60 | elif isinstance(j, dict): | ||
| 59 | d = dict(list(d.items()) + list(self.__get_meta_recursively(j).items())) | 61 | d = dict(list(d.items()) + list(self.__get_meta_recursively(j).items())) |
| 60 | else: | 62 | else: |
| 61 | d[i] = j | 63 | d[i] = j |
| @@ -67,7 +69,7 @@ class TorrentStripper(parser.GenericParser): | |||
| 67 | with open(self.filename, 'r') as f: | 69 | with open(self.filename, 'r') as f: |
| 68 | decoded = bencode.bdecode(f.read()) | 70 | decoded = bencode.bdecode(f.read()) |
| 69 | 71 | ||
| 70 | cleaned = {i: j for i, j in list(decoded.items()) if i in self.fields} | 72 | cleaned = self.__remove_all_recursively(decoded) |
| 71 | 73 | ||
| 72 | with open(self.output, 'w') as f: # encode the decoded torrent | 74 | with open(self.output, 'w') as f: # encode the decoded torrent |
| 73 | f.write(bencode.bencode(cleaned)) # and write it in self.output | 75 | f.write(bencode.bencode(cleaned)) # and write it in self.output |
