def add_links(self, links): """ Add one or multiple links to the package :param links: One or list of urls or :class:`LinkStatus` """ self.links.extend(to_link_list(to_list(links, [])))
def decrypt(cls, core, urls, password=None): """ Static method to decrypt urls or content. Can be used by other plugins. To decrypt file content prefix the string with ``CONTENT_PREFIX `` as seen above. :param core: pyLoad `Core`, needed in decrypt context :param urls: List of urls or single url/ file content :param password: optional password used for decrypting :raises Exception: No decryption errors are cascaded :return: List of decrypted urls, all package info removed """ urls = to_list(urls, []) p = cls(core, password) try: result = p._decrypt(urls) finally: p.clean() ret = [] for url_or_pack in result: if isinstance(url_or_pack, Package): #: package ret.extend(url_or_pack.get_all_urls()) elif isinstance(url_or_pack, LinkStatus): #: link ret.append(url_or_pack.url) else: core.log.debug( "Invalid decrypter result: {0}".format(url_or_pack)) return uniqify(ret)
def add_links(self, links): """ Add one or multiple links to the package :param links: One or list of urls or :class:`LinkStatus` """ self.links.extend(to_link_list(to_list(links, [])))
def decrypt(cls, core, urls, password=None): """ Static method to decrypt urls or content. Can be used by other plugins. To decrypt file content prefix the string with ``CONTENT_PREFIX `` as seen above. :param core: pyLoad `Core`, needed in decrypt context :param urls: List of urls or single url/ file content :param password: optional password used for decrypting :raises Exception: No decryption errors are cascaded :return: List of decrypted urls, all package info removed """ urls = to_list(urls, []) p = cls(core, password) try: result = p._decrypt(urls) finally: p.clean() ret = [] for url_or_pack in result: if isinstance(url_or_pack, Package): #: package ret.extend(url_or_pack.get_all_urls()) elif isinstance(url_or_pack, LinkStatus): #: link ret.append(url_or_pack.url) else: core.log.debug( "Invalid decrypter result: {0}".format(url_or_pack)) return uniqify(ret)
def _decrypt(self, urls): """ Internal method to select decrypting method :param urls: List of urls/content :return: (links, packages) """ cls = self.__class__ # separate local and remote files content, urls = self.get_local_content(urls) result = [] if urls and hasmethod(cls, "decrypt"): self.log_debug("Deprecated .decrypt() method in Crypter plugin") result = [] for url in urls: self.pyfile = PyFileMockup(url, cls.__name__) self.setup() self.decrypt(self.pyfile) result.extend(self.convert_packages()) elif urls: method = True try: self.setup() result = to_list(self.decrypt_urls(urls), []) except NotImplementedError: method = False # this will raise error if not implemented if not method: for url in urls: self.setup() result.extend(to_list(self.decrypt_url(url), [])) for f, c in content: self.setup() result.extend(to_list(self.decrypt_file(c), [])) try: if f.startswith("tmp_"): remove(f) except IOError: self.log_warning(_("Could not delete file '{0}'").format(f)) # self.pyload.print_exc() return to_link_list(result)
def _decrypt(self, urls): """ Internal method to select decrypting method :param urls: List of urls/content :return: (links, packages) """ cls = self.__class__ # separate local and remote files content, urls = self.get_local_content(urls) result = [] if urls and hasmethod(cls, "decrypt"): self.log_debug("Deprecated .decrypt() method in Crypter plugin") result = [] for url in urls: self.pyfile = PyFileMockup(url, cls.__name__) self.setup() self.decrypt(self.pyfile) result.extend(self.convert_packages()) elif urls: method = True try: self.setup() result = to_list(self.decrypt_urls(urls), []) except NotImplementedError: method = False # this will raise error if not implemented if not method: for url in urls: self.setup() result.extend(to_list(self.decrypt_url(url), [])) for f, c in content: self.setup() result.extend(to_list(self.decrypt_file(c), [])) try: if f.startswith("tmp_"): remove(f) except IOError: self.log_warning(_("Could not delete file '{0}'").format(f)) # self.pyload.print_exc() return to_link_list(result)
def get_progress_list(self, user=None): info = [] for thread in self.thread: # skip if not belong to current user if user is not None and thread.owner != user: continue if thread.progress: info.extend(to_list(thread.progress, [])) return info
def get_progress_list(self, user=None): info = [] for thread in self.thread: # skip if not belong to current user if user is not None and thread.owner != user: continue progress = thread.get_progress() if progress: info.extend(to_list(progress, [])) return info
def __new__(cls, func, *args, **kwargs): for ev in to_list(event, []): ADDONMANAGER.add_event_listener(class_name(func.__module__), func.__name__, ev) return func
def __new__(cls, f, *args, **kwargs): for ev in to_list(event, []): ADDONMANAGER.add_event_listener( class_name(f.__module__), f.__name__, ev) return f