+++ /dev/null
-# http://effbot.org/zone/bencode.htm
-# http://effbot.org/zone/copyright.htm
-#
-# Copyright (C) 1995-2013 by Fredrik Lundh
-#
-# By obtaining, using, and/or copying this software and/or its associated
-# documentation, you agree that you have read, understood, and will comply with
-# the following terms and conditions:
-#
-# Permission to use, copy, modify, and distribute this software and its
-# associated documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appears in all copies, and that both
-# that copyright notice and this permission notice appear in supporting
-# documentation, and that the name of Secret Labs AB or the author not be used
-# in advertising or publicity pertaining to distribution of the software
-# without specific, written prior permission.
-#
-# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
-# NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-# PERFORMANCE OF THIS SOFTWARE.
-
-from functools import partial
-import re
-
-
-def tokenize(text, match=re.compile(b"([idel])|(\\d+):|(-?\\d+)").match):
- i = 0
- while i < len(text):
- m = match(text, i)
- s = m.group(m.lastindex)
- i = m.end()
- if m.lastindex == 2:
- yield "s"
- yield text[i:i+int(s)]
- i = i + int(s)
- else:
- yield s.decode('ascii')
-
-
-def decode_item(next_, token):
- if token == "i":
- # integer: "i" value "e"
- data = int(next_())
- if next_() != "e":
- raise ValueError
- elif token == "s":
- # string: "s" value (virtual tokens)
- data = next_()
- elif token == "l" or token == "d":
- # container: "l" (or "d") values "e"
- data = []
- tok = next_()
- while tok != "e":
- data.append(decode_item(next_, tok))
- try:
- tok = next_()
- except StopIteration:
- break
- if token == "d":
- data = dict(zip(data[0::2], data[1::2]))
- else:
- raise ValueError
- return data
-
-
-def decode(text):
- try:
- src = tokenize(text)
- data = decode_item(partial(next, src), next(src))
- for token in src: # look for more tokens
- raise SyntaxError("trailing junk")
- except (AttributeError, ValueError, StopIteration):
- raise SyntaxError("syntax error")
- return data
"""Torrent Virtual FileSystem for Midnight Commander
The script requires Midnight Commander 3.1+
-(http://www.midnight-commander.org/), Python 2.4+ (http://www.python.org/),
-module eff_bdecode.py (http://effbot.org/zone/bencode.htm).
+(http://www.midnight-commander.org/), Python 2.7+ (http://www.python.org/),
+module eff_bdecode.py (from effbot.org/zone/bencode.htm) is now included
+in the code.
For mc 4.7+ just put the script in $HOME/[.local/share/].mc/extfs.d.
For older versions put it in /usr/[local/][lib|share]/mc/extfs
"""
-__version__ = "1.3.1"
+__version__ = "1.4.0"
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2010-2023 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2010-2025 PhiloSoft Design"
__license__ = "GPL"
from os.path import dirname, getmtime
import sys
from time import localtime, asctime
-from eff_bdecode import decode
try:
import locale
def output(s):
sys.stdout.write(s + '\n')
+# ---------- eff_bdecode.py ----------
+# effbot.org/zone/bencode.htm
+#
+# Copyright (C) 1995-2013 by Fredrik Lundh
+#
+# By obtaining, using, and/or copying this software and/or its associated
+# documentation, you agree that you have read, understood, and will comply with
+# the following terms and conditions:
+#
+# Permission to use, copy, modify, and distribute this software and its
+# associated documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appears in all copies, and that both
+# that copyright notice and this permission notice appear in supporting
+# documentation, and that the name of Secret Labs AB or the author not be used
+# in advertising or publicity pertaining to distribution of the software
+# without specific, written prior permission.
+#
+# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
+# NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR ANY SPECIAL,
+# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+from functools import partial
+import re
+
+
+def tokenize(text, match=re.compile(b"([idel])|(\\d+):|(-?\\d+)").match):
+ i = 0
+ while i < len(text):
+ m = match(text, i)
+ s = m.group(m.lastindex)
+ i = m.end()
+ if m.lastindex == 2:
+ yield "s"
+ yield text[i:i+int(s)]
+ i = i + int(s)
+ else:
+ yield s.decode('ascii')
+
+
+def decode_item(next_, token):
+ if token == "i":
+ # integer: "i" value "e"
+ data = int(next_())
+ if next_() != "e":
+ raise ValueError
+ elif token == "s":
+ # string: "s" value (virtual tokens)
+ data = next_()
+ elif token == "l" or token == "d":
+ # container: "l" (or "d") values "e"
+ data = []
+ tok = next_()
+ while tok != "e":
+ data.append(decode_item(next_, tok))
+ try:
+ tok = next_()
+ except StopIteration:
+ break
+ if token == "d":
+ data = dict(zip(data[0::2], data[1::2]))
+ else:
+ raise ValueError
+ return data
+
+
+def eff_bdecode(text):
+ try:
+ src = tokenize(text)
+ data = decode_item(partial(next, src), next(src))
+ for token in src: # look for more tokens
+ raise SyntaxError("trailing junk")
+ except (AttributeError, ValueError, StopIteration):
+ raise SyntaxError("syntax error")
+ return data
+# ---------- /eff_bdecode.py ----------
+
def mctorrent_list():
"""List the entire VFS"""
torrent_file = open(sys.argv[2], 'rb')
data = torrent_file.read()
torrent_file.close()
- torrent = decode(data)
+ torrent = eff_bdecode(data)
except IOError as error_str:
torrent_error(error_str)
WHAT'S NEW
-Version 1.2.4 (2018-05-18)
- Fix a bug in handling overflow with dates > 2038 year.
-Version 1.2.3 (2015-07-08)
- Set directories/files date/time to the content of ".META/creation date" file
-if it exists or to the last modification time of the torrent file itself.
+Version 1.4.0 (2025-01-11)
-Version 1.2.2 (2015-01-10)
- Changed link to installation instructions.
-
-Version 1.2.1 (2013-11-20)
- Fixed a minor bug.
-
-Version 1.2.0 (2013-11-16)
- Get charset from the environment.
-
-Version 1.1.1 (2013-11-11)
- Documented the fact that the script can be put in
-$HOME/[.local/share/].mc/extfs.d.
-
-Version 1.1.0 (2013-06-10)
- Show DHT nodes if they are present.
- Show publisher and publisher-url if they are available.
- Use name.utf-8, path.utf-8 and comment.utf-8 if those are available.
- Use codepage instead of encoding if codepage is available
- and encoding is not.
-
-Version 1.0.0 (2010-11-11)
- Initial release.
+ Include eff_bdecode.py into the code.
WHERE TO GET
Oleg Broytman <phd@phdru.name>
COPYRIGHT
- Copyright (C) 2010-2015 PhiloSoft Design
+ Copyright (C) 2010-2025 PhiloSoft Design
LICENSE
GPL
Олег Бройтман <phd@phdru.name>
COPYRIGHT
- Copyright (C) 2010-2015 PhiloSoft Design
+ Copyright (C) 2010-2025 PhiloSoft Design
ЛИЦЕНЗИЯ
GPL
+Version 1.4.0 (2025-01-11)
+
+ Include eff_bdecode.py into the code.
+
Version 1.3.1 (2023-08-13)
Update for Python 3.