from sites.default import DefaultSite from sites.helper.query import Query class Lalamus(DefaultSite): def __init__(self): super().__init__() self.url = 'https://wwc.lalamus.mobi' self.query = Query(self, 'FLAT', 'music') self.structure\ .set_container_path('div.playlist-hash')\ .set_item_path('table.song')\ .set_title_path('td.title')\ .set_duration_path('td.time') \ .set_url_path('button.btn_download') self.request\ .add_header('Referer', self.url + '/')\ .add_header('Origin', self.url)\ .add_header('Content-Type', 'application/x-www-form-urlencoded') def format_url(self, field): script = field.attr.onclick _start = 'openDL(\'' _end = '\'' start = script.find(_start) if start > -1: end = script.find(_end, start+len(_start)) if end > -1 and end > start: return '{0}{1}'.format(self.url, script[start+len(_start):end]) return None