diff options
author | neodarz <neodarz@neodarz.net> | 2020-08-15 17:08:58 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2020-08-15 17:08:58 +0200 |
commit | e2099a3e5c8f38c8bae88d862950b0c2bf5b1d13 (patch) | |
tree | 8bec0b584c05b4343ac6f1ea78682747402eb207 /extractors/common.py | |
parent | e6097b7d5b6122eeecea6a358a8e74cff5a17bbb (diff) | |
download | music_downloader-e2099a3e5c8f38c8bae88d862950b0c2bf5b1d13.tar.xz music_downloader-e2099a3e5c8f38c8bae88d862950b0c2bf5b1d13.zip |
Add option to specifie extractor
Diffstat (limited to '')
-rw-r--r-- | extractors/common.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/extractors/common.py b/extractors/common.py index db8f5c1..da3e59c 100644 --- a/extractors/common.py +++ b/extractors/common.py @@ -1,4 +1,5 @@ import os +import re from pathlib import Path from sh import youtube_dl from utils import read_file, write_file @@ -7,7 +8,13 @@ from utils import read_file, write_file class Extractor(): def __init__(self, reg, url): - self.root = reg.group(1) + self.root = None + if not reg: + r = re.search(r'(^http(?:s|):(?:\/\/.*?\/|\/\/.*))', url) + if r: + self.root = r.group(1) + if not self.root: + self.root = reg.group(1) self._albums = [] self.root_path = self._root_path() self._update_cache(self.root) @@ -26,7 +33,7 @@ class Extractor(): for url in urls_cache: if url.startswith(self.root): return - write_file(cache_file, self.root) + write_file(cache_file, self.root + "," + self.__class__.__name__) def _yt_wrapper(self, url, output): for line in youtube_dl( |