aboutsummaryrefslogtreecommitdiff
path: root/extractors/job.py
diff options
context:
space:
mode:
Diffstat (limited to 'extractors/job.py')
-rw-r--r--extractors/job.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/extractors/job.py b/extractors/job.py
index 596a3ae..795617a 100644
--- a/extractors/job.py
+++ b/extractors/job.py
@@ -3,6 +3,8 @@ import re
import importlib
import sys
+from utils import NoExtractorException
+
extrs = [
'bandcamp'
]
@@ -10,12 +12,16 @@ extrs = [
class DlJob():
- def __init__(self, url, output):
- self.extr = self._find(url)
+ def __init__(self, url, output, extractor=None):
+ if extractor in extrs:
+ cls = self._get_class(extractor)
+ self.extr = cls(reg=None, url=url)
+ else:
+ self.extr = self._find(url)
self.output = output
self._albums = []
if not self.extr:
- logging.error("No extractor found for " + url + ".")
+ raise NoExtractorException("No extractor found for " + url + ".")
def _find(self, url):
for cls in self._list_extractors():
@@ -41,6 +47,13 @@ class DlJob():
)
]
+ def _get_class(self, extractor):
+ module = importlib.import_module('.' + extractor, __package__)
+ classes = self._get_classes(module)
+ for cls in classes:
+ if cls.__name__ == extractor:
+ return cls
+
def run(self):
self.extr.get_albums()
self.extr.download_albums(self.output)