Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
shadowban-eu-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
shadowban-eu-backend
Commits
8bb79d90
Commit
8bb79d90
authored
Aug 24, 2019
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix conversion error
parent
84468a3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
backend.py
backend.py
+19
-18
No files found.
backend.py
View file @
8bb79d90
...
...
@@ -139,20 +139,16 @@ class TwitterSession:
async
def
get
(
self
,
url
,
retries
=
0
):
self
.
set_csrf_header
()
try
:
async
with
self
.
_session
.
get
(
url
,
headers
=
self
.
_headers
)
as
r
:
result
=
await
r
.
json
()
self
.
monitor_rate_limit
(
r
.
headers
)
if
self
.
username
is
None
and
self
.
remaining
<
10
or
is_error
(
result
,
88
):
await
self
.
login_guest
()
if
retries
>
0
and
is_error
(
result
,
353
):
return
await
self
.
get
(
url
,
retries
-
1
)
if
is_error
(
result
,
326
):
self
.
locked
=
True
return
result
except
DisconnectedError
:
if
self
.
username
is
None
:
self
.
login_guest
()
async
with
self
.
_session
.
get
(
url
,
headers
=
self
.
_headers
)
as
r
:
result
=
await
r
.
json
()
self
.
monitor_rate_limit
(
r
.
headers
)
if
self
.
username
is
None
and
self
.
remaining
<
10
or
is_error
(
result
,
88
):
await
self
.
login_guest
()
if
retries
>
0
and
is_error
(
result
,
353
):
return
await
self
.
get
(
url
,
retries
-
1
)
if
is_error
(
result
,
326
):
self
.
locked
=
True
return
result
async
def
search_raw
(
self
,
query
,
live
=
True
):
additional_query
=
""
...
...
@@ -180,10 +176,15 @@ class TwitterSession:
def
monitor_rate_limit
(
self
,
headers
):
# store last remaining count for reset detection
last_remaining
=
self
.
remaining
self
.
limit
=
int
(
headers
.
get
(
'x-rate-limit-limit'
,
-
1
))
self
.
remaining
=
int
(
headers
.
get
(
'x-rate-limit-remaining'
,
-
1
))
self
.
reset
=
int
(
headers
.
get
(
'x-rate-limit-reset'
,
-
1
))
limit
=
headers
.
get
(
'x-rate-limit-limit'
,
None
)
remaining
=
headers
.
get
(
'x-rate-limit-remaining'
,
None
)
reset
=
headers
.
get
(
'x-rate-limit-reset'
,
None
)
if
limit
is
not
None
:
self
.
limit
=
int
(
limit
)
if
remaining
is
not
None
:
self
.
remaining
=
int
(
remaining
)
if
reset
is
not
None
:
self
.
reset
=
int
(
reset
)
# rate limit reset
if
last_remaining
<
self
.
remaining
and
self
.
overshot
>
0
and
self
.
username
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment