Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Twint
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
Twint
Commits
652fe03a
Commit
652fe03a
authored
Nov 11, 2018
by
andytnt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added DB history for users
parent
499f070f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
25 deletions
+17
-25
twint/storage/db.py
twint/storage/db.py
+17
-25
No files found.
twint/storage/db.py
View file @
652fe03a
import
sqlite3
import
sqlite3
import
sys
import
sys
import
time
import
time
import
hashlib
def
Conn
(
database
):
def
Conn
(
database
):
if
database
:
if
database
:
...
@@ -40,8 +41,9 @@ def init(db):
...
@@ -40,8 +41,9 @@ def init(db):
verified integer not null,
verified integer not null,
profile_image_url text not null,
profile_image_url text not null,
background_image text,
background_image text,
hex_dig text not null,
time_update integer not null,
time_update integer not null,
CONSTRAINT users_pk PRIMARY KEY (id)
CONSTRAINT users_pk PRIMARY KEY (id
, hex_dig
)
);
);
"""
"""
cursor
.
execute
(
table_users
)
cursor
.
execute
(
table_users
)
...
@@ -181,37 +183,27 @@ def follow(conn, Username, Followers, User):
...
@@ -181,37 +183,27 @@ def follow(conn, Username, Followers, User):
except
sqlite3
.
IntegrityError
:
except
sqlite3
.
IntegrityError
:
pass
pass
def
get_
user
_id
(
conn
,
id
):
def
get_
hash
_id
(
conn
,
id
):
cursor
=
conn
.
cursor
()
cursor
=
conn
.
cursor
()
cursor
.
execute
(
'SELECT
id
FROM users WHERE id = ? LIMIT 1'
,
(
id
,))
cursor
.
execute
(
'SELECT
hex_dig
FROM users WHERE id = ? LIMIT 1'
,
(
id
,))
resultset
=
cursor
.
fetchall
()
resultset
=
cursor
.
fetchall
()
return
resultset
[
0
][
0
]
if
resultset
else
-
1
return
resultset
[
0
][
0
]
if
resultset
else
-
1
def
user
(
conn
,
config
,
User
):
def
user
(
conn
,
config
,
User
):
try
:
try
:
time_ms
=
round
(
time
.
time
()
*
1000
)
time_ms
=
round
(
time
.
time
()
*
1000
)
cursor
=
conn
.
cursor
()
cursor
=
conn
.
cursor
()
entry
=
(
int
(
User
.
id
),
user
=
[
int
(
User
.
id
),
User
.
id
,
User
.
name
,
User
.
username
,
User
.
bio
,
User
.
location
,
User
.
url
,
User
.
join_date
,
User
.
join_time
,
User
.
tweets
,
User
.
following
,
User
.
followers
,
User
.
likes
,
User
.
media_count
,
User
.
is_private
,
User
.
is_verified
,
User
.
avatar
,
User
.
background_image
]
User
.
id
,
User
.
name
,
hex_dig
=
hashlib
.
sha256
(
','
.
join
(
str
(
v
)
for
v
in
user
)
.
encode
())
.
hexdigest
()
User
.
username
,
entry
=
tuple
(
user
)
+
(
hex_dig
,
time_ms
,)
User
.
bio
,
old_hash
=
get_hash_id
(
conn
,
User
.
id
)
User
.
location
,
User
.
url
,
if
old_hash
==
-
1
or
old_hash
!=
hex_dig
:
User
.
join_date
,
query
=
f
"INSERT INTO users VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
User
.
join_time
,
cursor
.
execute
(
query
,
entry
)
User
.
tweets
,
else
:
User
.
following
,
pass
User
.
followers
,
User
.
likes
,
User
.
media_count
,
User
.
is_private
,
User
.
is_verified
,
User
.
avatar
,
User
.
background_image
,
time_ms
)
query
=
f
"INSERT INTO users VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
cursor
.
execute
(
query
,
entry
)
if
config
.
Followers
or
config
.
Following
:
if
config
.
Followers
or
config
.
Following
:
table
=
uTable
(
config
.
Followers
)
table
=
uTable
(
config
.
Followers
)
...
...
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