Use comment.utf-8 if available
authorOleg Broytman <phd@phdru.name>
Sun, 9 Jun 2013 22:30:50 +0000 (22:30 +0000)
committerOleg Broytman <phd@phdru.name>
Sun, 9 Jun 2013 22:30:50 +0000 (22:30 +0000)
git-svn-id: file:///home/phd/archive/SVN/mc-extfs/trunk@62 1a6e6372-1aea-0310-bd00-dc960550e1df

torrent

diff --git a/torrent b/torrent
index 769d90c..cfc1caa 100755 (executable)
--- a/torrent
+++ b/torrent
@@ -124,7 +124,10 @@ def mctorrent_list():
     meta = []
     for name in 'announce', 'announce-list', 'codepage', 'comment', \
                 'created by', 'creation date', 'encoding':
-        if name in torrent:
+        if name == 'comment' and 'comment.utf-8' in torrent:
+            data = torrent['comment.utf-8'].decode('utf-8').encode(charset, 'replace')
+            meta.append(('.META/' + name, len(data)))
+        elif name in torrent:
             if name == 'announce-list':
                 data = decode_announce_list(torrent[name])
             elif name == 'codepage':
@@ -154,7 +157,10 @@ def mctorrent_copyout():
 
     for name in 'announce', 'announce-list', 'codepage', 'comment', \
                 'created by', 'creation date', 'encoding':
-        if torrent_filename == '.META/' + name:
+        if name == 'comment' and 'comment.utf-8' in torrent:
+            data = torrent['comment.utf-8'].decode('utf-8').encode(charset, 'replace')
+            meta.append(('.META/' + name, len(data)))
+        elif torrent_filename == '.META/' + name:
             if name in torrent:
                 if name == 'announce-list':
                     data = decode_announce_list(torrent[name])