diff options
author | neodarz <neodarz@neodarz.net> | 2020-08-15 14:07:15 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2020-08-15 14:07:15 +0200 |
commit | c4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b (patch) | |
tree | 746b1c9e7d5b2f49e338706fec9f9c0d74f9f7c3 /extractors/bandcamp.py | |
download | music_downloader-c4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b.tar.xz music_downloader-c4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b.zip |
Initial commit
Diffstat (limited to 'extractors/bandcamp.py')
-rw-r--r-- | extractors/bandcamp.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/extractors/bandcamp.py b/extractors/bandcamp.py new file mode 100644 index 0000000..cc383ae --- /dev/null +++ b/extractors/bandcamp.py @@ -0,0 +1,26 @@ +import re +import logging +import requests +from bs4 import BeautifulSoup + +from .common import Extractor + +class bandcamp(Extractor): + pattern = re.compile(r'(http(?:s|):\/\/.*bandcamp.com\/)') + filename_template = "%(artist)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" + + def __init__(self, reg, url): + super().__init__(reg, url) + + def get_albums(self): + r = requests.get(self.root) + soup = BeautifulSoup(r.text, 'html.parser') + items = soup.select('a[href]') + for item in items: + if 'album' in item['href']: + url = self.root.rstrip('/') + item['href'] + if url not in self._albums: + self._albums.append(url) + + if not self._albums: + logging.warning(f"No albums found at {self.root} ????") |