Adds a package, with links to desired destination. :param name: name of the new package :param links: list of urls :param dest: `Destination` :return: package id of the new package
(self, name, links, dest=Destination.Queue)
| 309 | |
| 310 | @permission(PERMS.ADD) |
| 311 | def addPackage(self, name, links, dest=Destination.Queue): |
| 312 | """Adds a package, with links to desired destination. |
| 313 | |
| 314 | :param name: name of the new package |
| 315 | :param links: list of urls |
| 316 | :param dest: `Destination` |
| 317 | :return: package id of the new package |
| 318 | """ |
| 319 | if self.core.config['general']['folder_per_package']: |
| 320 | folder = name |
| 321 | else: |
| 322 | folder = "" |
| 323 | |
| 324 | folder = folder.replace("http://", "").replace("https://", "").rstrip("/") \ |
| 325 | .replace(":", "").replace("/", "_").replace("\\", "_") |
| 326 | |
| 327 | pid = self.core.files.addPackage(name, folder, dest) |
| 328 | |
| 329 | self.core.files.addLinks(links, pid) |
| 330 | |
| 331 | self.core.log.info(_("Added package %(name)s containing %(count)d links") % {"name": name, "count": len(links)}) |
| 332 | |
| 333 | self.core.files.save() |
| 334 | |
| 335 | return pid |
| 336 | |
| 337 | @permission(PERMS.ADD) |
| 338 | def parseURLs(self, html=None, url=None): |
no test coverage detected