Skip to content

Commit

Permalink
rearrange auth
Browse files Browse the repository at this point in the history
accept direct pasting of OnlyFans Cookie Helper into text document
  • Loading branch information
datawhores committed Feb 18, 2024
1 parent 57a45ae commit c520a52
Show file tree
Hide file tree
Showing 22 changed files with 573 additions and 415 deletions.
2 changes: 0 additions & 2 deletions ofscraper/api/pinned.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
from ofscraper.classes.semaphoreDelayed import semaphoreDelayed
from ofscraper.utils.context.run_async import run

from ..utils import auth

log = logging.getLogger("shared")
attempt = contextvars.ContextVar("attempt")
sem = None
Expand Down
10 changes: 5 additions & 5 deletions ofscraper/classes/sessionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import certifi
import httpx

import ofscraper.utils.auth.file as files
import ofscraper.utils.auth.request as auth_requests
import ofscraper.utils.config.data as data
import ofscraper.utils.constants as constants

from ..utils import auth

####
# This class allows the user to select which backend aiohttp or httpx they want to use
# httpx has better compatiblilty but is slower
Expand Down Expand Up @@ -121,17 +121,17 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def _create_headers(self, headers, url):
headers = headers or {}
if self._set_header:
new_headers = auth.make_headers(auth.read_auth())
new_headers = auth_requests.make_headers(files.read_auth())
headers.update(new_headers)
headers = self._create_sign(headers, url)
return headers

def _create_sign(self, headers, url):
auth.create_sign(url, headers) if self._set_sign else None
auth_requests.create_sign(url, headers) if self._set_sign else None
return headers

def _create_cookies(self):
return auth.add_cookies()
return auth_requests.add_cookies()

def requests(
self,
Expand Down
5 changes: 3 additions & 2 deletions ofscraper/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import ofscraper.models.selector as selector
import ofscraper.utils.args.read as read_args
import ofscraper.utils.args.write as write_args
import ofscraper.utils.auth as auth
import ofscraper.utils.auth.file as auth_file
import ofscraper.utils.auth.request as auth_requests
import ofscraper.utils.cache as cache
import ofscraper.utils.console as console_
import ofscraper.utils.constants as constants
Expand Down Expand Up @@ -298,7 +299,7 @@ def message_checker():

def purchase_checker():
user_dict = {}
auth.make_headers(auth.read_auth())
auth_requests.make_headers(auth_file.read_auth())
ROWS = []
for user_name in read_args.retriveArgs().username:
user_name = profile.scrape_profile(user_name)["username"]
Expand Down
21 changes: 11 additions & 10 deletions ofscraper/download/keyhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import ofscraper.classes.sessionbuilder as sessionbuilder
import ofscraper.download.common as common
import ofscraper.utils.args.read as read_args
import ofscraper.utils.auth as auth
import ofscraper.utils.auth.file as auth_file
import ofscraper.utils.auth.request as auth_requests
import ofscraper.utils.cache as cache
import ofscraper.utils.config.data as config_data
import ofscraper.utils.constants as constants
Expand Down Expand Up @@ -101,9 +102,9 @@ async def key_helper_cdrm(c, pssh, licence_url, id):
try:
log.debug(f"ID:{id} pssh: {pssh!=None}")
log.debug(f"ID:{id} licence: {licence_url}")
headers = auth.make_headers(auth.read_auth())
headers["cookie"] = auth.get_cookies()
auth.create_sign(licence_url, headers)
headers = auth_requests.make_headers(auth_file.read_auth())
headers["cookie"] = auth_requests.get_cookies()
auth_requests.create_sign(licence_url, headers)
json_data = {
"license": licence_url,
"headers": json.dumps(headers),
Expand Down Expand Up @@ -151,9 +152,9 @@ async def key_helper_cdrm2(c, pssh, licence_url, id):
try:
log.debug(f"ID:{id} pssh: {pssh!=None}")
log.debug(f"ID:{id} licence: {licence_url}")
headers = auth.make_headers(auth.read_auth())
headers["cookie"] = auth.get_cookies()
auth.create_sign(licence_url, headers)
headers = auth_requests.make_headers(auth_file.read_auth())
headers["cookie"] = auth_requests.get_cookies()
auth_requests.create_sign(licence_url, headers)
json_data = {
"license": licence_url,
"headers": json.dumps(headers),
Expand Down Expand Up @@ -201,9 +202,9 @@ async def key_helper_keydb(c, pssh, licence_url, id):
try:
log.debug(f"ID:{id} pssh: {pssh!=None}")
log.debug(f"ID:{id} licence: {licence_url}")
headers = auth.make_headers(auth.read_auth())
headers["cookie"] = auth.get_cookies()
auth.create_sign(licence_url, headers)
headers = auth_requests.make_headers(auth_file.read_auth())
headers["cookie"] = auth_requests.get_cookies()
auth_requests.create_sign(licence_url, headers)
json_data = {
"license_url": licence_url,
"headers": json.dumps(headers),
Expand Down
17 changes: 9 additions & 8 deletions ofscraper/prompts/prompt_groups/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,38 @@ def auth_prompt(auth) -> dict:
"type": "input",
"name": "sess",
"message": "Enter your sess cookie:",
"default": auth["sess"],
"default": auth["sess"] or "",
"validate": EmptyInputValidator(),
"multiline": True,
},
{
"type": "input",
"name": "auth_id",
"message": "Enter your auth_id cookie:",
"default": auth["auth_id"],
"default": auth["auth_id"] or "",
"validate": EmptyInputValidator(),
"multiline": True,
},
{
"type": "input",
"name": "auth_uid_",
"message": "Enter your auth_uid cookie (can be left blank if you don't use 2FA):",
"default": auth["auth_uid_"],
"default": auth["auth_uid_"] or "",
"multiline": True,
},
{
"type": "input",
"name": "user_agent",
"message": "Enter your `user agent`:",
"default": auth["user_agent"],
"default": auth["user_agent"] or "",
"validate": EmptyInputValidator(),
"multiline": True,
},
{
"type": "input",
"name": "x-bc",
"message": "Enter your `x-bc` token:",
"default": auth["x-bc"],
"default": auth["x-bc"] or "",
"validate": EmptyInputValidator(),
"multiline": True,
},
Expand Down Expand Up @@ -185,7 +185,7 @@ def user_agent_prompt(current):
"type": "input",
"name": name,
"message": "Enter User_Agent from browser",
"default": current,
"default": current or "",
"validate": EmptyInputValidator(),
"filter": lambda x: prompt_validators.cleanTextInput(x),
}
Expand All @@ -194,7 +194,7 @@ def user_agent_prompt(current):
return questions[name]


def xbc_prompt():
def xbc_prompt(xbc):
name = "input"
questions = promptClasses.batchConverter(
*[
Expand All @@ -205,6 +205,7 @@ def xbc_prompt():
"instruction": f"\nGo to browser network tools to view\nFor more instructions visit https://github.com/datawhores/ofscraper\n\n",
"validate": EmptyInputValidator(),
"filter": lambda x: prompt_validators.cleanTextInput(x),
"default": xbc or "",
}
]
)
Expand All @@ -228,7 +229,7 @@ def auth_full_paste():
}
]
)
return questions[name]
return questions[name]["auth"]


def reset_auth_prompt() -> bool:
Expand Down
4 changes: 2 additions & 2 deletions ofscraper/prompts/prompt_groups/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,8 @@ def reset_config_prompt() -> bool:
"message": "How do you want to fix this issue",
"choices": [
Choice("reset", "Reset Default"),
Choice("manual", "Through script Edit Config"),
Choice("again", "File was fixed manually"),
Choice("manual", "Edit Config manually with script"),
Choice("again", "File was fixed manually via text editor"),
],
}
]
Expand Down
2 changes: 1 addition & 1 deletion ofscraper/runner/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def main():
systemSet()
args_loader()
setdate()
setLogger()
readConfig()
setLogger()
make_folder()
run.main()
except Exception as E:
Expand Down
Loading

0 comments on commit c520a52

Please sign in to comment.