2020-05-10 00:31:42 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2021-01-06 18:16:06 +01:00
|
|
|
# Copyright 2020-2021 Mike Fährmann
|
2020-05-10 00:31:42 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
|
|
|
|
"""Extractors for https://redgifs.com/"""
|
|
|
|
|
2020-07-16 14:48:31 +02:00
|
|
|
from .gfycat import GfycatExtractor, GfycatAPI
|
|
|
|
from .. import text
|
2020-05-10 00:31:42 +02:00
|
|
|
|
|
|
|
|
2020-06-10 22:03:52 +02:00
|
|
|
class RedgifsExtractor(GfycatExtractor):
|
|
|
|
"""Base class for redgifs extractors"""
|
2020-05-10 00:31:42 +02:00
|
|
|
category = "redgifs"
|
2021-01-06 18:16:06 +01:00
|
|
|
root = "https://www.redgifs.com"
|
2020-06-10 22:03:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
class RedgifsUserExtractor(RedgifsExtractor):
|
|
|
|
"""Extractor for redgifs user profiles"""
|
|
|
|
subcategory = "user"
|
|
|
|
directory_fmt = ("{category}", "{userName}")
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = r"(?:https?://)?(?:www\.)?redgifs\.com/users/([^/?#]+)"
|
2020-06-10 22:03:52 +02:00
|
|
|
test = ("https://www.redgifs.com/users/Natalifiction", {
|
2020-09-20 21:54:39 +02:00
|
|
|
"pattern": r"https://\w+\.(redgifs|gfycat)\.com/[A-Za-z]+\.mp4",
|
2020-06-10 22:03:52 +02:00
|
|
|
"count": ">= 100",
|
|
|
|
})
|
|
|
|
|
|
|
|
def gfycats(self):
|
|
|
|
return RedgifsAPI(self).user(self.key)
|
|
|
|
|
|
|
|
|
|
|
|
class RedgifsSearchExtractor(RedgifsExtractor):
|
|
|
|
"""Extractor for redgifs search results"""
|
|
|
|
subcategory = "search"
|
|
|
|
directory_fmt = ("{category}", "Search", "{search}")
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = r"(?:https?://)?(?:www\.)?redgifs\.com/gifs/browse/([^/?#]+)"
|
2020-06-10 22:03:52 +02:00
|
|
|
test = ("https://www.redgifs.com/gifs/browse/jav", {
|
2020-09-20 21:54:39 +02:00
|
|
|
"pattern": r"https://\w+\.(redgifs|gfycat)\.com/[A-Za-z]+\.mp4",
|
2021-01-06 18:16:06 +01:00
|
|
|
"range": "1-10",
|
|
|
|
"count": 10,
|
2020-06-10 22:03:52 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
def metadata(self):
|
2020-07-16 14:48:31 +02:00
|
|
|
self.key = text.unquote(self.key).replace("-", " ")
|
2020-06-10 22:03:52 +02:00
|
|
|
return {"search": self.key}
|
|
|
|
|
|
|
|
def gfycats(self):
|
|
|
|
return RedgifsAPI(self).search(self.key)
|
|
|
|
|
|
|
|
|
|
|
|
class RedgifsImageExtractor(RedgifsExtractor):
|
|
|
|
"""Extractor for individual gifs from redgifs.com"""
|
|
|
|
subcategory = "image"
|
2021-01-08 16:01:01 +01:00
|
|
|
pattern = (r"(?:https?://)?(?:www\.)?(?:redgifs\.com/(?:watch|ifr)"
|
2020-07-09 18:04:30 +02:00
|
|
|
r"|gifdeliverynetwork.com)/([A-Za-z]+)")
|
|
|
|
test = (
|
|
|
|
("https://redgifs.com/watch/foolishforkedabyssiniancat", {
|
2020-08-30 20:55:22 +02:00
|
|
|
"pattern": r"https://\w+\.(redgifs|gfycat)\.com"
|
|
|
|
r"/FoolishForkedAbyssiniancat\.mp4",
|
2020-07-09 18:04:30 +02:00
|
|
|
"content": "f6e03f1df9a2ff2a74092f53ee7580d2fb943533",
|
|
|
|
}),
|
2021-01-08 16:01:01 +01:00
|
|
|
("https://redgifs.com/ifr/FoolishForkedAbyssiniancat"),
|
2020-07-09 18:04:30 +02:00
|
|
|
("https://www.gifdeliverynetwork.com/foolishforkedabyssiniancat"),
|
|
|
|
)
|
2020-05-28 02:00:40 +02:00
|
|
|
|
2020-06-10 22:03:52 +02:00
|
|
|
def gfycats(self):
|
|
|
|
return (RedgifsAPI(self).gfycat(self.key),)
|
2020-05-28 02:00:40 +02:00
|
|
|
|
|
|
|
|
2020-07-16 14:48:31 +02:00
|
|
|
class RedgifsAPI(GfycatAPI):
|
2021-06-16 23:07:25 +02:00
|
|
|
API_ROOT = "https://api.redgifs.com"
|
2020-07-16 14:48:31 +02:00
|
|
|
ACCESS_KEY = ("dBLwVuGn9eq4dtXLs8WSfpjcYFY7bPQe"
|
|
|
|
"AqGPSFgqeW5B9uzj2cMVhF63pTFF4Rg9")
|