aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2020-09-30 08:56:56 +0200
committerneodarz <neodarz@neodarz.net>2020-09-30 08:56:56 +0200
commitdaf74314d743bba802321c1f61d601320a3c632f (patch)
tree596876e4ad2afdb3725b6a8436723790200ab7c8
parentac9eaf5c4fcaf6d41804dc67a17ccb77a99e1668 (diff)
downloadmusic_downloader-daf74314d743bba802321c1f61d601320a3c632f.tar.xz
music_downloader-daf74314d743bba802321c1f61d601320a3c632f.zip
Add soundcloud support
Diffstat (limited to '')
-rw-r--r--extractors/common.py9
-rw-r--r--extractors/job.py3
-rw-r--r--extractors/soundcloud.py18
3 files changed, 29 insertions, 1 deletions
diff --git a/extractors/common.py b/extractors/common.py
index 0287496..019556c 100644
--- a/extractors/common.py
+++ b/extractors/common.py
@@ -9,12 +9,21 @@ class Extractor():
def __init__(self, reg, url):
self.root = None
+ self.path = None
if not reg:
r = re.search(r'(^http(?:s|):(?:\/\/.*?\/|\/\/.*))', url)
if r:
self.root = r.group(1)
+ try:
+ self.path = r.group(2)
+ except IndexError:
+ pass
if not self.root:
self.root = reg.group(1)
+ try:
+ self.path = reg.group(2)
+ except IndexError:
+ pass
self._albums = []
self.root_path = self._root_path()
self._update_cache(self.root)
diff --git a/extractors/job.py b/extractors/job.py
index 795617a..8770500 100644
--- a/extractors/job.py
+++ b/extractors/job.py
@@ -6,7 +6,8 @@ import sys
from utils import NoExtractorException
extrs = [
- 'bandcamp'
+ 'bandcamp',
+ 'soundcloud',
]
diff --git a/extractors/soundcloud.py b/extractors/soundcloud.py
new file mode 100644
index 0000000..e7c7e0b
--- /dev/null
+++ b/extractors/soundcloud.py
@@ -0,0 +1,18 @@
+import re
+import logging
+import requests
+from bs4 import BeautifulSoup
+
+from .common import Extractor
+
+class soundcloud(Extractor):
+ pattern = re.compile(r'(http(?:s|):\/\/.*soundcloud.com)(.*)')
+ filename_template = "%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s"
+
+ def __init__(self, reg, url):
+ super().__init__(reg, url)
+
+ def get_albums(self):
+ # We directly use youtube-dl soudcloud albums management
+ # (It download all songs by an artist
+ self._albums.append(self.root + self.path)