"""
-__version__ = "1.1.0"
+__version__ = "1.1.1"
__author__ = "Oleg Broytman <phd@phdru.name>"
__copyright__ = "Copyright (C) 2010-2013 PhiloSoft Design"
__license__ = "GPL"
Author: %s
%s
-This is not a program. Put the script in /usr/[local/][lib|share]/mc/extfs.
-For more information read the source!""",
+This is not a program. Put the script in $HOME/.mc/extfs.d or
+/usr/[local/][lib|share]/mc/extfs. For more information read the source!""",
__version__, __author__, __copyright__
)
sys.exit(1)
torrent_error('Info absent')
info = torrent['info']
- if 'name' not in info or 'name.utf-8' not in info:
+ if 'name' not in info and 'name.utf-8' not in info:
torrent_error('Unknown name')
codepage = torrent.get('codepage', None)
files = info['files']
paths = []
for file in files:
- if 'path' not in file or 'path.utf-8' not in file:
+ if 'path' not in file and 'path.utf-8' not in file:
torrent_error('Unknown path')
if 'length' not in file:
torrent_error('Unknown length')
meta = []
for name in 'announce', 'announce-list', 'codepage', 'comment', \
- 'created by', 'creation date', 'encoding':
- if name in torrent:
+ 'created by', 'creation date', 'encoding', \
+ 'nodes', 'publisher', 'publisher-url':
+ 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_list(torrent[name])
+ data = decode_announce_list(torrent[name])
elif name == 'codepage':
data = str(torrent[name])
elif name == 'creation date':
data = decode_datetime(torrent[name])
+ elif name == 'nodes':
+ data = ['%s:%s' % (host, port) for host, port in torrent[name]]
+ data = '\n'.join(data)
else:
data = torrent[name]
meta.append(('.META/' + name, len(data)))
data = None
for name in 'announce', 'announce-list', 'codepage', 'comment', \
- 'created by', 'creation date', 'encoding':
- if torrent_filename == '.META/' + name:
+ 'created by', 'creation date', 'encoding', \
+ 'nodes', 'publisher', 'publisher-url':
+ 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_list(torrent[name])
+ data = decode_announce_list(torrent[name])
elif name == 'codepage':
data = str(torrent[name])
elif name == 'creation date':
data = decode_datetime(torrent[name])
+ elif name == 'nodes':
+ data = ['%s:%s' % (host, port) for host, port in torrent[name]]
+ data = '\n'.join(data)
else:
data = str(torrent[name])
else:
l_now = localtime(the_time)
return asctime(l_now)
-def decode_list(announce):
+def decode_announce_list(announce):
return '\n'.join(l[0] for l in announce)