funky 0.2.11 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cb6573c5c4307f5428f7f8d49bc59d61725e580
4
- data.tar.gz: 93da0ce27c0889babb4223e6556ea0fcb0339ebe
3
+ metadata.gz: 5b9e7b186a308ef63690c433f2ddb60bbcb8fa27
4
+ data.tar.gz: eedf7241ecaab8a243db77a2fbeceaaf7820049d
5
5
  SHA512:
6
- metadata.gz: 1a8f7d9df7a690ab1023d9d9fdd716d163d56bd08df5d1fa58f0088cb26ca96c8963e690f178032ad67dee51e517c0d373c33a34b76043a30f22fe934d317842
7
- data.tar.gz: 94e59a9cc3537e5521782033bb3f38b395911daa2fe397747cfa9bf3e787e775fe7d459fe018134233011e7719923c23c96337c03479815065e63a7ea1ceb758
6
+ metadata.gz: 21ee4481dd2049a91ea7a18c6e86ca1d5e0c840dfb93e00522b30e3661145aebff2970276a7e1b3011daec293eef47cb97e61888b30bb3b570a97b0cfe33dc58
7
+ data.tar.gz: 493e943f7097cfbb4d955a8317add67ce3540351485354d5b28fca529847fd918f993541ad069a2b7858b8bffb3bf7a1e4b2e73b132d9ce4251dd7cfd4b80651
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.2.12 - 2017/01/19
10
+
11
+ * [ENHANCEMENT] Parse new format of share & comment count in Facebook HTML
12
+ * [BUGFIX] Fix regular expression for likecount
13
+
9
14
  ## 0.2.11 - 2017/01/19
10
15
 
11
16
  * [ENHANCEMENT] Follow redirects when Facebook responds with 302
@@ -2,34 +2,40 @@ module Funky
2
2
  # @api private
3
3
  module HTML
4
4
  class Parser
5
- def parse(html:)
5
+ def parse(html:, video_id:)
6
6
  {
7
7
  view_count: extract_views_from(html),
8
- share_count: extract_shares_from(html),
8
+ share_count: extract_shares_from(html, video_id),
9
9
  like_count: extract_likes_from(html),
10
- comment_count: extract_comments_from(html)
10
+ comment_count: extract_comments_from(html, video_id)
11
11
  }
12
12
  end
13
13
 
14
- def extract_shares_from(html)
14
+ def extract_shares_from(html, video_id)
15
15
  html.match(/"sharecount":(.*?),/)
16
+ html.match(/sharecount:(\d+),sharecountreduced/) if $1.nil?
17
+ html.match(/sharecount:(\d+),.*sharefbid:"#{video_id}"/) if $1.nil?
16
18
  matched_count $1
17
19
  end
18
20
 
19
21
  def extract_views_from(html)
20
22
  html.match(/<div><\/div><span class="fcg">\D*([\d,.]+)/)
21
23
  html.match %r{([\d,.]*?) views from this post} if $1.nil?
22
- html.match /<div class=\"_1vx9\"><span>([\d,.]*?) Views<\/span><\/div>/ if $1.nil?
24
+ html.match /<div class=\"_1vx9\"><span>([\d,.]*?) .*?<\/span><\/div>/ if $1.nil?
25
+ html.match(/postViewCount:"([\d,.]*?)",/) if $1.nil?
23
26
  matched_count $1
24
27
  end
25
28
 
26
29
  def extract_likes_from(html)
27
30
  html.match(/"likecount":(\d+),"likecountreduced"/)
31
+ html.match(/likecount:(\d+),likecountreduced/) if $1.nil?
28
32
  matched_count $1
29
33
  end
30
34
 
31
- def extract_comments_from(html)
35
+ def extract_comments_from(html, video_id)
32
36
  html.match /"commentcount":(.*?),/
37
+ html.match(/commentcount:(\d+),commentcountreduced/) if $1.nil?
38
+ html.match /commentcount:(\d+),.*commentstargetfbid:"#{video_id}"/ if $1.nil?
33
39
  matched_count $1
34
40
  end
35
41
 
data/lib/funky/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Funky
2
- VERSION = "0.2.11"
2
+ VERSION = "0.2.12"
3
3
  end
data/lib/funky/video.rb CHANGED
@@ -101,7 +101,7 @@ module Funky
101
101
  # @return [Funky::Video] the data scraped from Facebook's HTML
102
102
  # and encapsulated into a Funky::Video object.
103
103
  def self.find(video_id)
104
- counters = @@html_parser.parse html: @@html_page.get(video_id: video_id)
104
+ counters = @@html_parser.parse html: @@html_page.get(video_id: video_id), video_id: video_id
105
105
  new counters.merge(id: video_id)
106
106
  end
107
107
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Nguyen