DreamTeam 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/DreamTeam/Films/html_films_table.rb +27 -37
- data/lib/DreamTeam/Films/parsing_films.rb +47 -55
- data/lib/DreamTeam/Games/html_games_table.rb +118 -124
- data/lib/DreamTeam/Games/parsing_games.rb +55 -61
- data/lib/DreamTeam/html_main.rb +3 -1
- data/lib/DreamTeam/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0998c3e35a0c4eec1573745686606a9a590c3e816be83987a162b71e8b8a3460'
|
4
|
+
data.tar.gz: 89e15191fe544d8e74b25f6acf32627a7a86592d1e0eea476262b5384bdedd1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1cbdefc59ca978a98f224be2434e48c6d9708c7aa64abfaf4d069273eb223290751342ebacdbe2215806847cb1ad43538b6a5238130385f62f2c7bae00d8f84
|
7
|
+
data.tar.gz: 38c683c303225b2a31c1772c90d4fb635769516f03bc23c02838bb574f22df8837cef0a797b24bb2fa4620af24bf1f10a663a8c2e3e0bbb95771f8124f76151c
|
data/README.md
CHANGED
@@ -35,8 +35,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
35
35
|
## Usage
|
36
36
|
|
37
37
|
usage example:
|
38
|
-
object = DreamTeam::Html_main::Html_main_page.
|
39
|
-
object.create_main('Path to specify the path where the files will be created',"Steam id")
|
38
|
+
object = DreamTeam::Html_main::Html_main_page.create_main('Path to specify the path where the files will be created',"Steam id")
|
40
39
|
|
41
40
|
## Development
|
42
41
|
|
@@ -1,13 +1,9 @@
|
|
1
1
|
require_relative 'parsing_films'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
class Table_film_page
|
3
|
+
def create_table_with_film(path)
|
4
|
+
fileHtml = File.new(path + "/table_film.html", "w+")
|
6
5
|
|
7
|
-
|
8
|
-
fileHtml = File.new(path + "/table_film.html", "w+")
|
9
|
-
|
10
|
-
fileHtml.puts "<style>
|
6
|
+
fileHtml.puts "<style>
|
11
7
|
.table_dark {
|
12
8
|
font-family: 'Lucida Sans Unicode', 'Lucida Grande', Sans-Serif;
|
13
9
|
font-size: 14px;
|
@@ -51,38 +47,32 @@ module DreamTeam
|
|
51
47
|
|
52
48
|
</tr>"
|
53
49
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
50
|
+
filmsInformation = get_all_films(get_films_id())
|
51
|
+
filmsInformation.each do |elem|
|
52
|
+
fileHtml.puts "<tr>"
|
53
|
+
fileHtml.puts "<th>"
|
54
|
+
fileHtml.puts elem.rank
|
55
|
+
fileHtml.puts "<th>"
|
56
|
+
fileHtml.puts elem.title
|
57
|
+
fileHtml.puts "<th>"
|
58
|
+
fileHtml.puts elem.title_full
|
59
|
+
fileHtml.puts "<th>"
|
60
|
+
fileHtml.puts elem.year
|
61
|
+
fileHtml.puts "<th>"
|
62
|
+
fileHtml.puts "<img src = '#{elem.image}'
|
67
63
|
width = '102'
|
68
64
|
height = '160'>"
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
fileHtml.puts "</tr>"
|
79
|
-
end
|
65
|
+
fileHtml.puts "<th>"
|
66
|
+
fileHtml.puts elem.crew
|
67
|
+
fileHtml.puts "<th>"
|
68
|
+
fileHtml.puts elem.imDbRating
|
69
|
+
fileHtml.puts "<th>"
|
70
|
+
fileHtml.puts elem.imDbRatingCount
|
71
|
+
fileHtml.puts "<th>"
|
80
72
|
|
81
|
-
|
82
|
-
fileHtml.close
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
end
|
73
|
+
fileHtml.puts "</tr>"
|
87
74
|
end
|
75
|
+
|
76
|
+
fileHtml.puts "</table>"
|
77
|
+
fileHtml.close
|
88
78
|
end
|
@@ -2,69 +2,61 @@ require 'open-uri'
|
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'json'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@imDbRating = help(arr, 7).to_f
|
23
|
-
@imDbRatingCount = help(arr, 8).to_i
|
24
|
-
end
|
5
|
+
class Film
|
6
|
+
include Comparable
|
7
|
+
attr_reader :id, :rank, :title, :title_full, :year, :image, :crew, :imDbRating, :imDbRatingCount
|
8
|
+
|
9
|
+
#конструктор класса. из строки вытаскивает функцией help нужные данные для полей
|
10
|
+
def initialize (arr_film)
|
11
|
+
arr = arr_film.to_s.gsub('{', '').gsub('}', '').gsub('",', '"^^^').split('^^^')
|
12
|
+
@id = help(arr, 0)
|
13
|
+
@rank = help(arr, 1).to_i
|
14
|
+
@title = help(arr, 2)
|
15
|
+
@title_full = help(arr, 3)
|
16
|
+
@year = help(arr, 4).to_i
|
17
|
+
@image = help(arr, 5)
|
18
|
+
@crew = help(arr, 6)
|
19
|
+
@imDbRating = help(arr, 7).to_f
|
20
|
+
@imDbRatingCount = help(arr, 8).to_i
|
21
|
+
end
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def <=>(an_other)
|
24
|
+
an_other.year <=> self.year
|
25
|
+
end
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
def help(arr, i)
|
28
|
+
return arr[i][arr[i].index(':"') + 2, arr[i].length - arr[i].index(':"') - 3]
|
29
|
+
end
|
30
|
+
end
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
def get_films_id()
|
33
|
+
uri = 'https://imdb-api.com/en/API/Top250Movies/k_uq4za59n'
|
34
|
+
doc = Nokogiri::HTML(URI.open(uri))
|
38
35
|
|
39
|
-
|
36
|
+
text = doc.text.gsub('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
40
37
|
"http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><p>', '')
|
41
|
-
|
42
|
-
|
38
|
+
text = text.gsub('{"items":[', '').gsub(']', '')
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
def get_all_films(text)
|
40
|
+
#text = '{"id":"1424411", ":rank":"1", ":title":"title 1", ":year":"1990", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"},{"id":"9352791", ":rank":"2", ":title":"title 2", ":year":"2006", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"},{"id":"1908543", ":rank":"3", ":title":"title 3", ":year":"2012", ":image":"http:\picture1.com",":crew":"Tom Jon Mike", ":imDbRating":"9.2", ":imDbRatingCount":"8.1"}'
|
41
|
+
#text = '{"id":"tt0111161","rank":"1","title":"The Shawshank Redemption","fullTitle":"The Shawshank Redemption (1994)","year":"1994","image":"https://m.media-amazon.com/images/M/MV5BMDFkYTc0MGEtZmNhMC00ZDIzLWFmNTEtODM1ZmRlYWMwMWFmXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Frank Darabont (dir.), Tim Robbins, Morgan Freeman","imDbRating":"9.2","imDbRatingCount":"2650504"},{"id":"tt0068646","rank":"2","title":"The Godfather","fullTitle":"The Godfather (1972)","year":"1972","image":"https://m.media-amazon.com/images/M/MV5BM2MyNjYxNmUtYTAwNi00MTYxLWJmNWYtYzZlODY3ZTk3OTFlXkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Francis Ford Coppola (dir.), Marlon Brando, Al Pacino","imDbRating":"9.2","imDbRatingCount":"1837317"},{"id":"tt0468569","rank":"3","title":"The Dark Knight","fullTitle":"The Dark Knight (2008)","year":"2008","image":"https://m.media-amazon.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Christopher Nolan (dir.), Christian Bale, Heath Ledger","imDbRating":"9.0","imDbRatingCount":"2622617"},{"id":"tt0071562","rank":"4","title":"The Godfather Part II","fullTitle":"The Godfather Part II (1974)","year":"1974","image":"https://m.media-amazon.com/images/M/MV5BMWMwMGQzZTItY2JlNC00OWZiLWIyMDctNDk2ZDQ2YjRjMWQ0XkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Francis Ford Coppola (dir.), Al Pacino, Robert De Niro","imDbRating":"9.0","imDbRatingCount":"1259016"},{"id":"tt0050083","rank":"5","title":"12 Angry Men","fullTitle":"12 Angry Men (1957)","year":"1957","image":"https://m.media-amazon.com/images/M/MV5BMWU4N2FjNzYtNTVkNC00NzQ0LTg0MjAtYTJlMjFhNGUxZDFmXkEyXkFqcGdeQXVyNjc1NTYyMjg@._V1_UX128_CR0,12,128,176_AL_.jpg","crew":"Sidney Lumet (dir.), Henry Fonda, Lee J. Cobb","imDbRating":"9.0","imDbRatingCount":"782597"}'
|
42
|
+
text.gsub('},', '}').gsub('"errorMessage":""}', '')
|
43
|
+
end
|
51
44
|
|
52
|
-
|
53
|
-
while text.index('}') != nil
|
54
|
-
ind_start = 0
|
55
|
-
ind_finish = text.index('}')
|
56
|
-
dist = ind_finish - ind_start + 1
|
57
|
-
arr_films << text[ind_start, dist].gsub(' "','"')
|
58
|
-
text = text.gsub(text[ind_start, dist], '')
|
59
|
-
end
|
45
|
+
def get_all_films(text)
|
60
46
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
47
|
+
arr_films = []
|
48
|
+
while text.index('}') != nil
|
49
|
+
ind_start = 0
|
50
|
+
ind_finish = text.index('}')
|
51
|
+
dist = ind_finish - ind_start + 1
|
52
|
+
arr_films << text[ind_start, dist].gsub(' "', '"')
|
53
|
+
text = text.gsub(text[ind_start, dist], '')
|
54
|
+
end
|
65
55
|
|
66
|
-
|
67
|
-
|
56
|
+
rezult = []
|
57
|
+
arr_films.each do |f|
|
58
|
+
rezult << Film.new(f)
|
68
59
|
end
|
69
|
-
end
|
70
60
|
|
61
|
+
rezult
|
62
|
+
end
|
@@ -1,130 +1,124 @@
|
|
1
1
|
require_relative 'parsing_games'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
border-radius: 0 8px 8px 0;
|
44
|
-
}
|
45
|
-
</style>
|
3
|
+
def create_table_with_user_game(path, user_id)
|
4
|
+
file_html = File.new(path + "/table_game.html", "w+")
|
5
|
+
user_info = get_user_information(user_id)
|
6
|
+
file_html.puts "<style type='text/css'>
|
7
|
+
.table {
|
8
|
+
width: 100%;
|
9
|
+
border: none;
|
10
|
+
margin-bottom: 20px;
|
11
|
+
}
|
12
|
+
.table thead th {
|
13
|
+
font-weight: bold;
|
14
|
+
text-align: left;
|
15
|
+
border: none;
|
16
|
+
padding: 10px 15px;
|
17
|
+
background: #d8d8d8;
|
18
|
+
font-size: 14px;
|
19
|
+
}
|
20
|
+
.table thead tr th:first-child {
|
21
|
+
border-radius: 8px 0 0 8px;
|
22
|
+
}
|
23
|
+
.table thead tr th:last-child {
|
24
|
+
border-radius: 0 8px 8px 0;
|
25
|
+
}
|
26
|
+
.table tbody td {
|
27
|
+
text-align: left;
|
28
|
+
border: none;
|
29
|
+
padding: 10px 15px;
|
30
|
+
font-size: 14px;
|
31
|
+
vertical-align: top;
|
32
|
+
}
|
33
|
+
.table tbody tr:nth-child(even){
|
34
|
+
background: #f3f3f3;
|
35
|
+
}
|
36
|
+
.table tbody tr td:first-child {
|
37
|
+
border-radius: 8px 0 0 8px;
|
38
|
+
}
|
39
|
+
.table tbody tr td:last-child {
|
40
|
+
border-radius: 0 8px 8px 0;
|
41
|
+
}
|
42
|
+
</style>
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
44
|
+
<table class='table'>
|
45
|
+
<thead>
|
46
|
+
<img src = '#{user_info[:avatar]}'>
|
47
|
+
#{user_info[:username]}
|
48
|
+
<tr>
|
49
|
+
<th>Game</th>
|
50
|
+
<th>Image</th>
|
51
|
+
<th>Price</th>
|
52
|
+
<th>Developers</th>
|
53
|
+
<th>Date</th>
|
54
|
+
<th>Description</th>
|
55
|
+
<th>Recommendation</th>
|
56
|
+
<th>Time In The Game</th>
|
57
|
+
</tr>
|
58
|
+
</thead>
|
59
|
+
<tbody>"
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
file_html.puts "</th>"
|
74
|
-
file_html.puts "<th>"
|
75
|
-
file_html.puts "<img src = '#{elem[:img]}'
|
76
|
-
width = '220'
|
77
|
-
height = '102'
|
78
|
-
alt = 'Picture of the game'>"
|
79
|
-
file_html.puts "</th>"
|
80
|
-
file_html.puts "<th>"
|
81
|
-
if elem[:price].nil?
|
82
|
-
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
83
|
-
else
|
84
|
-
file_html.puts elem[:price]
|
85
|
-
end
|
86
|
-
file_html.puts "</th>"
|
87
|
-
file_html.puts "<th>"
|
88
|
-
if elem[:developers].nil?
|
89
|
-
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
90
|
-
else
|
91
|
-
file_html.puts elem[:developers]
|
92
|
-
end
|
93
|
-
file_html.puts "</th>"
|
94
|
-
file_html.puts "<th>"
|
95
|
-
if elem[:date].nil?
|
96
|
-
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
97
|
-
else
|
98
|
-
file_html.puts elem[:date]
|
99
|
-
end
|
100
|
-
file_html.puts "</th>"
|
101
|
-
file_html.puts "<th>"
|
102
|
-
if elem[:desc].nil?
|
103
|
-
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
104
|
-
else
|
105
|
-
file_html.puts elem[:desc]
|
106
|
-
end
|
107
|
-
file_html.puts "</th>"
|
108
|
-
file_html.puts "<th>"
|
109
|
-
if elem[:recommendations].nil?
|
110
|
-
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
111
|
-
else
|
112
|
-
file_html.puts elem[:recommendations]
|
113
|
-
end
|
114
|
-
file_html.puts "</th>"
|
115
|
-
file_html.puts "<th>"
|
116
|
-
if elem[:time] == 0
|
117
|
-
file_html.puts "0"
|
118
|
-
else
|
119
|
-
file_html.puts "#{elem[:time].to_i/60}h #{-(elem[:time].to_i/60*60 - elem[:time].to_i)}min"
|
120
|
-
end
|
121
|
-
file_html.puts "</th>"
|
122
|
-
file_html.puts "</tr>"
|
123
|
-
end
|
124
|
-
file_html.puts "</tbody>
|
125
|
-
</table>"
|
126
|
-
file_html.close
|
127
|
-
end
|
61
|
+
games_information = information_of_games(get_user_games(user_id))
|
62
|
+
games_information.each do |elem|
|
63
|
+
file_html.puts "<tr>"
|
64
|
+
file_html.puts "<th>"
|
65
|
+
if elem[:name].nil?
|
66
|
+
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
67
|
+
else
|
68
|
+
file_html.puts elem[:name]
|
128
69
|
end
|
70
|
+
file_html.puts "</th>"
|
71
|
+
file_html.puts "<th>"
|
72
|
+
file_html.puts "<img src = '#{elem[:img]}'
|
73
|
+
width = '220'
|
74
|
+
height = '102'
|
75
|
+
alt = 'Picture of the game'>"
|
76
|
+
file_html.puts "</th>"
|
77
|
+
file_html.puts "<th>"
|
78
|
+
if elem[:price].nil?
|
79
|
+
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
80
|
+
else
|
81
|
+
file_html.puts elem[:price]
|
82
|
+
end
|
83
|
+
file_html.puts "</th>"
|
84
|
+
file_html.puts "<th>"
|
85
|
+
if elem[:developers].nil?
|
86
|
+
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
87
|
+
else
|
88
|
+
file_html.puts elem[:developers]
|
89
|
+
end
|
90
|
+
file_html.puts "</th>"
|
91
|
+
file_html.puts "<th>"
|
92
|
+
if elem[:date].nil?
|
93
|
+
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
94
|
+
else
|
95
|
+
file_html.puts elem[:date]
|
96
|
+
end
|
97
|
+
file_html.puts "</th>"
|
98
|
+
file_html.puts "<th>"
|
99
|
+
if elem[:desc].nil?
|
100
|
+
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
101
|
+
else
|
102
|
+
file_html.puts elem[:desc]
|
103
|
+
end
|
104
|
+
file_html.puts "</th>"
|
105
|
+
file_html.puts "<th>"
|
106
|
+
if elem[:recommendations].nil?
|
107
|
+
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
108
|
+
else
|
109
|
+
file_html.puts elem[:recommendations]
|
110
|
+
end
|
111
|
+
file_html.puts "</th>"
|
112
|
+
file_html.puts "<th>"
|
113
|
+
if elem[:time] == 0
|
114
|
+
file_html.puts "0"
|
115
|
+
else
|
116
|
+
file_html.puts "#{elem[:time].to_i / 60}h #{-(elem[:time].to_i / 60 * 60 - elem[:time].to_i)}min"
|
117
|
+
end
|
118
|
+
file_html.puts "</th>"
|
119
|
+
file_html.puts "</tr>"
|
129
120
|
end
|
130
|
-
|
121
|
+
file_html.puts "</tbody>
|
122
|
+
</table>"
|
123
|
+
file_html.close
|
124
|
+
end
|
@@ -1,70 +1,64 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'nokogiri'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
avatar = url[/<avataricon><!--\[CDATA\[(?<avatar>.*)\]\]--><\/avataricon>/, 1]
|
11
|
-
{username: username, avatar: avatar}
|
12
|
-
end
|
4
|
+
def get_user_information(steam_id)
|
5
|
+
url = Nokogiri::HTML5(URI.open('https://steamcommunity.com/profiles/' + steam_id + '/?xml=1')).to_s
|
6
|
+
username = url[/<steamid><!--\[CDATA\[(?<username>.*)\]\]--><\/steamid>/, 1]
|
7
|
+
avatar = url[/<avataricon><!--\[CDATA\[(?<avatar>.*)\]\]--><\/avataricon>/, 1]
|
8
|
+
{ username: username, avatar: avatar }
|
9
|
+
end
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
res
|
11
|
+
def get_user_games(steam_id)
|
12
|
+
res = []
|
13
|
+
begin
|
14
|
+
url = Nokogiri::HTML5(URI.open('https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?steamid=' +
|
15
|
+
+steam_id + '&key=' + 'FB8E10E3C18DFD06F605ACF4D049866A')).to_s
|
16
|
+
rescue
|
17
|
+
return res
|
18
|
+
end
|
19
|
+
arr = url.split(',')
|
20
|
+
last_id = ''
|
21
|
+
arr.each do |a|
|
22
|
+
id = a.match(/"appid":(?<id>.*)/)
|
23
|
+
if !id.nil?
|
24
|
+
last_id = id[:id]
|
25
|
+
else
|
26
|
+
time = a.match(/"playtime_forever":(?<time>.*)/)
|
27
|
+
if !time.nil?
|
28
|
+
res.push({ id: last_id, time: time[:time] })
|
36
29
|
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
res
|
33
|
+
end
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
developers = url[/"developers":\[(?<developers>.*)\],"publishers"/, 1]
|
56
|
-
if developers != nil
|
57
|
-
developers = developers.delete "\""
|
58
|
-
end
|
59
|
-
recommendations = url[/tions":{"total":(?<recommendations>\d*)/, 1]
|
60
|
-
desc = url[/t_description":"(?<desc>.*)","sup/, 1]
|
61
|
-
img = url[/"header_image":"(?<img>.*)","website"/, 1]
|
62
|
-
|
63
|
-
res.push({name: name, time: time, date: date, price: price, developers: developers,
|
64
|
-
recommendations: recommendations, desc: desc, img: img})
|
65
|
-
end
|
66
|
-
res
|
67
|
-
end
|
35
|
+
def information_of_games(games_id)
|
36
|
+
res = []
|
37
|
+
games_id.each do |g|
|
38
|
+
begin
|
39
|
+
url = Nokogiri::HTML5(URI.open('https://store.steampowered.com/api/appdetails/?appids=' + g[:id])).to_s
|
40
|
+
rescue
|
41
|
+
next
|
42
|
+
end
|
43
|
+
name = url[/"name":"(?<name>.*)","steam_/, 1]
|
44
|
+
time = g[:time]
|
45
|
+
date = url[/date":"(?<date>.*)"},"su/, 1]
|
46
|
+
price = url[/nal_formatted":"(?<price>.*) pуб\."},"pac/, 1]
|
47
|
+
if price == nil
|
48
|
+
price = url[/nal_formatted":"(?<price>.*)"},"pac/, 1]
|
49
|
+
else
|
50
|
+
price += ' rub'
|
68
51
|
end
|
52
|
+
developers = url[/"developers":\[(?<developers>.*)\],"publishers"/, 1]
|
53
|
+
if developers != nil
|
54
|
+
developers = developers.delete "\""
|
55
|
+
end
|
56
|
+
recommendations = url[/tions":{"total":(?<recommendations>\d*)/, 1]
|
57
|
+
desc = url[/t_description":"(?<desc>.*)","sup/, 1]
|
58
|
+
img = url[/"header_image":"(?<img>.*)","website"/, 1]
|
59
|
+
|
60
|
+
res.push({ name: name, time: time, date: date, price: price, developers: developers,
|
61
|
+
recommendations: recommendations, desc: desc, img: img })
|
69
62
|
end
|
63
|
+
res
|
70
64
|
end
|
data/lib/DreamTeam/html_main.rb
CHANGED
@@ -4,7 +4,7 @@ require 'DreamTeam/Films/html_films_table'
|
|
4
4
|
module DreamTeam
|
5
5
|
module Html_main
|
6
6
|
class Html_main_page
|
7
|
-
def create_main(path, steam_id)
|
7
|
+
def self.create_main(path, steam_id)
|
8
8
|
create_table_with_user_game(path, steam_id)
|
9
9
|
create_table_with_film(path)
|
10
10
|
file_html = File.new(path + '/main_table.html', 'w+')
|
@@ -41,3 +41,5 @@ module DreamTeam
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
DreamTeam::Html_main::Html_main_page.create_main("C:/ЮФУ", "76561198271666506")
|
data/lib/DreamTeam/version.rb
CHANGED