mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-10 20:31:47 +00:00
Reformat python code to be compliant with PEP8
The following command is used: `pycodestyle --ignore=E265,E722 --max-line-length=100 <py files>`
This commit is contained in:
parent
bdc788c824
commit
bbe76231cf
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.41
|
#VERSION: 1.42
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
@ -29,25 +29,30 @@
|
|||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import re, htmlentitydefs
|
import gzip
|
||||||
import tempfile
|
import htmlentitydefs
|
||||||
import os
|
import os
|
||||||
import StringIO, gzip, urllib2
|
import re
|
||||||
import socket
|
import socket
|
||||||
import socks
|
import socks
|
||||||
import re
|
import StringIO
|
||||||
|
import tempfile
|
||||||
|
import urllib2
|
||||||
|
|
||||||
# Some sites blocks default python User-agent
|
# Some sites blocks default python User-agent
|
||||||
user_agent = 'Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Firefox/38.0'
|
user_agent = 'Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Firefox/38.0'
|
||||||
headers = {'User-Agent': user_agent}
|
headers = {'User-Agent': user_agent}
|
||||||
# SOCKS5 Proxy support
|
# SOCKS5 Proxy support
|
||||||
if os.environ.has_key("sock_proxy") and len(os.environ["sock_proxy"].strip()) > 0:
|
if ("sock_proxy" in os.environ) and (len(os.environ["sock_proxy"].strip()) > 0):
|
||||||
proxy_str = os.environ["sock_proxy"].strip()
|
proxy_str = os.environ["sock_proxy"].strip()
|
||||||
m=re.match(r"^(?:(?P<username>[^:]+):(?P<password>[^@]+)@)?(?P<host>[^:]+):(?P<port>\w+)$", proxy_str)
|
m = re.match(r"^(?:(?P<username>[^:]+):(?P<password>[^@]+)@)?(?P<host>[^:]+):(?P<port>\w+)$",
|
||||||
|
proxy_str)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, m.group('host'), int(m.group('port')), True, m.group('username'), m.group('password'))
|
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, m.group('host'),
|
||||||
|
int(m.group('port')), True, m.group('username'), m.group('password'))
|
||||||
socket.socket = socks.socksocket
|
socket.socket = socks.socksocket
|
||||||
|
|
||||||
|
|
||||||
def htmlentitydecode(s):
|
def htmlentitydecode(s):
|
||||||
# First convert alpha entities (such as é)
|
# First convert alpha entities (such as é)
|
||||||
# (Inspired from http://mail.python.org/pipermail/python-list/2007-June/443813.html)
|
# (Inspired from http://mail.python.org/pipermail/python-list/2007-June/443813.html)
|
||||||
@ -59,10 +64,11 @@ def htmlentitydecode(s):
|
|||||||
t = re.sub(u'&(%s);' % u'|'.join(htmlentitydefs.name2codepoint), entity2char, s)
|
t = re.sub(u'&(%s);' % u'|'.join(htmlentitydefs.name2codepoint), entity2char, s)
|
||||||
|
|
||||||
# Then convert numerical entities (such as é)
|
# Then convert numerical entities (such as é)
|
||||||
t = re.sub(u'&#(\d+);', lambda x: unichr(int(x.group(1))), t)
|
t = re.sub(r'&#(\d+);', lambda x: unichr(int(x.group(1))), t)
|
||||||
|
|
||||||
# Then convert hexa entities (such as é)
|
# Then convert hexa entities (such as é)
|
||||||
return re.sub(u'&#x(\w+);', lambda x: unichr(int(x.group(1),16)), t)
|
return re.sub(r'&#x(\w+);', lambda x: unichr(int(x.group(1), 16)), t)
|
||||||
|
|
||||||
|
|
||||||
def retrieve_url(url):
|
def retrieve_url(url):
|
||||||
""" Return the content of the url page as a string """
|
""" Return the content of the url page as a string """
|
||||||
@ -90,6 +96,7 @@ def retrieve_url(url):
|
|||||||
dat = htmlentitydecode(dat)
|
dat = htmlentitydecode(dat)
|
||||||
return dat
|
return dat
|
||||||
|
|
||||||
|
|
||||||
def download_file(url, referer=None):
|
def download_file(url, referer=None):
|
||||||
""" Download file at url and write it to a file, return the path to the file and the url """
|
""" Download file at url and write it to a file, return the path to the file and the url """
|
||||||
file, path = tempfile.mkstemp()
|
file, path = tempfile.mkstemp()
|
||||||
@ -112,4 +119,4 @@ def download_file(url, referer=None):
|
|||||||
file.write(dat)
|
file.write(dat)
|
||||||
file.close()
|
file.close()
|
||||||
# return file path
|
# return file path
|
||||||
return path+" "+url
|
return (path + " " + url)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.41
|
#VERSION: 1.42
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Fabien Devaux <fab AT gnux DOT info>
|
# Fabien Devaux <fab AT gnux DOT info>
|
||||||
@ -56,6 +56,7 @@ CATEGORIES = {'all', 'movies', 'tv', 'music', 'games', 'anime', 'software', 'pic
|
|||||||
# As a convention, try to list results by decreasing number of seeds or similar
|
# As a convention, try to list results by decreasing number of seeds or similar
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
def initialize_engines():
|
def initialize_engines():
|
||||||
""" Import available engines
|
""" Import available engines
|
||||||
|
|
||||||
@ -81,6 +82,7 @@ def initialize_engines():
|
|||||||
|
|
||||||
return supported_engines
|
return supported_engines
|
||||||
|
|
||||||
|
|
||||||
def engines_to_xml(supported_engines):
|
def engines_to_xml(supported_engines):
|
||||||
""" Generates xml for supported engines """
|
""" Generates xml for supported engines """
|
||||||
tab = " " * 4
|
tab = " " * 4
|
||||||
@ -90,7 +92,8 @@ def engines_to_xml(supported_engines):
|
|||||||
|
|
||||||
supported_categories = ""
|
supported_categories = ""
|
||||||
if hasattr(search_engine, "supported_categories"):
|
if hasattr(search_engine, "supported_categories"):
|
||||||
supported_categories = " ".join((key for key in search_engine.supported_categories.keys()
|
supported_categories = " ".join((key
|
||||||
|
for key in search_engine.supported_categories.keys()
|
||||||
if key is not "all"))
|
if key is not "all"))
|
||||||
|
|
||||||
yield "".join((tab, "<", short_name, ">\n",
|
yield "".join((tab, "<", short_name, ">\n",
|
||||||
@ -99,6 +102,7 @@ def engines_to_xml(supported_engines):
|
|||||||
tab, tab, "<categories>", supported_categories, "</categories>\n",
|
tab, tab, "<categories>", supported_categories, "</categories>\n",
|
||||||
tab, "</", short_name, ">\n"))
|
tab, "</", short_name, ">\n"))
|
||||||
|
|
||||||
|
|
||||||
def displayCapabilities(supported_engines):
|
def displayCapabilities(supported_engines):
|
||||||
"""
|
"""
|
||||||
Display capabilities in XML format
|
Display capabilities in XML format
|
||||||
@ -115,6 +119,7 @@ def displayCapabilities(supported_engines):
|
|||||||
"</capabilities>"))
|
"</capabilities>"))
|
||||||
print(xml)
|
print(xml)
|
||||||
|
|
||||||
|
|
||||||
def run_search(engine_list):
|
def run_search(engine_list):
|
||||||
""" Run search in engine
|
""" Run search in engine
|
||||||
|
|
||||||
@ -136,6 +141,7 @@ def run_search(engine_list):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
fix_encoding()
|
fix_encoding()
|
||||||
supported_engines = initialize_engines()
|
supported_engines = initialize_engines()
|
||||||
@ -180,5 +186,6 @@ def main(args):
|
|||||||
else:
|
else:
|
||||||
map(run_search, ([globals()[engine], what, cat] for engine in engines_list))
|
map(run_search, ([globals()[engine], what, cat] for engine in engines_list))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(argv[1:])
|
main(argv[1:])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.20
|
#VERSION: 1.21
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
@ -37,8 +37,10 @@ supported_engines = dict()
|
|||||||
engines = glob.glob(os.path.join(os.path.dirname(__file__), 'engines', '*.py'))
|
engines = glob.glob(os.path.join(os.path.dirname(__file__), 'engines', '*.py'))
|
||||||
for engine in engines:
|
for engine in engines:
|
||||||
e = engine.split(os.sep)[-1][:-3]
|
e = engine.split(os.sep)[-1][:-3]
|
||||||
if len(e.strip()) == 0: continue
|
if len(e.strip()) == 0:
|
||||||
if e.startswith('_'): continue
|
continue
|
||||||
|
if e.startswith('_'):
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
exec("from engines.%s import %s" % (e, e))
|
exec("from engines.%s import %s" % (e, e))
|
||||||
exec("engine_url = %s.url" % e)
|
exec("engine_url = %s.url" % e)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.45
|
#VERSION: 1.46
|
||||||
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions are met:
|
# modification, are permitted provided that the following conditions are met:
|
||||||
@ -24,21 +24,26 @@
|
|||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import sys, codecs
|
import codecs
|
||||||
|
import sys
|
||||||
from io import open
|
from io import open
|
||||||
|
|
||||||
# Force UTF-8 printing
|
# Force UTF-8 printing
|
||||||
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
|
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
|
||||||
|
|
||||||
|
|
||||||
def prettyPrinter(dictionary):
|
def prettyPrinter(dictionary):
|
||||||
dictionary['size'] = anySizeToBytes(dictionary['size'])
|
dictionary['size'] = anySizeToBytes(dictionary['size'])
|
||||||
outtext = "|".join((dictionary["link"], dictionary["name"].replace("|", " "), str(dictionary["size"]), str(dictionary["seeds"]), str(dictionary["leech"]), dictionary["engine_url"]))
|
outtext = "|".join((dictionary["link"], dictionary["name"].replace("|", " "),
|
||||||
|
str(dictionary["size"]), str(dictionary["seeds"]),
|
||||||
|
str(dictionary["leech"]), dictionary["engine_url"]))
|
||||||
if 'desc_link' in dictionary:
|
if 'desc_link' in dictionary:
|
||||||
outtext = "|".join((outtext, dictionary["desc_link"]))
|
outtext = "|".join((outtext, dictionary["desc_link"]))
|
||||||
|
|
||||||
with open(1, 'w', encoding='utf-8', closefd=False) as utf8_stdout:
|
with open(1, 'w', encoding='utf-8', closefd=False) as utf8_stdout:
|
||||||
utf8_stdout.write(unicode("".join((outtext, "\n"))))
|
utf8_stdout.write(unicode("".join((outtext, "\n"))))
|
||||||
|
|
||||||
|
|
||||||
def anySizeToBytes(size_string):
|
def anySizeToBytes(size_string):
|
||||||
"""
|
"""
|
||||||
Convert a string like '1 KB' to '1024' (bytes)
|
Convert a string like '1 KB' to '1024' (bytes)
|
||||||
@ -63,6 +68,6 @@ def anySizeToBytes(size_string):
|
|||||||
|
|
||||||
# convert
|
# convert
|
||||||
units_dict = {'T': 40, 'G': 30, 'M': 20, 'K': 10}
|
units_dict = {'T': 40, 'G': 30, 'M': 20, 'K': 10}
|
||||||
if units_dict.has_key(short_unit):
|
if short_unit in units_dict:
|
||||||
size = size * 2**units_dict[short_unit]
|
size = size * 2**units_dict[short_unit]
|
||||||
return int(size)
|
return int(size)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.40
|
#VERSION: 1.41
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
@ -27,13 +27,17 @@
|
|||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import re, html.entities
|
import gzip
|
||||||
import tempfile
|
import html.entities
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import io, gzip, urllib.request, urllib.error, urllib.parse
|
import re
|
||||||
import socket
|
import socket
|
||||||
import socks
|
import socks
|
||||||
import re
|
import tempfile
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
# Some sites blocks default python User-agent
|
# Some sites blocks default python User-agent
|
||||||
user_agent = 'Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Firefox/38.0'
|
user_agent = 'Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Firefox/38.0'
|
||||||
@ -41,11 +45,14 @@ headers = {'User-Agent': user_agent}
|
|||||||
# SOCKS5 Proxy support
|
# SOCKS5 Proxy support
|
||||||
if "sock_proxy" in os.environ and len(os.environ["sock_proxy"].strip()) > 0:
|
if "sock_proxy" in os.environ and len(os.environ["sock_proxy"].strip()) > 0:
|
||||||
proxy_str = os.environ["sock_proxy"].strip()
|
proxy_str = os.environ["sock_proxy"].strip()
|
||||||
m=re.match(r"^(?:(?P<username>[^:]+):(?P<password>[^@]+)@)?(?P<host>[^:]+):(?P<port>\w+)$", proxy_str)
|
m = re.match(r"^(?:(?P<username>[^:]+):(?P<password>[^@]+)@)?(?P<host>[^:]+):(?P<port>\w+)$",
|
||||||
|
proxy_str)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, m.group('host'), int(m.group('port')), True, m.group('username'), m.group('password'))
|
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, m.group('host'),
|
||||||
|
int(m.group('port')), True, m.group('username'), m.group('password'))
|
||||||
socket.socket = socks.socksocket
|
socket.socket = socks.socksocket
|
||||||
|
|
||||||
|
|
||||||
def htmlentitydecode(s):
|
def htmlentitydecode(s):
|
||||||
# First convert alpha entities (such as é)
|
# First convert alpha entities (such as é)
|
||||||
# (Inspired from http://mail.python.org/pipermail/python-list/2007-June/443813.html)
|
# (Inspired from http://mail.python.org/pipermail/python-list/2007-June/443813.html)
|
||||||
@ -57,10 +64,11 @@ def htmlentitydecode(s):
|
|||||||
t = re.sub('&(%s);' % '|'.join(html.entities.name2codepoint), entity2char, s)
|
t = re.sub('&(%s);' % '|'.join(html.entities.name2codepoint), entity2char, s)
|
||||||
|
|
||||||
# Then convert numerical entities (such as é)
|
# Then convert numerical entities (such as é)
|
||||||
t = re.sub('&#(\d+);', lambda x: chr(int(x.group(1))), t)
|
t = re.sub(r'&#(\d+);', lambda x: chr(int(x.group(1))), t)
|
||||||
|
|
||||||
# Then convert hexa entities (such as é)
|
# Then convert hexa entities (such as é)
|
||||||
return re.sub('&#x(\w+);', lambda x: chr(int(x.group(1),16)), t)
|
return re.sub(r'&#x(\w+);', lambda x: chr(int(x.group(1), 16)), t)
|
||||||
|
|
||||||
|
|
||||||
def retrieve_url(url):
|
def retrieve_url(url):
|
||||||
""" Return the content of the url page as a string """
|
""" Return the content of the url page as a string """
|
||||||
@ -89,6 +97,7 @@ def retrieve_url(url):
|
|||||||
# return dat.encode('utf-8', 'replace')
|
# return dat.encode('utf-8', 'replace')
|
||||||
return dat
|
return dat
|
||||||
|
|
||||||
|
|
||||||
def download_file(url, referer=None):
|
def download_file(url, referer=None):
|
||||||
""" Download file at url and write it to a file, return the path to the file and the url """
|
""" Download file at url and write it to a file, return the path to the file and the url """
|
||||||
file, path = tempfile.mkstemp()
|
file, path = tempfile.mkstemp()
|
||||||
@ -111,4 +120,4 @@ def download_file(url, referer=None):
|
|||||||
file.write(dat)
|
file.write(dat)
|
||||||
file.close()
|
file.close()
|
||||||
# return file path
|
# return file path
|
||||||
return path+" "+url
|
return (path + " " + url)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.41
|
#VERSION: 1.42
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Fabien Devaux <fab AT gnux DOT info>
|
# Fabien Devaux <fab AT gnux DOT info>
|
||||||
@ -55,6 +55,7 @@ CATEGORIES = {'all', 'movies', 'tv', 'music', 'games', 'anime', 'software', 'pic
|
|||||||
# As a convention, try to list results by decreasing number of seeds or similar
|
# As a convention, try to list results by decreasing number of seeds or similar
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
def initialize_engines():
|
def initialize_engines():
|
||||||
""" Import available engines
|
""" Import available engines
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ def initialize_engines():
|
|||||||
|
|
||||||
return supported_engines
|
return supported_engines
|
||||||
|
|
||||||
|
|
||||||
def engines_to_xml(supported_engines):
|
def engines_to_xml(supported_engines):
|
||||||
""" Generates xml for supported engines """
|
""" Generates xml for supported engines """
|
||||||
tab = " " * 4
|
tab = " " * 4
|
||||||
@ -89,7 +91,8 @@ def engines_to_xml(supported_engines):
|
|||||||
|
|
||||||
supported_categories = ""
|
supported_categories = ""
|
||||||
if hasattr(search_engine, "supported_categories"):
|
if hasattr(search_engine, "supported_categories"):
|
||||||
supported_categories = " ".join((key for key in search_engine.supported_categories.keys()
|
supported_categories = " ".join((key
|
||||||
|
for key in search_engine.supported_categories.keys()
|
||||||
if key is not "all"))
|
if key is not "all"))
|
||||||
|
|
||||||
yield "".join((tab, "<", short_name, ">\n",
|
yield "".join((tab, "<", short_name, ">\n",
|
||||||
@ -98,6 +101,7 @@ def engines_to_xml(supported_engines):
|
|||||||
tab, tab, "<categories>", supported_categories, "</categories>\n",
|
tab, tab, "<categories>", supported_categories, "</categories>\n",
|
||||||
tab, "</", short_name, ">\n"))
|
tab, "</", short_name, ">\n"))
|
||||||
|
|
||||||
|
|
||||||
def displayCapabilities(supported_engines):
|
def displayCapabilities(supported_engines):
|
||||||
"""
|
"""
|
||||||
Display capabilities in XML format
|
Display capabilities in XML format
|
||||||
@ -114,6 +118,7 @@ def displayCapabilities(supported_engines):
|
|||||||
"</capabilities>"))
|
"</capabilities>"))
|
||||||
print(xml)
|
print(xml)
|
||||||
|
|
||||||
|
|
||||||
def run_search(engine_list):
|
def run_search(engine_list):
|
||||||
""" Run search in engine
|
""" Run search in engine
|
||||||
|
|
||||||
@ -136,6 +141,7 @@ def run_search(engine_list):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
supported_engines = initialize_engines()
|
supported_engines = initialize_engines()
|
||||||
|
|
||||||
@ -179,5 +185,6 @@ def main(args):
|
|||||||
# py3 note: map is needed to be evaluated for content to be executed
|
# py3 note: map is needed to be evaluated for content to be executed
|
||||||
all(map(run_search, ([globals()[engine], what, cat] for engine in engines_list)))
|
all(map(run_search, ([globals()[engine], what, cat] for engine in engines_list)))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(argv[1:])
|
main(argv[1:])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.20
|
#VERSION: 1.21
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
@ -37,8 +37,10 @@ supported_engines = dict()
|
|||||||
engines = glob.glob(os.path.join(os.path.dirname(__file__), 'engines', '*.py'))
|
engines = glob.glob(os.path.join(os.path.dirname(__file__), 'engines', '*.py'))
|
||||||
for engine in engines:
|
for engine in engines:
|
||||||
e = engine.split(os.sep)[-1][:-3]
|
e = engine.split(os.sep)[-1][:-3]
|
||||||
if len(e.strip()) == 0: continue
|
if len(e.strip()) == 0:
|
||||||
if e.startswith('_'): continue
|
continue
|
||||||
|
if e.startswith('_'):
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
exec("from engines.%s import %s" % (e, e))
|
exec("from engines.%s import %s" % (e, e))
|
||||||
exec("engine_url = %s.url" % e)
|
exec("engine_url = %s.url" % e)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.45
|
#VERSION: 1.46
|
||||||
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions are met:
|
# modification, are permitted provided that the following conditions are met:
|
||||||
@ -24,9 +24,12 @@
|
|||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
def prettyPrinter(dictionary):
|
def prettyPrinter(dictionary):
|
||||||
dictionary['size'] = anySizeToBytes(dictionary['size'])
|
dictionary['size'] = anySizeToBytes(dictionary['size'])
|
||||||
outtext = "|".join((dictionary["link"], dictionary["name"].replace("|", " "), str(dictionary["size"]), str(dictionary["seeds"]), str(dictionary["leech"]), dictionary["engine_url"]))
|
outtext = "|".join((dictionary["link"], dictionary["name"].replace("|", " "),
|
||||||
|
str(dictionary["size"]), str(dictionary["seeds"]),
|
||||||
|
str(dictionary["leech"]), dictionary["engine_url"]))
|
||||||
if 'desc_link' in dictionary:
|
if 'desc_link' in dictionary:
|
||||||
outtext = "|".join((outtext, dictionary["desc_link"]))
|
outtext = "|".join((outtext, dictionary["desc_link"]))
|
||||||
|
|
||||||
@ -34,6 +37,7 @@ def prettyPrinter(dictionary):
|
|||||||
with open(1, 'w', encoding='utf-8', closefd=False) as utf8stdout:
|
with open(1, 'w', encoding='utf-8', closefd=False) as utf8stdout:
|
||||||
print(outtext, file=utf8stdout)
|
print(outtext, file=utf8stdout)
|
||||||
|
|
||||||
|
|
||||||
def anySizeToBytes(size_string):
|
def anySizeToBytes(size_string):
|
||||||
"""
|
"""
|
||||||
Convert a string like '1 KB' to '1024' (bytes)
|
Convert a string like '1 KB' to '1024' (bytes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user