Fix case where Gfycat fails after redirect
This commit is contained in:
@@ -28,7 +28,12 @@ class Gfycat(GifDeliveryNetwork):
|
|||||||
gfycat_id = re.match(r'.*/(.*?)/?$', url).group(1)
|
gfycat_id = re.match(r'.*/(.*?)/?$', url).group(1)
|
||||||
url = 'https://gfycat.com/' + gfycat_id
|
url = 'https://gfycat.com/' + gfycat_id
|
||||||
|
|
||||||
page_source = requests.get(url).text
|
response = requests.get(url)
|
||||||
|
page_source = response.text
|
||||||
|
|
||||||
|
if 'gifdeliverynetwork' in response.url:
|
||||||
|
return GifDeliveryNetwork._get_link(url)
|
||||||
|
|
||||||
soup = BeautifulSoup(page_source, 'html.parser')
|
soup = BeautifulSoup(page_source, 'html.parser')
|
||||||
content = soup.find('script', attrs={'data-react-helmet': 'true', 'type': 'application/ld+json'})
|
content = soup.find('script', attrs={'data-react-helmet': 'true', 'type': 'application/ld+json'})
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from bulkredditdownloader.site_downloaders.gfycat import Gfycat
|
|||||||
@pytest.mark.parametrize(('test_url', 'expected_url'), (
|
@pytest.mark.parametrize(('test_url', 'expected_url'), (
|
||||||
('https://gfycat.com/definitivecaninecrayfish', 'https://giant.gfycat.com/DefinitiveCanineCrayfish.mp4'),
|
('https://gfycat.com/definitivecaninecrayfish', 'https://giant.gfycat.com/DefinitiveCanineCrayfish.mp4'),
|
||||||
('https://gfycat.com/dazzlingsilkyiguana', 'https://giant.gfycat.com/DazzlingSilkyIguana.mp4'),
|
('https://gfycat.com/dazzlingsilkyiguana', 'https://giant.gfycat.com/DazzlingSilkyIguana.mp4'),
|
||||||
|
('https://gfycat.com/webbedimpurebutterfly', 'https://thumbs2.redgifs.com/WebbedImpureButterfly.mp4'),
|
||||||
))
|
))
|
||||||
def test_get_link(test_url: str, expected_url: str):
|
def test_get_link(test_url: str, expected_url: str):
|
||||||
result = Gfycat._get_link(test_url)
|
result = Gfycat._get_link(test_url)
|
||||||
|
|||||||
Reference in New Issue
Block a user