Merge pull request #731 from Soulsuck24/development
This commit is contained in:
@@ -23,13 +23,18 @@ class Redgifs(BaseDownloader):
|
|||||||
return [Resource(self.post, m, Resource.retry_download(m), None) for m in media_urls]
|
return [Resource(self.post, m, Resource.retry_download(m), None) for m in media_urls]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_link(url: str) -> set[str]:
|
def _get_id(url: str) -> str:
|
||||||
try:
|
try:
|
||||||
if url.endswith("/"):
|
if url.endswith("/"):
|
||||||
url = url.removesuffix("/")
|
url = url.removesuffix("/")
|
||||||
redgif_id = re.match(r".*/(.*?)(\..{0,})?$", url).group(1)
|
redgif_id = re.match(r".*/(.*?)(?:\?.*|\..{0,})?$", url).group(1)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise SiteDownloaderError(f"Could not extract Redgifs ID from {url}")
|
raise SiteDownloaderError(f"Could not extract Redgifs ID from {url}")
|
||||||
|
return redgif_id
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_link(url: str) -> set[str]:
|
||||||
|
redgif_id = Redgifs._get_id(url)
|
||||||
|
|
||||||
auth_token = json.loads(Redgifs.retrieve_url("https://api.redgifs.com/v2/auth/temporary").text)["token"]
|
auth_token = json.loads(Redgifs.retrieve_url("https://api.redgifs.com/v2/auth/temporary").text)["token"]
|
||||||
if not auth_token:
|
if not auth_token:
|
||||||
|
|||||||
@@ -10,6 +10,19 @@ from bdfr.resource import Resource
|
|||||||
from bdfr.site_downloaders.redgifs import Redgifs
|
from bdfr.site_downloaders.redgifs import Redgifs
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("test_url", "expected"),
|
||||||
|
(
|
||||||
|
("https://redgifs.com/watch/frighteningvictorioussalamander", "frighteningvictorioussalamander"),
|
||||||
|
("https://www.redgifs.com/watch/genuineprivateguillemot/", "genuineprivateguillemot"),
|
||||||
|
("https://www.redgifs.com/watch/marriedcrushingcob?rel=u%3Akokiri.girl%3Bo%3Arecent", "marriedcrushingcob"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_get_id(test_url: str, expected: str):
|
||||||
|
result = Redgifs._get_id(test_url)
|
||||||
|
assert result == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.online
|
@pytest.mark.online
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("test_url", "expected"),
|
("test_url", "expected"),
|
||||||
|
|||||||
Reference in New Issue
Block a user