From c61412841c8ea6c456f7d3472166d81132b56e95 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 19 Feb 2015 16:02:32 +0100 Subject: [LinkList] Rename to TXT --- module/plugins/container/LinkList.py | 69 ------------------------------------ module/plugins/container/TXT.py | 69 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 module/plugins/container/LinkList.py create mode 100644 module/plugins/container/TXT.py diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py deleted file mode 100644 index ccb9b2fa3..000000000 --- a/module/plugins/container/LinkList.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- - -import codecs - -from module.plugins.Container import Container -from module.utils import fs_encode - - -class LinkList(Container): - __name__ = "LinkList" - __type__ = "container" - __version__ = "0.14" - - __pattern__ = r'.+\.txt$' - __config__ = [("flush" , "bool" , "Flush list after adding", False ), - ("encoding", "string", "File encoding" , "utf-8")] - - __description__ = """Read link lists in txt format""" - __license__ = "GPLv3" - __authors__ = [("spoob", "spoob@pyload.org"), - ("jeix", "jeix@hasnomail.com")] - - - def decrypt(self, pyfile): - try: - encoding = codecs.lookup(self.getConfig("encoding")).name - - except Exception: - encoding = "utf-8" - - file = fs_encode(pyfile.url.strip()) - txt = codecs.open(file, 'r', encoding) - curPack = "Parsed links from %s" % pyfile.name - packages = {curPack:[],} - - for link in txt.readlines(): - link = link.strip() - - if not link: - continue - - if link.startswith(";"): - continue - - if link.startswith("[") and link.endswith("]"): - # new package - curPack = link[1:-1] - packages[curPack] = [] - continue - - packages[curPack].append(link) - - txt.close() - - # empty packages fix - for key, value in packages.iteritems(): - if not value: - packages.pop(key, None) - - if self.getConfig("flush"): - try: - txt = open(file, 'wb') - txt.close() - - except IOError: - self.logWarning(_("Failed to flush list")) - - for name, links in packages.iteritems(): - self.packages.append((name, links, name)) diff --git a/module/plugins/container/TXT.py b/module/plugins/container/TXT.py new file mode 100644 index 000000000..585da8ac6 --- /dev/null +++ b/module/plugins/container/TXT.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +import codecs + +from module.plugins.Container import Container +from module.utils import fs_encode + + +class TXT(Container): + __name__ = "TXT" + __type__ = "container" + __version__ = "0.15" + + __pattern__ = r'.+\.(txt|text)$' + __config__ = [("flush" , "bool" , "Flush list after adding", False ), + ("encoding", "string", "File encoding" , "utf-8")] + + __description__ = """Read link lists in plain text formats""" + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("jeix", "jeix@hasnomail.com")] + + + def decrypt(self, pyfile): + try: + encoding = codecs.lookup(self.getConfig("encoding")).name + + except Exception: + encoding = "utf-8" + + file = fs_encode(pyfile.url.strip()) + txt = codecs.open(file, 'r', encoding) + curPack = "Parsed links from %s" % pyfile.name + packages = {curPack:[],} + + for link in txt.readlines(): + link = link.strip() + + if not link: + continue + + if link.startswith(";"): + continue + + if link.startswith("[") and link.endswith("]"): + # new package + curPack = link[1:-1] + packages[curPack] = [] + continue + + packages[curPack].append(link) + + txt.close() + + # empty packages fix + for key, value in packages.iteritems(): + if not value: + packages.pop(key, None) + + if self.getConfig("flush"): + try: + txt = open(file, 'wb') + txt.close() + + except IOError: + self.logWarning(_("Failed to flush list")) + + for name, links in packages.iteritems(): + self.packages.append((name, links, name)) -- cgit v1.2.3