fbcrawl-colly 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,10 +18,7 @@ const _ = grpc.SupportPackageIsVersion6
18
18
  // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
19
19
  type GrpcClient interface {
20
20
  // Sends a greeting
21
- Init(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Pointer, error)
22
- FreeColly(ctx context.Context, in *Pointer, opts ...grpc.CallOption) (*Empty, error)
23
21
  Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
24
- LoginWithCookies(ctx context.Context, in *LoginWithCookiesRequest, opts ...grpc.CallOption) (*Empty, error)
25
22
  FetchGroupInfo(ctx context.Context, in *FetchGroupInfoRequest, opts ...grpc.CallOption) (*FacebookGroup, error)
26
23
  FetchUserInfo(ctx context.Context, in *FetchUserInfoRequest, opts ...grpc.CallOption) (*FacebookUser, error)
27
24
  FetchGroupFeed(ctx context.Context, in *FetchGroupFeedRequest, opts ...grpc.CallOption) (*FacebookPostList, error)
@@ -38,24 +35,6 @@ func NewGrpcClient(cc grpc.ClientConnInterface) GrpcClient {
38
35
  return &grpcClient{cc}
39
36
  }
40
37
 
41
- func (c *grpcClient) Init(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Pointer, error) {
42
- out := new(Pointer)
43
- err := c.cc.Invoke(ctx, "/fbcrawl_colly.Grpc/Init", in, out, opts...)
44
- if err != nil {
45
- return nil, err
46
- }
47
- return out, nil
48
- }
49
-
50
- func (c *grpcClient) FreeColly(ctx context.Context, in *Pointer, opts ...grpc.CallOption) (*Empty, error) {
51
- out := new(Empty)
52
- err := c.cc.Invoke(ctx, "/fbcrawl_colly.Grpc/FreeColly", in, out, opts...)
53
- if err != nil {
54
- return nil, err
55
- }
56
- return out, nil
57
- }
58
-
59
38
  func (c *grpcClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
60
39
  out := new(LoginResponse)
61
40
  err := c.cc.Invoke(ctx, "/fbcrawl_colly.Grpc/Login", in, out, opts...)
@@ -65,15 +44,6 @@ func (c *grpcClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.C
65
44
  return out, nil
66
45
  }
67
46
 
68
- func (c *grpcClient) LoginWithCookies(ctx context.Context, in *LoginWithCookiesRequest, opts ...grpc.CallOption) (*Empty, error) {
69
- out := new(Empty)
70
- err := c.cc.Invoke(ctx, "/fbcrawl_colly.Grpc/LoginWithCookies", in, out, opts...)
71
- if err != nil {
72
- return nil, err
73
- }
74
- return out, nil
75
- }
76
-
77
47
  func (c *grpcClient) FetchGroupInfo(ctx context.Context, in *FetchGroupInfoRequest, opts ...grpc.CallOption) (*FacebookGroup, error) {
78
48
  out := new(FacebookGroup)
79
49
  err := c.cc.Invoke(ctx, "/fbcrawl_colly.Grpc/FetchGroupInfo", in, out, opts...)
@@ -133,10 +103,7 @@ func (c *grpcClient) FetchImageUrl(ctx context.Context, in *FetchImageUrlRequest
133
103
  // for forward compatibility
134
104
  type GrpcServer interface {
135
105
  // Sends a greeting
136
- Init(context.Context, *Empty) (*Pointer, error)
137
- FreeColly(context.Context, *Pointer) (*Empty, error)
138
106
  Login(context.Context, *LoginRequest) (*LoginResponse, error)
139
- LoginWithCookies(context.Context, *LoginWithCookiesRequest) (*Empty, error)
140
107
  FetchGroupInfo(context.Context, *FetchGroupInfoRequest) (*FacebookGroup, error)
141
108
  FetchUserInfo(context.Context, *FetchUserInfoRequest) (*FacebookUser, error)
142
109
  FetchGroupFeed(context.Context, *FetchGroupFeedRequest) (*FacebookPostList, error)
@@ -150,18 +117,9 @@ type GrpcServer interface {
150
117
  type UnimplementedGrpcServer struct {
151
118
  }
152
119
 
153
- func (*UnimplementedGrpcServer) Init(context.Context, *Empty) (*Pointer, error) {
154
- return nil, status.Errorf(codes.Unimplemented, "method Init not implemented")
155
- }
156
- func (*UnimplementedGrpcServer) FreeColly(context.Context, *Pointer) (*Empty, error) {
157
- return nil, status.Errorf(codes.Unimplemented, "method FreeColly not implemented")
158
- }
159
120
  func (*UnimplementedGrpcServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) {
160
121
  return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
161
122
  }
162
- func (*UnimplementedGrpcServer) LoginWithCookies(context.Context, *LoginWithCookiesRequest) (*Empty, error) {
163
- return nil, status.Errorf(codes.Unimplemented, "method LoginWithCookies not implemented")
164
- }
165
123
  func (*UnimplementedGrpcServer) FetchGroupInfo(context.Context, *FetchGroupInfoRequest) (*FacebookGroup, error) {
166
124
  return nil, status.Errorf(codes.Unimplemented, "method FetchGroupInfo not implemented")
167
125
  }
@@ -186,42 +144,6 @@ func RegisterGrpcServer(s *grpc.Server, srv GrpcServer) {
186
144
  s.RegisterService(&_Grpc_serviceDesc, srv)
187
145
  }
188
146
 
189
- func _Grpc_Init_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
190
- in := new(Empty)
191
- if err := dec(in); err != nil {
192
- return nil, err
193
- }
194
- if interceptor == nil {
195
- return srv.(GrpcServer).Init(ctx, in)
196
- }
197
- info := &grpc.UnaryServerInfo{
198
- Server: srv,
199
- FullMethod: "/fbcrawl_colly.Grpc/Init",
200
- }
201
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
202
- return srv.(GrpcServer).Init(ctx, req.(*Empty))
203
- }
204
- return interceptor(ctx, in, info, handler)
205
- }
206
-
207
- func _Grpc_FreeColly_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
208
- in := new(Pointer)
209
- if err := dec(in); err != nil {
210
- return nil, err
211
- }
212
- if interceptor == nil {
213
- return srv.(GrpcServer).FreeColly(ctx, in)
214
- }
215
- info := &grpc.UnaryServerInfo{
216
- Server: srv,
217
- FullMethod: "/fbcrawl_colly.Grpc/FreeColly",
218
- }
219
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
220
- return srv.(GrpcServer).FreeColly(ctx, req.(*Pointer))
221
- }
222
- return interceptor(ctx, in, info, handler)
223
- }
224
-
225
147
  func _Grpc_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
226
148
  in := new(LoginRequest)
227
149
  if err := dec(in); err != nil {
@@ -240,24 +162,6 @@ func _Grpc_Login_Handler(srv interface{}, ctx context.Context, dec func(interfac
240
162
  return interceptor(ctx, in, info, handler)
241
163
  }
242
164
 
243
- func _Grpc_LoginWithCookies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
244
- in := new(LoginWithCookiesRequest)
245
- if err := dec(in); err != nil {
246
- return nil, err
247
- }
248
- if interceptor == nil {
249
- return srv.(GrpcServer).LoginWithCookies(ctx, in)
250
- }
251
- info := &grpc.UnaryServerInfo{
252
- Server: srv,
253
- FullMethod: "/fbcrawl_colly.Grpc/LoginWithCookies",
254
- }
255
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
256
- return srv.(GrpcServer).LoginWithCookies(ctx, req.(*LoginWithCookiesRequest))
257
- }
258
- return interceptor(ctx, in, info, handler)
259
- }
260
-
261
165
  func _Grpc_FetchGroupInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
262
166
  in := new(FetchGroupInfoRequest)
263
167
  if err := dec(in); err != nil {
@@ -370,22 +274,10 @@ var _Grpc_serviceDesc = grpc.ServiceDesc{
370
274
  ServiceName: "fbcrawl_colly.Grpc",
371
275
  HandlerType: (*GrpcServer)(nil),
372
276
  Methods: []grpc.MethodDesc{
373
- {
374
- MethodName: "Init",
375
- Handler: _Grpc_Init_Handler,
376
- },
377
- {
378
- MethodName: "FreeColly",
379
- Handler: _Grpc_FreeColly_Handler,
380
- },
381
277
  {
382
278
  MethodName: "Login",
383
279
  Handler: _Grpc_Login_Handler,
384
280
  },
385
- {
386
- MethodName: "LoginWithCookies",
387
- Handler: _Grpc_LoginWithCookies_Handler,
388
- },
389
281
  {
390
282
  MethodName: "FetchGroupInfo",
391
283
  Handler: _Grpc_FetchGroupInfo_Handler,
data/go.mod CHANGED
@@ -13,6 +13,5 @@ require (
13
13
  github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119
14
14
  golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
15
15
  google.golang.org/grpc v1.27.0
16
- google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200814200710-a3740e5ed326 // indirect
17
16
  google.golang.org/protobuf v1.25.0
18
17
  )
data/go.sum CHANGED
@@ -127,9 +127,6 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
127
127
  google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
128
128
  google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
129
129
  google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
130
- google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI=
131
- google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200814200710-a3740e5ed326 h1:9xXKDULLQoff9XAN3whAGrh4vrLLvydDbmFGWofOWI0=
132
- google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200814200710-a3740e5ed326/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
133
130
  google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
134
131
  google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
135
132
  google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -4,45 +4,45 @@ module FbcrawlColly
4
4
  def initialize(host_and_port)
5
5
  @host_and_port = host_and_port
6
6
  @client = new_grpc_client
7
- @colly = @client.init(FbcrawlColly::Empty.new)
8
-
9
- ObjectSpace.define_finalizer(self) do
10
- new_grpc_client.free_colly(@colly)
11
- end
7
+ @context = nil
12
8
  end
13
9
 
14
10
  def login(email, password, totp_secret = "")
15
- s = @client.login(FbcrawlColly::LoginRequest.new(pointer: @colly, email: email, password: password, totp_secret: totp_secret)).cookies
11
+ cookies = @client.login(FbcrawlColly::LoginRequest.new(email: email, password: password, totp_secret: totp_secret)).cookies
12
+ @context = FbcrawlColly::Context.new(cookies: cookies)
13
+ cookies
16
14
  end
17
15
 
18
16
  def login_with_cookies(cookies)
19
- s = @client.login_with_cookies(FbcrawlColly::LoginWithCookiesRequest.new(pointer: @colly, cookies: cookies))
17
+ @context = FbcrawlColly::Context.new(cookies: cookies)
20
18
  end
21
19
 
22
20
  def fetch_user_info(username)
23
- s = @client.fetch_user_info(FbcrawlColly::FetchUserInfoRequest.new(pointer: @colly, username: username))
21
+ s = @client.fetch_user_info(FbcrawlColly::FetchUserInfoRequest.new(context: @context, username: username))
24
22
  end
25
23
 
26
24
  def fetch_group_info(group_id_or_username)
27
- s = @client.fetch_group_info(FbcrawlColly::FetchGroupInfoRequest.new(pointer: @colly, group_username: group_id_or_username))
25
+ s = @client.fetch_group_info(FbcrawlColly::FetchGroupInfoRequest.new(context: @context, group_username: group_id_or_username))
28
26
  end
29
27
 
30
28
  def fetch_group_feed(group_id, next_cursor = nil)
31
- s = @client.fetch_group_feed(FbcrawlColly::FetchGroupFeedRequest.new(pointer: @colly, group_id: group_id, next_cursor: next_cursor))
29
+ s = @client.fetch_group_feed(FbcrawlColly::FetchGroupFeedRequest.new(context: @context, group_id: group_id, next_cursor: next_cursor))
32
30
  end
33
31
 
34
32
  def fetch_post(group_id, post_id, comment_next_cursor = nil)
35
- s = @client.fetch_post(FbcrawlColly::FetchPostRequest.new(pointer: @colly, group_id: group_id, post_id: post_id, comment_next_cursor: comment_next_cursor))
33
+ s = @client.fetch_post(FbcrawlColly::FetchPostRequest.new(context: @context, group_id: group_id, post_id: post_id, comment_next_cursor: comment_next_cursor))
36
34
  end
37
35
 
38
36
  def fetch_content_images(post_id, next_cursor = nil)
39
- s = @client.fetch_content_images(FbcrawlColly::FetchContentImagesRequest.new(pointer: @colly, post_id: post_id, next_cursor: next_cursor))
37
+ s = @client.fetch_content_images(FbcrawlColly::FetchContentImagesRequest.new(context: @context, post_id: post_id, next_cursor: next_cursor))
40
38
  end
41
39
 
42
40
  def fetch_image_url(image_id)
43
- s = @client.fetch_image_url(FbcrawlColly::FetchImageUrlRequest.new(pointer: @colly, image_id: image_id))
41
+ s = @client.fetch_image_url(FbcrawlColly::FetchImageUrlRequest.new(context: @context, image_id: image_id))
44
42
  end
43
+
45
44
  private
45
+
46
46
  def new_grpc_client
47
47
  FbcrawlColly::Grpc::Stub.new(@host_and_port, :this_channel_is_insecure)
48
48
  end
@@ -1,3 +1,3 @@
1
1
  module FbcrawlColly
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -7,11 +7,10 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
7
7
  add_file("fbcrawl.proto", :syntax => :proto3) do
8
8
  add_message "fbcrawl_colly.Empty" do
9
9
  end
10
- add_message "fbcrawl_colly.Pointer" do
11
- optional :address, :int64, 1
10
+ add_message "fbcrawl_colly.Context" do
11
+ optional :cookies, :string, 1
12
12
  end
13
13
  add_message "fbcrawl_colly.LoginRequest" do
14
- optional :pointer, :message, 1, "fbcrawl_colly.Pointer"
15
14
  optional :email, :string, 2
16
15
  optional :password, :string, 3
17
16
  optional :totp_secret, :string, 4
@@ -20,35 +19,34 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
20
19
  optional :cookies, :string, 1
21
20
  end
22
21
  add_message "fbcrawl_colly.LoginWithCookiesRequest" do
23
- optional :pointer, :message, 1, "fbcrawl_colly.Pointer"
24
- optional :cookies, :string, 2
22
+ optional :cookies, :string, 1
25
23
  end
26
24
  add_message "fbcrawl_colly.FetchGroupInfoRequest" do
27
- optional :pointer, :message, 1, "fbcrawl_colly.Pointer"
25
+ optional :context, :message, 1, "fbcrawl_colly.Context"
28
26
  optional :group_username, :string, 2
29
27
  end
30
28
  add_message "fbcrawl_colly.FetchUserInfoRequest" do
31
- optional :pointer, :message, 1, "fbcrawl_colly.Pointer"
29
+ optional :context, :message, 1, "fbcrawl_colly.Context"
32
30
  optional :username, :string, 2
33
31
  end
34
32
  add_message "fbcrawl_colly.FetchGroupFeedRequest" do
35
- optional :pointer, :message, 1, "fbcrawl_colly.Pointer"
33
+ optional :context, :message, 1, "fbcrawl_colly.Context"
36
34
  optional :group_id, :int64, 2
37
35
  optional :next_cursor, :string, 3
38
36
  end
39
37
  add_message "fbcrawl_colly.FetchPostRequest" do
40
- optional :pointer, :message, 1, "fbcrawl_colly.Pointer"
38
+ optional :context, :message, 1, "fbcrawl_colly.Context"
41
39
  optional :group_id, :int64, 2
42
40
  optional :post_id, :int64, 3
43
41
  optional :comment_next_cursor, :string, 4
44
42
  end
45
43
  add_message "fbcrawl_colly.FetchContentImagesRequest" do
46
- optional :pointer, :message, 1, "fbcrawl_colly.Pointer"
44
+ optional :context, :message, 1, "fbcrawl_colly.Context"
47
45
  optional :post_id, :int64, 2
48
46
  optional :next_cursor, :string, 3
49
47
  end
50
48
  add_message "fbcrawl_colly.FetchImageUrlRequest" do
51
- optional :pointer, :message, 1, "fbcrawl_colly.Pointer"
49
+ optional :context, :message, 1, "fbcrawl_colly.Context"
52
50
  optional :image_id, :int64, 2
53
51
  end
54
52
  add_message "fbcrawl_colly.FacebookGroup" do
@@ -103,7 +101,7 @@ end
103
101
 
104
102
  module FbcrawlColly
105
103
  Empty = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("fbcrawl_colly.Empty").msgclass
106
- Pointer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("fbcrawl_colly.Pointer").msgclass
104
+ Context = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("fbcrawl_colly.Context").msgclass
107
105
  LoginRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("fbcrawl_colly.LoginRequest").msgclass
108
106
  LoginResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("fbcrawl_colly.LoginResponse").msgclass
109
107
  LoginWithCookiesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("fbcrawl_colly.LoginWithCookiesRequest").msgclass
@@ -15,10 +15,7 @@ module FbcrawlColly
15
15
  self.service_name = 'fbcrawl_colly.Grpc'
16
16
 
17
17
  # Sends a greeting
18
- rpc :Init, FbcrawlColly::Empty, FbcrawlColly::Pointer
19
- rpc :FreeColly, FbcrawlColly::Pointer, FbcrawlColly::Empty
20
18
  rpc :Login, FbcrawlColly::LoginRequest, FbcrawlColly::LoginResponse
21
- rpc :LoginWithCookies, FbcrawlColly::LoginWithCookiesRequest, FbcrawlColly::Empty
22
19
  rpc :FetchGroupInfo, FbcrawlColly::FetchGroupInfoRequest, FbcrawlColly::FacebookGroup
23
20
  rpc :FetchUserInfo, FbcrawlColly::FetchUserInfoRequest, FbcrawlColly::FacebookUser
24
21
  rpc :FetchGroupFeed, FbcrawlColly::FetchGroupFeedRequest, FbcrawlColly::FacebookPostList
data/main.go CHANGED
@@ -5,14 +5,13 @@ import (
5
5
  context "context"
6
6
  "flag"
7
7
  "github.com/google/logger"
8
- lru "github.com/hashicorp/golang-lru"
9
8
  "google.golang.org/grpc"
9
+ "io/ioutil"
10
10
  "log"
11
11
  "net"
12
12
  "os"
13
13
  "qnetwork.net/fbcrawl/fbcrawl"
14
14
  "qnetwork.net/fbcrawl/fbcrawl/pb"
15
- "unsafe"
16
15
  )
17
16
 
18
17
  const logPath = "parse.log"
@@ -23,14 +22,13 @@ var password = flag.String("password", "change_me", "facebook password")
23
22
  var otp = flag.String("otp", "123456", "facebook otp")
24
23
  var groupId = flag.String("groupId", "334294967318328", "facebook group id, default is 334294967318328")
25
24
 
26
- var allInstances, _ = lru.New(20)
27
-
28
- func getColly(pointer *pb.Pointer) *fbcolly.Fbcolly {
29
- c, ok := allInstances.Get(pointer.Address)
30
- if ok {
31
- return c.(*fbcolly.Fbcolly)
25
+ func getColly(context *pb.Context) *fbcolly.Fbcolly {
26
+ instance := fbcolly.New()
27
+ if context != nil && len(context.Cookies) > 0 {
28
+ _ = instance.LoginWithCookies(context.Cookies)
32
29
  }
33
- return nil
30
+
31
+ return instance
34
32
  }
35
33
 
36
34
  // server is used to implement helloworld.GreeterServer.
@@ -38,21 +36,8 @@ type server struct {
38
36
  pb.GrpcServer
39
37
  }
40
38
 
41
- func (s server) Init(ctx context.Context, empty *pb.Empty) (*pb.Pointer, error) {
42
- instance := fbcolly.New()
43
- ptr := (uintptr)(unsafe.Pointer(instance))
44
- allInstances.Add(int64(ptr), instance)
45
- return &pb.Pointer{Address: int64(ptr)}, nil
46
- }
47
-
48
- func (s server) FreeColly(ctx context.Context, pointer *pb.Pointer) (*pb.Empty, error) {
49
- logger.Info("FreeColly")
50
- allInstances.Remove(pointer.Address)
51
- return &pb.Empty{}, nil
52
- }
53
-
54
39
  func (s server) Login(ctx context.Context, request *pb.LoginRequest) (*pb.LoginResponse, error) {
55
- p := getColly(request.Pointer)
40
+ p := getColly(nil)
56
41
 
57
42
  cookies, err := p.Login(request.Email, request.Password, request.TotpSecret)
58
43
  if err == nil {
@@ -61,49 +46,45 @@ func (s server) Login(ctx context.Context, request *pb.LoginRequest) (*pb.LoginR
61
46
  return nil, err
62
47
  }
63
48
 
64
- func (s server) LoginWithCookies(ctx context.Context, request *pb.LoginWithCookiesRequest) (*pb.Empty, error) {
65
- p := getColly(request.Pointer)
66
- err := p.LoginWithCookies(request.Cookies)
67
- return &pb.Empty{}, err
68
- }
69
-
70
49
  func (s server) FetchGroupInfo(ctx context.Context, request *pb.FetchGroupInfoRequest) (*pb.FacebookGroup, error) {
71
- p := getColly(request.Pointer)
50
+ p := getColly(request.Context)
72
51
  err, groupInfo := p.FetchGroupInfo(request.GroupUsername)
73
52
  return groupInfo, err
74
53
  }
75
54
 
76
55
  func (s server) FetchUserInfo(ctx context.Context, request *pb.FetchUserInfoRequest) (*pb.FacebookUser, error) {
77
- p := getColly(request.Pointer)
56
+ p := getColly(request.Context)
78
57
  err, userInfo := p.FetchUserInfo(request.Username)
79
58
  return userInfo, err
80
59
  }
81
60
 
82
61
  func (s server) FetchGroupFeed(ctx context.Context, request *pb.FetchGroupFeedRequest) (*pb.FacebookPostList, error) {
83
- p := getColly(request.Pointer)
62
+ p := getColly(request.Context)
84
63
  err, postsList := p.FetchGroupFeed(request.GroupId, request.NextCursor)
85
64
  return postsList, err
86
65
  }
87
66
 
88
67
  func (s server) FetchPost(ctx context.Context, request *pb.FetchPostRequest) (*pb.FacebookPost, error) {
89
- p := getColly(request.Pointer)
68
+ p := getColly(request.Context)
90
69
  err, post := p.FetchPost(request.GroupId, request.PostId, request.CommentNextCursor)
91
70
  return post, err
92
71
  }
93
72
 
94
73
  func (s server) FetchContentImages(ctx context.Context, request *pb.FetchContentImagesRequest) (*pb.FacebookImageList, error) {
95
- p := getColly(request.Pointer)
74
+ p := getColly(request.Context)
96
75
  err, imageList := p.FetchContentImages(request.PostId, request.NextCursor)
97
76
  return imageList, err
98
77
  }
99
78
 
100
79
  func (s server) FetchImageUrl(ctx context.Context, request *pb.FetchImageUrlRequest) (*pb.FacebookImage, error) {
101
- p := getColly(request.Pointer)
80
+ p := getColly(request.Context)
102
81
  err, image := p.FetchImageUrl(request.ImageId)
103
82
  return image, err
104
83
  }
105
84
 
106
85
  func main() {
86
+ logger.Init("fb-colly", true, false, ioutil.Discard)
87
+
107
88
  port := os.Getenv("PORT")
108
89
  if len(port) == 0 {
109
90
  port = "50051"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbcrawl-colly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duy Le
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-17 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf