diff --git a/gallery_dl/extractor/hotleak.py b/gallery_dl/extractor/hotleak.py index 27bd3e30..d12c4125 100644 --- a/gallery_dl/extractor/hotleak.py +++ b/gallery_dl/extractor/hotleak.py @@ -50,6 +50,12 @@ class HotleakExtractor(Extractor): params["page"] += 1 +def decode_video_url(encoded_url): + sliced_url = encoded_url[16:-16] + reversed_url = sliced_url[::-1] + return base64.b64decode(reversed_url).decode('utf-8') + + class HotleakPostExtractor(HotleakExtractor): """Extractor for individual posts on hotleak""" subcategory = "post" @@ -84,11 +90,6 @@ class HotleakPostExtractor(HotleakExtractor): HotleakExtractor.__init__(self, match) self.creator, self.type, self.id = match.groups() - def decode_video_url(self, encoded_url): - sliced_url = encoded_url[16:-16] - reversed_url = sliced_url[::-1] - return base64.b64decode(reversed_url).decode('utf-8') - def posts(self): url = "{}/{}/{}/{}".format( self.root, self.creator, self.type, self.id) @@ -106,7 +107,7 @@ class HotleakPostExtractor(HotleakExtractor): text.nameext_from_url(data["url"], data) elif self.type == "video": - data["url"] = "ytdl:" + self.decode_video_url(text.extr( + data["url"] = "ytdl:" + decode_video_url(text.extr( text.unescape(page), '"src":"', '"')) text.nameext_from_url(data["url"], data) data["extension"] = "mp4" @@ -139,11 +140,6 @@ class HotleakCreatorExtractor(HotleakExtractor): url = "{}/{}".format(self.root, self.creator) return self._pagination(url) - def decode_video_url(self, encoded_url): - sliced_url = encoded_url[16:-16] - reversed_url = sliced_url[::-1] - return base64.b64decode(reversed_url).decode('utf-8') - def _pagination(self, url): headers = {"X-Requested-With": "XMLHttpRequest"} params = {"page": 1} @@ -174,7 +170,7 @@ class HotleakCreatorExtractor(HotleakExtractor): elif post["type"] == 1: data["type"] = "video" - data["url"] = "ytdl:" + self.decode_video_url( + data["url"] = "ytdl:" + decode_video_url( post["stream_url_play"]) text.nameext_from_url(data["url"], data) data["extension"] = "mp4"