nullscreen / fb-video

Funky is a Ruby library to fetch data about videos posted on Facebook.
MIT License
7 stars 6 forks source link

Video Views is always nil #47

Closed himberjack closed 8 years ago

himberjack commented 8 years ago

I think something is broken in the regex

claudiofullscreen commented 8 years ago

Hello and thanks for stopping by!

Could you provide more context? What video are you using? Or what snippet of code?

Thanks 🎀

himberjack commented 8 years ago

Just run your video IDs example. they are always nil, so are other video IDs im trying

On Wed, Jun 22, 2016 at 5:46 PM, claudiofullscreen <notifications@github.com

wrote:

Hello and thanks for stopping by!

Could you provide more context? What video are you using? Or what snippet of code?

Thanks 🎀

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Fullscreen/funky/issues/47#issuecomment-227767371, or mute the thread https://github.com/notifications/unsubscribe/AC_t8TOki6R6lyrqnax9XX5qtjiXsYInks5qOUrFgaJpZM4I7fcE .

claudiofullscreen commented 8 years ago

Could you copy/paste here the snippet of code and its result (without any private key/secret)? That would help us debug the issue. Thanks!

himberjack commented 8 years ago

just try any video 2.2.3 :002 > Funky::Video.find('10154439119663508') => #<Funky::Video:0x007fe041953f48 @data={:view_count=>nil, :share_count=>425, :like_count=>1169, :comment_count=>65, :id=>"10154439119663508"}>

On Wed, Jun 22, 2016 at 5:50 PM, claudiofullscreen <notifications@github.com

wrote:

Could you copy/paste here the snippet of code and its result (without any private key/secret)? That would help us debug the issue. Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Fullscreen/funky/issues/47#issuecomment-227768816, or mute the thread https://github.com/notifications/unsubscribe/AC_t8f4ltjmbEic2QxvVxDPq5vv27HXCks5qOUvNgaJpZM4I7fcE .

claudiofullscreen commented 8 years ago

Thanks for your help!

I ran the same command 30 times and I always get the view count (33765).

Therefore, I believe what is happening is that Facebook is serving different pages for the same video, probably based on our different locations or some internal A/B testing.

To help us debug the issue, could you run the following command and then attach the resulting file to this issue? curl "https://www.facebook.com/video.php?v=10154439119663508" > 10154439119663508.txt

For completeness, this is the page that we get: 10154439119663508.txt

himberjack commented 8 years ago

10154439119663508.txt

himberjack commented 8 years ago

You are right. from the USA I indeed get views. From Israel I dont - even though in the browser I can see it. the HTML is different markup

claudiofullscreen commented 8 years ago

😞 In this case, all we can do is to add a disclaimer in the README or raise some error if the metric is not available.

himberjack commented 8 years ago

Why not to fallback to another regex

On Wednesday, 22 June 2016, claudiofullscreen notifications@github.com wrote:

😞 In this case, all we can do is to add a disclaimer in the README or raise some error if the metric is not available.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Fullscreen/funky/issues/47#issuecomment-227796136, or mute the thread https://github.com/notifications/unsubscribe/AC_t8Wn6-K4bvoV7oTAkSK-jBT4ogaF9ks5qOV_KgaJpZM4I7fcE .

claudiofullscreen commented 8 years ago

Because I was not able to find the "view count" value at all in the HTML that you submitted.

Is it there somewhere?

On Wed, Jun 22, 2016 at 9:25 AM, Oded Shafran notifications@github.com wrote:

Why not to fallback to another regex

On Wednesday, 22 June 2016, claudiofullscreen notifications@github.com wrote:

😞 In this case, all we can do is to add a disclaimer in the README or raise some error if the metric is not available.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Fullscreen/funky/issues/47#issuecomment-227796136, or mute the thread < https://github.com/notifications/unsubscribe/AC_t8Wn6-K4bvoV7oTAkSK-jBT4ogaF9ks5qOV_KgaJpZM4I7fcE

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Fullscreen/funky/issues/47#issuecomment-227798844, or mute the thread https://github.com/notifications/unsubscribe/AHEL01pwp-LoNLEmEIeQxPKFG8jcucufks5qOWH7gaJpZM4I7fcE .

Claudio Baccigalupo | Manager, Software Engineering | Fullscreen, Inc. http://www.fullscreen.com

kangkyu commented 8 years ago

Then we should find out how to scrape "‏33,765‏ צפיות" by REGEX 😄

</span><div></div><span class="fcg">‏33,765‏ צפיות</span></div>
himberjack commented 8 years ago

Oh, its in hebrew? Hahaha , then yes, never mind

On Wednesday, 22 June 2016, Kang-Kyu Lee notifications@github.com wrote:

Then we should find out how to scrape "‏33,765‏ צפיות" by REGEX 😄

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Fullscreen/funky/issues/47#issuecomment-227803394, or mute the thread https://github.com/notifications/unsubscribe/AC_t8SIQk2F-wdt-M6t_5TEwwGjMVQg-ks5qOWWwgaJpZM4I7fcE .

philipqnguyen commented 8 years ago

Now I'm curious if we can get the views while being language agnostic?

With shares, likes, and comment counts, the regex is grabbing it from a JSON on the page. It's only the view count that is based on html markup. I'm talking about this file here: https://github.com/Fullscreen/funky/blob/master/lib/funky/html/parser.rb

claudiofullscreen commented 8 years ago

@philipqnguyen Since we are currently hard-coding the string "Views", I don't mind also hard-coding its Hebrew translation. Down the line, you might want to extract that part into its own function with all the possible translations (and left-to-right or right-to-left position) of the string "Views"

philipqnguyen commented 8 years ago

I have a local branch right now with a regex that could potentially be language agnostic. The regex won't depend on looking for "Views" or the Hebrew translation. I'll test it a bit more and then push it up =)

claudiofullscreen commented 8 years ago

@himberjack Do you mind trying the code in #50 and let us know if you can fetch the view count?

himberjack commented 8 years ago

perfect!