Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
twitter_syncer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
twitter_syncer
Commits
2b2c3b48
Commit
2b2c3b48
authored
Mar 31, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
db94164e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
18 deletions
+64
-18
main.go
cmd/manual/main.go
+60
-17
idx.go
core/idx.go
+4
-1
No files found.
cmd/manual/main.go
View file @
2b2c3b48
...
...
@@ -58,48 +58,91 @@ func manual(name string, bee string, sync_all bool) {
}
taskUser
:=
core
.
UserObjectToUserTask
(
users
)
slog
.
Info
(
"GetFollowerList"
,
"task id"
,
todoTask
.
TaskId
,
"cursor"
,
cursor
,
"len(users)"
,
len
(
users
),
"newCursor"
,
newCursor
)
if
(
cursor
!=
""
&&
newCursor
==
""
)
||
(
cursor
!=
""
&&
newCursor
==
"0"
)
{
slog
.
Info
(
"Get all followers finished"
)
l
:=
page
.
GetIdx
()
.
List
ok
,
l
:=
page
.
GetIdx
()
.
Idx
(
taskUser
)
if
ok
{
res
:=
make
([]
core
.
UserTask
,
0
,
l
.
Len
())
for
e
:=
l
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
if
user
,
ok
:=
e
.
Value
.
(
core
.
UserTask
);
ok
{
res
=
append
(
res
,
user
)
}
}
// save it to json file.
d
,
_
:=
json
.
MarshalIndent
(
res
,
""
,
" "
)
filename
:=
fmt
.
Sprintf
(
"follower-%s.json"
,
todoTask
.
TaskId
)
err
=
os
.
WriteFile
(
filename
,
d
,
0644
)
if
err
!=
nil
{
slog
.
Error
(
"write followers"
,
"err"
,
err
.
Error
())
}
else
{
slog
.
Info
(
"write followers"
,
"task id"
,
todoTask
.
TaskId
,
"len(users)"
,
len
(
res
))
}
if
err
:=
core
.
InsertTaskRes
(
res
,
todoTask
.
TaskType
,
todoTask
.
TaskId
);
err
!=
nil
{
slog
.
Error
(
"InsertTaskRes"
,
"task id"
,
todoTask
.
TaskId
,
"t.TaskType"
,
todoTask
.
TaskType
,
"len(users)"
,
len
(
users
),
"err"
,
err
.
Error
())
}
else
{
slog
.
Info
(
"InsertTaskRes"
,
"task id"
,
todoTask
.
TaskId
,
"len(users)"
,
len
(
res
))
}
return
}
else
{
ok
,
l
:=
page
.
GetIdx
()
.
Idx
(
taskUser
)
if
ok
{
if
newCursor
==
""
||
newCursor
==
"0"
{
// all followers are found.
slog
.
Info
(
"Get all followers finished"
)
l
:=
page
.
GetIdx
()
.
List
res
:=
make
([]
core
.
UserTask
,
0
,
l
.
Len
())
for
e
:=
l
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
if
user
,
ok
:=
e
.
Value
.
(
core
.
UserTask
);
ok
{
res
=
append
(
res
,
user
)
}
}
// save it to json file.
d
,
_
:=
json
.
MarshalIndent
(
res
,
""
,
" "
)
filename
:=
fmt
.
Sprintf
(
"follower-%s.json"
,
todoTask
.
TaskId
)
err
=
os
.
WriteFile
(
filename
,
d
,
0644
)
if
err
!=
nil
{
slog
.
Error
(
"write followers"
,
"err"
,
err
.
Error
())
}
else
{
slog
.
Info
(
"write followers"
,
"task id"
,
todoTask
.
TaskId
,
"len(users)"
,
len
(
res
))
}
if
err
:=
core
.
InsertTaskRes
(
res
,
todoTask
.
TaskType
,
todoTask
.
TaskId
);
err
!=
nil
{
slog
.
Error
(
"InsertTaskRes"
,
"task id"
,
todoTask
.
TaskId
,
"t.TaskType"
,
todoTask
.
TaskType
,
"len(users)"
,
len
(
users
),
"err"
,
err
.
Error
())
}
else
{
slog
.
Info
(
"InsertTaskRes"
,
"task id"
,
todoTask
.
TaskId
,
"len(users)"
,
len
(
res
))
}
return
}
}
//if (cursor != "" && newCursor == "") || (cursor != "" && newCursor == "0") {
// slog.Info("Get all followers finished")
// l := page.GetIdx().List
// res := make([]core.UserTask, 0, l.Len())
// for e := l.Front(); e != nil; e = e.Next() {
// if user, ok := e.Value.(core.UserTask); ok {
// res = append(res, user)
// }
// }
// // save it to json file.
// d, _ := json.MarshalIndent(res, "", " ")
// filename := fmt.Sprintf("follower-%s.json", todoTask.TaskId)
// err = os.WriteFile(filename, d, 0644)
// if err != nil {
// slog.Error("write followers", "err", err.Error())
// } else {
// slog.Info("write followers", "task id", todoTask.TaskId, "len(users)", len(res))
// }
//
// if err := core.InsertTaskRes(res, todoTask.TaskType, todoTask.TaskId); err != nil {
// slog.Error("InsertTaskRes", "task id", todoTask.TaskId,
// "t.TaskType", todoTask.TaskType, "len(users)", len(users), "err", err.Error())
// }
// return
//} else {
// ok, l := page.GetIdx().Idx(taskUser)
// if ok {
// res := make([]core.UserTask, 0, l.Len())
// for e := l.Front(); e != nil; e = e.Next() {
// if user, ok := e.Value.(core.UserTask); ok {
// res = append(res, user)
// }
// }
// if err := core.InsertTaskRes(res, todoTask.TaskType, todoTask.TaskId); err != nil {
// slog.Error("InsertTaskRes", "task id", todoTask.TaskId,
// "t.TaskType", todoTask.TaskType, "len(users)", len(users), "err", err.Error())
// } else {
// slog.Info("InsertTaskRes", "task id", todoTask.TaskId, "len(users)", len(res))
// }
// return
// }
//}
if
newCursor
==
""
||
newCursor
==
"0"
{
break
...
...
core/idx.go
View file @
2b2c3b48
...
...
@@ -35,6 +35,9 @@ func NewIdx(i []UserTask) *Idx {
}
func
(
s
*
Idx
)
Idx
(
page
[]
UserTask
)
(
bool
,
*
list
.
List
)
{
if
len
(
page
)
==
0
{
return
false
,
nil
}
if
s
.
idx
!=
nil
&&
len
(
s
.
idx
)
==
0
{
...
...
@@ -61,7 +64,7 @@ func (s *Idx) Idx(page []UserTask) (bool, *list.List) {
}
}
if
!
match
{
newItems
.
Push
Front
(
v
)
newItems
.
Push
Back
(
v
)
}
else
{
// stop, all new items has added to newItems.
break
...
...
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