Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gofile extractor "401 Unauthorized" #2632

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions gallery_dl/extractor/gofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .common import Extractor, Message
from .. import exception
from ..cache import memcache
import re


class GofileFolderExtractor(Extractor):
Expand Down Expand Up @@ -74,7 +75,8 @@ def items(self):
token = self._create_account()
self.session.cookies.set("accountToken", token, domain=".gofile.io")

folder = self._get_content(self.content_id, token)
website_token = self._get_website_token()
folder = self._get_content(self.content_id, token, website_token)
yield Message.Directory, folder

num = 0
Expand Down Expand Up @@ -104,11 +106,19 @@ def items(self):
def _create_account(self):
return self._api_request("createAccount")["token"]

def _get_content(self, content_id, token):
def _get_website_token(self):
response = self.request("https://gofile.io/contents/files.html")
regex = r"websiteToken:\s+\"([^\"]*)\""
matches = re.findall(regex, response.text)
if len(matches) < 1:
raise exception.StopExtraction("Could not find websiteToken!")
return matches[0]

def _get_content(self, content_id, token, website_token):
return self._api_request("getContent", {
"contentId" : content_id,
"token" : token,
"websiteToken": "websiteToken",
"contentId": content_id,
"token": token,
"websiteToken": website_token,
})

def _api_request(self, endpoint, params=None):
Expand Down