1
0
Fork 0
mirror of synced 2024-09-29 08:41:56 +13:00

Fix for access denied

This commit is contained in:
Erik Johnson 2021-01-17 22:58:51 +01:00 committed by GitHub
parent e7bf66f28b
commit 332e08d038
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,7 +36,9 @@ class Redgifs:
if url[-1:] == '/':
url = url[:-1]
url = "https://redgifs.com/watch/" + url.split('/')[-1]
url = urllib.request.Request("https://redgifs.com/watch/" + url.split('/')[-1])
url.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.64')
pageSource = (urllib.request.urlopen(url).read().decode())
@ -47,4 +49,4 @@ class Redgifs:
if content is None:
raise NotADownloadableLinkError("Could not read the page source")
return json.loads(content.contents[0])["video"]["contentUrl"]
return json.loads(content.contents[0])["video"]["contentUrl"]