mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-22 11:25:49 +05:30
chore: bumped up to v0.4.2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
__version__ = '1.2.2'
|
||||
__version__ = '1.3.0'
|
||||
|
||||
import abc
|
||||
import json
|
||||
@@ -52,28 +52,32 @@ class BgUtilPTPBase(PoTokenProvider, abc.ABC):
|
||||
def _get_attestation(self, webpage: str | None):
|
||||
if not webpage:
|
||||
return None
|
||||
raw_challenge_data = self.ie._search_regex(
|
||||
r'''(?sx)window\.ytAtR\s*=\s*(?P<raw_cd>(?P<q>['"])
|
||||
(?:
|
||||
\\.|
|
||||
(?!(?P=q)).
|
||||
)*
|
||||
(?P=q))\s*;''',
|
||||
webpage,
|
||||
'raw challenge data',
|
||||
default=None,
|
||||
group='raw_cd',
|
||||
)
|
||||
att_txt = traverse_obj(
|
||||
raw_challenge_data,
|
||||
({js_to_json}, {json.loads}, {json.loads}, 'bgChallenge')
|
||||
)
|
||||
if not att_txt:
|
||||
self.logger.warning(
|
||||
'Failed to extract initial attestation from the webpage'
|
||||
)
|
||||
return None
|
||||
return att_txt
|
||||
raw_cd = (
|
||||
traverse_obj(
|
||||
self.ie._search_regex(
|
||||
r'''(?sx)window\s*\.\s*ytAtN\s*\(\s*
|
||||
(?P<js>\{.+?}\s*)
|
||||
\s*\)\s*;''',
|
||||
webpage,
|
||||
'ytAtN challenge',
|
||||
default=None),
|
||||
({js_to_json}, {json.loads}, 'R'))
|
||||
or traverse_obj(
|
||||
self.ie._search_regex(
|
||||
r'''(?sx)window\.ytAtR\s*=\s*(?P<raw_cd>(?P<q>['"])
|
||||
(?:
|
||||
\\.|
|
||||
(?!(?P=q)).
|
||||
)*
|
||||
(?P=q))\s*;''',
|
||||
webpage,
|
||||
'ytAtR challenge',
|
||||
default=None),
|
||||
({js_to_json}, {json.loads})))
|
||||
if att_txt := traverse_obj(raw_cd, ({json.loads}, 'bgChallenge')):
|
||||
return att_txt
|
||||
self.logger.warning('Failed to extract initial attestation from the webpage')
|
||||
return None
|
||||
|
||||
|
||||
__all__ = ['__version__']
|
||||
|
||||
Reference in New Issue
Block a user