# ex:ts=4:sw=4:sts=4:et # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- import re import xml.etree.ElementTree as ET from urllib.parse import urlparse from svtplay_dl.error import ServiceError from svtplay_dl.fetcher.hls import hlsparse from svtplay_dl.service import Service class Solidtango(Service): supported_domains_re = [r"^([^.]+\.)*solidtango.com"] supported_domains = ["mm-resource-service.herokuapp.com", "solidtango.com", "solidsport.com"] def get(self): data = self.get_urldata() parse = urlparse(self.url) if "solidsport" in parse.netloc: if self.config.get("username") and self.config.get("password"): res = self.http.request("get", "https://solidsport.com/login") match = re.search('authenticity_token" value="([^"]+)"', res.text) if not match: yield ServiceError("Cant find auth token for login") return pdata = { "authenticity_token": match.group(1), "user[email]": self.config.get("username"), "user[password]": self.config.get("password"), "commit": "Sign in", "utf8": "✓", } res = self.http.request("post", "https://solidsport.com/login", data=pdata) if "Wrong passwor" in res.text or "Can't find account" in res.text: yield ServiceError("Wrong username or password") return data = self.http.request("get", self.url).text match = re.search('src="(http://mm-resource-service.herokuapp.com[^"]*)"', data) if match: data = self.http.request("get", match.group(1)).text match = re.search('src="(https://[^"]+solidtango[^"]+)" ', data) if match: data = self.http.request("get", match.group(1)).text match = re.search(r"