sportsflix 1.6.0 → 1.6.1

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: 1ea041dbb071da1bcd51eccb712000c9287f2f60
4
- data.tar.gz: 43bd6b1284ac3f7ca6e3b2586747095ad45ebe44
3
+ metadata.gz: 3a0510c27da8e9eefdc3211d6cd0517570db21ee
4
+ data.tar.gz: 255d66d29aabab0366930d3a1e796e7e3e3ba32d
5
5
  SHA512:
6
- metadata.gz: cfc386a5141f5aded8bfa4f655b5dfc10cfd0406332159d704ba337990d1f2fa645f590f836063542ec65f4a9de3e9c3f435e2a191d5d987ed59c16764f239d7
7
- data.tar.gz: df74131c7528718f430c1fe8d6c0a45b10e46b1cfa65665cfce7f78431a4f8005bcd2187a8ab9ca52f031231a365ebabe56f1f479e285109e1c197c3bd13b4b7
6
+ metadata.gz: 0fdb6a3e324b4f1b0186f3b96e8ba5c42b0bbc30a225414b4d894e09ea6f712b5687e56af11992f707643f0ac320c40878d46edd386c76fb432f069afbd38947
7
+ data.tar.gz: 52b5d5fa6e1a25b62a82eb968bcf509c570373b6e0592fe9ec7dd1ae0f646c56f8623e643bbf3790daf1387fa74258d41089640b96ca2fff6c307ab4b62cf237
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportsflix (1.6.0)
4
+ sportsflix (1.6.1)
5
5
  execjs-fastnode (~> 0.2)
6
6
  oga (~> 2.15)
7
7
  therubyracer (~> 0.12)
@@ -6,25 +6,38 @@ module Sportsflix
6
6
  module Arenavision
7
7
  class Client
8
8
  BASE_URLS = ['http://arenavision.in', 'http://arenavision.biz', 'http://arenavision.us']
9
- BASE_URL = BASE_URLS.sample
9
+
10
+ HEADERS = {
11
+ 'Cookie': 'beget=begetok;',
12
+ 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0',
13
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
14
+ 'Accept-Language': 'en-GB,pt;q=0.5',
15
+ 'DNT': '1',
16
+ 'Connection': 'keep-alive'
17
+ }
10
18
 
11
19
  def initialize(options)
12
- @verbose = options[:verbose]
13
- @club_name = options[:club]
20
+ @verbose = options[:verbose]
21
+ @club_name = options[:club]
14
22
  @server_only = options['server-only']
15
- @http = Sportsflix::Utils::HTTP.new
23
+ @http = Sportsflix::Utils::HTTP.new
24
+ @base_url = BASE_URLS.sample
25
+ puts ""
26
+ puts @base_url
27
+ puts ""
16
28
  end
17
29
 
18
30
  def list_streams
19
- home = get_page_contents("#{BASE_URL}/")
20
- schedule_path = home.css('a').select { |item| item.text.include?('EVENTS GUIDE') }.first.get('href')
21
- schedule_url = if schedule_path.start_with?("http")
22
- schedule_path
23
- else
24
- "#{BASE_URL}#{schedule_path}"
25
- end
26
- schedule = get_page_contents(schedule_url)
27
- streams = schedule.css('table tr')
31
+ @base_url = resolve_base_url("#{@base_url}/")
32
+ home = get_page_contents("#{@base_url}/")
33
+ schedule_path = home.css('a').select {|item| item.text.include?('EVENTS GUIDE')}.first.get('href')
34
+ schedule_url = if schedule_path.start_with?("http")
35
+ schedule_path
36
+ else
37
+ "#{@base_url}#{schedule_path}"
38
+ end
39
+ schedule = get_page_contents(schedule_url)
40
+ streams = schedule.css('table tr')
28
41
  # Remove first element
29
42
  streams = streams.drop(1)
30
43
  # Remove last element
@@ -43,35 +56,33 @@ module Sportsflix
43
56
 
44
57
  streams.map do |item|
45
58
  {
46
- :date => clean_str(item.css('td:nth-child(1)').text),
47
- :hour => clean_str(item.css('td:nth-child(2)').text),
48
- :sport => clean_str(item.css('td:nth-child(3)').text),
49
- :competition => clean_str(item.css('td:nth-child(4)').text),
50
- :game => clean_str(item.css('td:nth-child(5)').text),
51
- :stream_nr => parse_stream_ids(clean_str(item.css('td:nth-child(6)').text)),
52
- :proxy => :acestream
59
+ :date => clean_str(item.css('td:nth-child(1)').text),
60
+ :hour => clean_str(item.css('td:nth-child(2)').text),
61
+ :sport => clean_str(item.css('td:nth-child(3)').text),
62
+ :competition => clean_str(item.css('td:nth-child(4)').text),
63
+ :game => clean_str(item.css('td:nth-child(5)').text),
64
+ :stream_nr => parse_stream_ids(clean_str(item.css('td:nth-child(6)').text)),
65
+ :proxy => :acestream
53
66
  }
54
67
  end
55
68
  end
56
69
 
57
70
  def get_stream_uri(stream_nr, event)
58
- home = get_page_contents("#{BASE_URL}/")
59
- stream_link = home.css('a').select { |item| item.text.include?("#{event} #{stream_nr}") }.first.get('href')
60
- stream_raw = get_page_contents(stream_link)
61
- stream_raw.css('a').select { |item| !item.get('href').nil? && item.get('href').include?('acestream://') }.first.get('href')
71
+ home = get_page_contents("#{@base_url}/")
72
+ stream_link = home.css('a').select {|item| item.text.include?("#{event} #{stream_nr}")}.first.get('href')
73
+ stream_raw = get_page_contents(stream_link)
74
+ stream_raw.css('a').select {|item| !item.get('href').nil? && item.get('href').include?('acestream://')}.first.get('href')
62
75
  end
63
76
 
64
77
  private
65
78
 
79
+ def resolve_base_url(raw_url)
80
+ resp = @http.get(raw_url, {},HEADERS)
81
+ "#{resp.uri.scheme}://#{resp.uri.host}"
82
+ end
83
+
66
84
  def get_page_contents(raw_url)
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
85
+ html_str = @http.get(raw_url, {}, HEADERS).body
75
86
  Oga.parse_xml(html_str)
76
87
  end
77
88
 
@@ -79,22 +90,22 @@ module Sportsflix
79
90
  matches = raw_stream.scan(/(([W]?[0-9]+)(?:-([W]?[0-9]+))? \[(.+?)\])/)
80
91
  matches.map do |match|
81
92
  {
82
- :start => match[1].delete("W").to_i,
83
- :end => (match[2] || match[1]).delete("W").to_i,
84
- :language => match[3],
85
- :event => if match[1].start_with?("W")
86
- "World Cup"
87
- else
88
- "ArenaVision"
89
- end
93
+ :start => match[1].delete("W").to_i,
94
+ :end => (match[2] || match[1]).delete("W").to_i,
95
+ :language => match[3],
96
+ :event => if match[1].start_with?("W")
97
+ "World Cup"
98
+ else
99
+ "ArenaVision"
100
+ end
90
101
  }
91
102
  end
92
103
  end
93
104
 
94
105
  def clean_str(str)
95
106
  str.force_encoding('UTF-8')
96
- .gsub("\n\t\t", ' ')
97
- .strip
107
+ .gsub("\n\t\t", ' ')
108
+ .strip
98
109
  end
99
110
 
100
111
  end
@@ -1,3 +1,3 @@
1
1
  module Sportsflix
2
- VERSION = '1.6.0'
2
+ VERSION = '1.6.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportsflix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Fernandes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2019-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler