sportsflix 1.5.0 → 1.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87ab151a9d4f728c6146461ee641364e8b3832e8
4
- data.tar.gz: d94329c45679c853322e9e8b3686fc2508973a45
3
+ metadata.gz: 1ea041dbb071da1bcd51eccb712000c9287f2f60
4
+ data.tar.gz: 43bd6b1284ac3f7ca6e3b2586747095ad45ebe44
5
5
  SHA512:
6
- metadata.gz: a153def34094a6ba86008147f7646e56028fb311b94f221d333bd296718af0a5af29668c2c8796c87c568cdf9e64984cb58071651dc0dc3b3c7f6395ffe61a42
7
- data.tar.gz: 0406f7da147bd96df0d8af1ce1e963b18e905fcdc35925b67ebfceeda12eef4b234555946a3c1632ede64635c9b8dab279b50a830851f1a71a2f193574208717
6
+ metadata.gz: cfc386a5141f5aded8bfa4f655b5dfc10cfd0406332159d704ba337990d1f2fa645f590f836063542ec65f4a9de3e9c3f435e2a191d5d987ed59c16764f239d7
7
+ data.tar.gz: df74131c7528718f430c1fe8d6c0a45b10e46b1cfa65665cfce7f78431a4f8005bcd2187a8ab9ca52f031231a365ebabe56f1f479e285109e1c197c3bd13b4b7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportsflix (1.5.0)
4
+ sportsflix (1.6.0)
5
5
  execjs-fastnode (~> 0.2)
6
6
  oga (~> 2.15)
7
7
  therubyracer (~> 0.12)
@@ -21,7 +21,7 @@ GEM
21
21
  execjs (~> 2.0)
22
22
  jaro_winkler (1.5.2)
23
23
  json (2.2.0)
24
- libv8 (3.16.14.19)
24
+ libv8 (3.16.14.19-x86_64-linux)
25
25
  oga (2.15)
26
26
  ast
27
27
  ruby-ll (~> 2.1)
@@ -64,7 +64,14 @@ module Sportsflix
64
64
  private
65
65
 
66
66
  def get_page_contents(raw_url)
67
- html_str = @http.get(raw_url, {}, { Cookie: 'beget=begetok;' }).body
67
+ html_str = @http.get(raw_url, {}, {
68
+ 'Cookie': 'beget=begetok;',
69
+ 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0',
70
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
71
+ 'Accept-Language': 'en-GB,pt;q=0.5',
72
+ 'DNT': '1',
73
+ 'Connection': 'keep-alive'
74
+ }).body
68
75
  Oga.parse_xml(html_str)
69
76
  end
70
77
 
@@ -82,11 +82,12 @@ module Sportsflix
82
82
 
83
83
  def needs_cf_answer(res)
84
84
  res.is_a?(Net::HTTPServiceUnavailable) &&
85
- res['Server'] == 'cloudflare-nginx' &&
85
+ res['Server'].include?('cloudflare') &&
86
86
  res.body.include?('jschl_vc') &&
87
87
  res.body.include?('jschl_answer')
88
88
  end
89
89
 
90
+ # Source: https://github.com/Anorov/cloudflare-scrape/blob/master/cfscrape/__init__.py#L115
90
91
  def solve_challenge(body)
91
92
  begin
92
93
  js = /setTimeout\(function\(\){\s+(var s,t,o,p,b,r,e,a,k,i,n,g,f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n/.match(body)
@@ -95,7 +96,7 @@ module Sportsflix
95
96
  exit(1)
96
97
  end
97
98
 
98
- js = js.gsub("a\.value = (parseInt\(.+?\)).+", "\1")
99
+ js = js.gsub("a\.value = (.+ \+ t\.length).+", "\1")
99
100
  js = js.gsub("\s{3,}[a-z](?: = |\.).+", '')
100
101
 
101
102
  # Strip characters that could be used to exit the string context
@@ -1,3 +1,3 @@
1
1
  module Sportsflix
2
- VERSION = '1.5.0'
2
+ VERSION = '1.6.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportsflix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Fernandes