# -*- coding: cp936 -*-
############################################################
# convert mldonkey's chinese
# Version: 0.1
# Author: kongxx
# Email: kongxxcn@yahoo.com.cn
############################################################
import os ,sys ,string ,urllib ,telnetlib ,operator
# define the mldonkey incoming dir
sdir='/usr/local/mldonkey/incoming/'
#flag the num
sNum='0123456789'
#length
len8 = 8
len12 = 12
lengths = [len8 ,len12]
def convert():
filenames=os.listdir(sdir)
for filename in filenames :
for length in lengths :
s1 = filename
s2 = convertName(filename ,length)
try :
if s1 != s2 :
print '############################################################'
print 'The source name is:' + s1
print 'The target name is:' + s2
print ''
confirm = raw_input('Do you confirm rename the file[yes or no]? ')
if confirm == 'yes' :
os.rename(sdir + s1 ,sdir + s2)
break
except UnicodeDecodeError:
print ''
# convert ths file name
# param s the filename
# param length
def convertName(s ,length) :
location = 0
ret = ''
if length not in lengths:
return s
while True :
if location + length <= len(s) :
subStr = s[location:location + length]
if check(subStr) :
if length == len8 :
ret += "%" + hex((int)(subStr[1:4]))[2:4] + "%" + hex((int)(subStr[5:8]))[2:4]
if length == len12 :
ret += "%" + hex((int)(subStr[1:4]))[2:4] + "%" + hex((int)(subStr[5:8]))[2:4] + "%" + hex((int)(subStr[9:12]))[2:4]
location = location + length
else :
ret += s[location :location + 1]
location = location + 1
else :
ret += s[location:]
break
ret = urllib.unquote(ret)
if ret == s : return s
try :
if length == len8 :
return ret.decode('GBK')
if length == len12 :
return ret.decode('UTF-8')
except UnicodeDecodeError:
return ret
def check(s):
if len(s) != len8 and len(s) != len12:
return False
if s[0] != '_' or s[4] != '_' :
return False
if len(s) == len12 and s[8] != '_':
return False
s = s.replace('_','')
for c in s :
if (c not in sNum) :return False
return True
convert()
|
相关推荐
mldonkey-2.9.0p2p文件传输工具
MLDonkey下载软件.pdf
MLDonkey是一款性能强劲的P2P客户端和服务器端软件。它最著名的特点是没有界面和支持各种不同的P2P协议。 为什么没有界面是优点呢?这意味着MLDonkey可以在系统启动的时候启动并且在后台运行。如果你想给它一些指示...
mldonkey 3.06所需的库文件. freetype2-2.4.4.tbz png-1.4.5.tbz jpeg-8_3.tbz gd-2.0.35_7,1.tbz config-0.25_1.tbz expat-2.0.1_1.tbz fontconfig-2.8.0,1.tbz libiconv-1.13.1_1.tbz
控制MLDONKEY上传下载必备,非常好用,安卓电子市场提取
安装mldonkey需要的dat文件之一,另一个是nodes.dat
linux下的超级电驴,支持ftp,http,BT等
使用方法,使用sancho,打开后进入Console模式,把文件拷贝过去,然后输入 servers /路径/server.met
mldonkey_protocol_handler-2.5.xpimldonkey_protocol_handler-2.5.xpimldonkey_protocol_handler-2.5.xpi
mldonkey h608b 电信猫 脱机下载
mldonkey nodes.dat~~~
mldonkey需要的nodes.dat
mldonkey-3.1.3.static.i386.Windows 命令行的,可以下载一个界面工具配合使用,推荐sancho
MLdonkey_与_sancho_的安装使用
使用方法,使用sancho,打开后进入Console模式,把文件拷贝过去,然后输入 kad_load /路径/nodes.dat
mldonkey_telnet
mldonkey_www
解压后,进入解压文件夹打开终端,运行./mlnet 电驴就安装好了,如果你还要前端的话,我这还有sancho09458linuxgtk.sh