DreamTeam 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +12 -12
- data/README.md +21 -19
- data/lib/DreamTeam/Films/html_films_table.rb +88 -0
- data/lib/DreamTeam/Films/parsing_films.rb +52 -46
- data/lib/DreamTeam/Games/html_games_table.rb +130 -0
- data/lib/DreamTeam/Games/parsing_games.rb +61 -55
- data/lib/DreamTeam/html_main.rb +2 -2
- data/lib/DreamTeam/version.rb +1 -1
- data/lib/DreamTeam.rb +2 -2
- metadata +8 -8
- data/lib/DreamTeam/Films/html_table.rb +0 -79
- data/lib/DreamTeam/Games/html_table.rb +0 -124
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea8a784a181c210965d831f2bffadd7f9661defa8e945513a195ffa96a20c446
|
4
|
+
data.tar.gz: 950744a84f6b8f69d3d44046ff7e9c7af8485f30a45f250be8f89f8b76115eee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db1467c54c0d32afb099e233817ddc80c156188c4dfb3acda88f819e0ac32d2c69a9740bd0d5e0293efb3c577969dc2209e2a8c50d5c8f60983c31133ad9484b
|
7
|
+
data.tar.gz: c564993091e2ef75b240409ab49ccbd3b7b7475bfd9ec7eafa1d278c0f670698bc7c37c88ed3952a114c73fd807c5a70868bf37478f44921a66bf7942fd06e8b
|
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in DreamTeam.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem "rake", "~> 13.0"
|
9
|
-
|
10
|
-
gem "minitest", "~> 5.0"
|
11
|
-
|
12
|
-
gem "nokogiri"
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in DreamTeam.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
|
10
|
+
gem "minitest", "~> 5.0"
|
11
|
+
|
12
|
+
gem "nokogiri", "~> 1.13.0"
|
data/README.md
CHANGED
@@ -3,24 +3,24 @@
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/DreamTeam`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
5
|
This gem allows you to get information about the steam user's games and the top 250 IMDb movies.
|
6
|
-
Information about steam games includes:
|
7
|
-
-Name
|
8
|
-
-Picture
|
9
|
-
-Price
|
10
|
-
-Developer
|
11
|
-
-Release date
|
12
|
-
-Description
|
13
|
-
-Number of recommendations
|
14
|
-
-Time spent in the game.
|
15
|
-
Information about the films includes:
|
16
|
-
-Place in the rating
|
17
|
-
-Film name
|
18
|
-
-Full name
|
19
|
-
-Release date
|
20
|
-
-Picture
|
21
|
-
-The actors
|
22
|
-
-Rating
|
23
|
-
-Rating Count
|
6
|
+
Information about steam games includes:
|
7
|
+
-Name
|
8
|
+
-Picture
|
9
|
+
-Price
|
10
|
+
-Developer
|
11
|
+
-Release date
|
12
|
+
-Description
|
13
|
+
-Number of recommendations
|
14
|
+
-Time spent in the game.
|
15
|
+
Information about the films includes:
|
16
|
+
-Place in the rating
|
17
|
+
-Film name
|
18
|
+
-Full name
|
19
|
+
-Release date
|
20
|
+
-Picture
|
21
|
+
-The actors
|
22
|
+
-Rating
|
23
|
+
-Rating Count
|
24
24
|
|
25
25
|
## Installation
|
26
26
|
|
@@ -34,7 +34,9 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
34
34
|
|
35
35
|
## Usage
|
36
36
|
|
37
|
-
|
37
|
+
usage example:
|
38
|
+
object = DreamTeam::Html_main::Html_main_page.new
|
39
|
+
object.create_main('Path to specify the path where the files will be created',"Steam id")
|
38
40
|
|
39
41
|
## Development
|
40
42
|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require_relative 'parsing_films'
|
2
|
+
|
3
|
+
module DreamTeam
|
4
|
+
module Table_film
|
5
|
+
class Table_film_page
|
6
|
+
|
7
|
+
def create_table_with_film(path)
|
8
|
+
fileHtml = File.new(path + "/table_film.html", "w+")
|
9
|
+
|
10
|
+
fileHtml.puts "<style>
|
11
|
+
.table_dark {
|
12
|
+
font-family: 'Lucida Sans Unicode', 'Lucida Grande', Sans-Serif;
|
13
|
+
font-size: 14px;
|
14
|
+
width: 100%;
|
15
|
+
text-align: left;
|
16
|
+
border-collapse: collapse;
|
17
|
+
background: #252F48;
|
18
|
+
margin: 10px;
|
19
|
+
}
|
20
|
+
.table_dark th {
|
21
|
+
color: #EDB749;
|
22
|
+
border-bottom: 1px solid #37B5A5;
|
23
|
+
padding: 12px 17px;
|
24
|
+
}
|
25
|
+
.table_dark td {
|
26
|
+
color: #CAD4D6;
|
27
|
+
border-bottom: 1px solid #37B5A5;
|
28
|
+
border-right: 1px solid #37B5A5;
|
29
|
+
padding: 7px 17px;
|
30
|
+
}
|
31
|
+
.table_dark tr:last-child td {
|
32
|
+
border-bottom: none;
|
33
|
+
}
|
34
|
+
.table_dark td:last-child {
|
35
|
+
border-right: none;
|
36
|
+
}
|
37
|
+
.table_dark tr:hover td {
|
38
|
+
text-decoration: underline;
|
39
|
+
} </style>
|
40
|
+
|
41
|
+
<table class='table_dark'>
|
42
|
+
<tr>
|
43
|
+
<th>Rang</th>
|
44
|
+
<th>Film name</th>
|
45
|
+
<th>Full name</th>
|
46
|
+
<th>Year</th>
|
47
|
+
<th>Image</th>
|
48
|
+
<th>The actors</th>
|
49
|
+
<th>Rating</th>
|
50
|
+
<th>Rating Count</th>
|
51
|
+
|
52
|
+
</tr>"
|
53
|
+
|
54
|
+
filmsInformation = get_all_films(get_films_id())
|
55
|
+
filmsInformation.each do |elem|
|
56
|
+
fileHtml.puts "<tr>"
|
57
|
+
fileHtml.puts "<th>"
|
58
|
+
fileHtml.puts elem.rank
|
59
|
+
fileHtml.puts "<th>"
|
60
|
+
fileHtml.puts elem.title
|
61
|
+
fileHtml.puts "<th>"
|
62
|
+
fileHtml.puts elem.title_full
|
63
|
+
fileHtml.puts "<th>"
|
64
|
+
fileHtml.puts elem.year
|
65
|
+
fileHtml.puts "<th>"
|
66
|
+
fileHtml.puts "<img src = '#{elem.image}'
|
67
|
+
width = '102'
|
68
|
+
height = '160'>"
|
69
|
+
fileHtml.puts "<th>"
|
70
|
+
fileHtml.puts elem.crew
|
71
|
+
fileHtml.puts "<th>"
|
72
|
+
fileHtml.puts elem.imDbRating
|
73
|
+
fileHtml.puts "<th>"
|
74
|
+
fileHtml.puts elem.imDbRatingCount
|
75
|
+
fileHtml.puts "<th>"
|
76
|
+
|
77
|
+
|
78
|
+
fileHtml.puts "</tr>"
|
79
|
+
end
|
80
|
+
|
81
|
+
fileHtml.puts "</table>"
|
82
|
+
fileHtml.close
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -2,63 +2,69 @@ require 'open-uri'
|
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'json'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
attr_reader :id, :rank, :title, :title_full, :year, :image, :crew, :imDbRating, :imDbRatingCount
|
5
|
+
module DreamTeam
|
6
|
+
module Parsing_film
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
8
|
+
class Film
|
9
|
+
include Comparable
|
10
|
+
attr_reader :id, :rank, :title, :title_full, :year, :image, :crew, :imDbRating, :imDbRatingCount
|
22
11
|
|
23
|
-
|
24
|
-
|
25
|
-
|
12
|
+
#конструктор класса. из строки вытаскивает функцией help нужные данные для полей
|
13
|
+
def initialize (arr_film)
|
14
|
+
arr = arr_film.to_s.gsub('{','').gsub('}','').gsub('",','"^^^').split('^^^')
|
15
|
+
@id = help(arr, 0)
|
16
|
+
@rank = help(arr, 1).to_i
|
17
|
+
@title = help(arr, 2)
|
18
|
+
@title_full = help(arr, 3)
|
19
|
+
@year = help(arr, 4).to_i
|
20
|
+
@image = help(arr, 5)
|
21
|
+
@crew = help(arr, 6)
|
22
|
+
@imDbRating = help(arr, 7).to_f
|
23
|
+
@imDbRatingCount = help(arr, 8).to_i
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def <=>(an_other)
|
27
|
+
an_other.year <=> self.year
|
28
|
+
end
|
29
|
+
|
30
|
+
def help(arr, i)
|
31
|
+
return arr[i][arr[i].index(':"') + 2, arr[i].length - arr[i].index(':"') - 3]
|
32
|
+
end
|
33
|
+
end
|
31
34
|
|
32
|
-
def get_films_id()
|
33
|
-
|
34
|
-
|
35
|
+
def get_films_id()
|
36
|
+
uri = 'https://imdb-api.com/en/API/Top250Movies/k_uq4za59n'
|
37
|
+
doc = Nokogiri::HTML(URI.open(uri))
|
35
38
|
|
36
|
-
|
39
|
+
text = doc.text.gsub('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
37
40
|
"http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><p>', '')
|
38
|
-
|
41
|
+
text = text.gsub('{"items":[', '').gsub(']','')
|
39
42
|
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
44
|
+
#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"}'
|
45
|
+
#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"}'
|
46
|
+
text.gsub('},','}').gsub('"errorMessage":""}','')
|
47
|
+
end
|
45
48
|
|
46
49
|
|
47
|
-
def get_all_films(text)
|
50
|
+
def get_all_films(text)
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
arr_films = []
|
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
|
57
60
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
61
|
+
rezult = []
|
62
|
+
arr_films.each do|f|
|
63
|
+
rezult << Film.new(f)
|
64
|
+
end
|
62
65
|
|
63
|
-
|
66
|
+
rezult
|
67
|
+
end
|
68
|
+
end
|
64
69
|
end
|
70
|
+
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require_relative 'parsing_games'
|
2
|
+
|
3
|
+
module DreamTeam
|
4
|
+
module Table_game
|
5
|
+
class Table_game_page
|
6
|
+
def create_table_with_user_game(path, user_id)
|
7
|
+
file_html = File.new(path + "/table_game.html", "w+")
|
8
|
+
user_info = get_user_information(user_id)
|
9
|
+
file_html.puts "<style type='text/css'>
|
10
|
+
.table {
|
11
|
+
width: 100%;
|
12
|
+
border: none;
|
13
|
+
margin-bottom: 20px;
|
14
|
+
}
|
15
|
+
.table thead th {
|
16
|
+
font-weight: bold;
|
17
|
+
text-align: left;
|
18
|
+
border: none;
|
19
|
+
padding: 10px 15px;
|
20
|
+
background: #d8d8d8;
|
21
|
+
font-size: 14px;
|
22
|
+
}
|
23
|
+
.table thead tr th:first-child {
|
24
|
+
border-radius: 8px 0 0 8px;
|
25
|
+
}
|
26
|
+
.table thead tr th:last-child {
|
27
|
+
border-radius: 0 8px 8px 0;
|
28
|
+
}
|
29
|
+
.table tbody td {
|
30
|
+
text-align: left;
|
31
|
+
border: none;
|
32
|
+
padding: 10px 15px;
|
33
|
+
font-size: 14px;
|
34
|
+
vertical-align: top;
|
35
|
+
}
|
36
|
+
.table tbody tr:nth-child(even){
|
37
|
+
background: #f3f3f3;
|
38
|
+
}
|
39
|
+
.table tbody tr td:first-child {
|
40
|
+
border-radius: 8px 0 0 8px;
|
41
|
+
}
|
42
|
+
.table tbody tr td:last-child {
|
43
|
+
border-radius: 0 8px 8px 0;
|
44
|
+
}
|
45
|
+
</style>
|
46
|
+
|
47
|
+
<table class='table'>
|
48
|
+
<thead>
|
49
|
+
<img src = '#{user_info[:avatar]}'>
|
50
|
+
#{user_info[:username]}
|
51
|
+
<tr>
|
52
|
+
<th>Game</th>
|
53
|
+
<th>Image</th>
|
54
|
+
<th>Price</th>
|
55
|
+
<th>Developers</th>
|
56
|
+
<th>Date</th>
|
57
|
+
<th>Description</th>
|
58
|
+
<th>Recommendation</th>
|
59
|
+
<th>Time In The Game</th>
|
60
|
+
</tr>
|
61
|
+
</thead>
|
62
|
+
<tbody>"
|
63
|
+
|
64
|
+
games_information = information_of_games(get_user_games(user_id))
|
65
|
+
games_information.each do |elem|
|
66
|
+
file_html.puts "<tr>"
|
67
|
+
file_html.puts "<th>"
|
68
|
+
if elem[:name].nil?
|
69
|
+
file_html.puts "<span style = 'font-size:20pt'> - </span>"
|
70
|
+
else
|
71
|
+
file_html.puts elem[:name]
|
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
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -1,64 +1,70 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'nokogiri'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
module DreamTeam
|
5
|
+
module Parsing_game
|
6
|
+
class Parsing_steam_game
|
7
|
+
def get_user_information(steam_id)
|
8
|
+
url = Nokogiri::HTML5(URI.open('https://steamcommunity.com/profiles/' + steam_id + '/?xml=1')).to_s
|
9
|
+
username = url[/<steamid><!--\[CDATA\[(?<username>.*)\]\]--><\/steamid>/, 1]
|
10
|
+
avatar = url[/<avataricon><!--\[CDATA\[(?<avatar>.*)\]\]--><\/avataricon>/, 1]
|
11
|
+
{username: username, avatar: avatar}
|
12
|
+
end
|
10
13
|
|
11
|
-
def get_user_games(steam_id)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
14
|
+
def get_user_games(steam_id)
|
15
|
+
res = []
|
16
|
+
begin
|
17
|
+
url = Nokogiri::HTML5(URI.open('https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?steamid=' +
|
18
|
+
+ steam_id + '&key=' + 'FB8E10E3C18DFD06F605ACF4D049866A')).to_s
|
19
|
+
rescue
|
20
|
+
return res
|
21
|
+
end
|
22
|
+
arr = url.split(',')
|
23
|
+
last_id = ''
|
24
|
+
arr.each do |a|
|
25
|
+
id = a.match(/"appid":(?<id>.*)/)
|
26
|
+
if !id.nil?
|
27
|
+
last_id = id[:id]
|
28
|
+
else
|
29
|
+
time = a.match(/"playtime_forever":(?<time>.*)/)
|
30
|
+
if !time.nil?
|
31
|
+
res.push({id: last_id, time: time[:time]})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
res
|
29
36
|
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
res
|
33
|
-
end
|
34
37
|
|
35
|
-
def information_of_games(games_id)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
38
|
+
def information_of_games(games_id)
|
39
|
+
res = []
|
40
|
+
games_id.each do |g|
|
41
|
+
begin
|
42
|
+
url = Nokogiri::HTML5(URI.open('https://store.steampowered.com/api/appdetails/?appids=' + g[:id])).to_s
|
43
|
+
rescue
|
44
|
+
next
|
45
|
+
end
|
46
|
+
name = url[/"name":"(?<name>.*)","steam_/, 1]
|
47
|
+
time = g[:time]
|
48
|
+
date = url[/date":"(?<date>.*)"},"su/, 1]
|
49
|
+
price = url[/nal_formatted":"(?<price>.*) pуб\."},"pac/, 1]
|
50
|
+
if price == nil
|
51
|
+
price = url[/nal_formatted":"(?<price>.*)"},"pac/, 1]
|
52
|
+
else
|
53
|
+
price += ' rub'
|
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]
|
59
62
|
|
60
|
-
|
63
|
+
res.push({name: name, time: time, date: date, price: price, developers: developers,
|
61
64
|
recommendations: recommendations, desc: desc, img: img})
|
65
|
+
end
|
66
|
+
res
|
67
|
+
end
|
68
|
+
end
|
62
69
|
end
|
63
|
-
|
64
|
-
end
|
70
|
+
end
|
data/lib/DreamTeam/html_main.rb
CHANGED
data/lib/DreamTeam/version.rb
CHANGED
data/lib/DreamTeam.rb
CHANGED
@@ -4,9 +4,9 @@ require_relative "DreamTeam/version"
|
|
4
4
|
|
5
5
|
module DreamTeam
|
6
6
|
class Error < StandardError; end
|
7
|
-
require_relative
|
7
|
+
require_relative "DreamTeam/Games/html_games_table"
|
8
8
|
require_relative "DreamTeam/Games/parsing_games"
|
9
|
-
require_relative "DreamTeam/Films/
|
9
|
+
require_relative "DreamTeam/Films/html_films_table"
|
10
10
|
require_relative "DreamTeam/Films/parsing_films"
|
11
11
|
require_relative "DreamTeam/html_main"
|
12
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: DreamTeam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spooky_Loki
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-10-
|
14
|
+
date: 2022-10-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
@@ -45,16 +45,16 @@ dependencies:
|
|
45
45
|
name: nokogiri
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- - "
|
48
|
+
- - "~>"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 1.13.0
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- - "
|
55
|
+
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
57
|
+
version: 1.13.0
|
58
58
|
description: |-
|
59
59
|
This gem allows you to get information about the steam user's games and the top 250 IMDb movies.
|
60
60
|
Information about steam games includes:
|
@@ -89,9 +89,9 @@ files:
|
|
89
89
|
- images/logo1.png
|
90
90
|
- images/logo2.png
|
91
91
|
- lib/DreamTeam.rb
|
92
|
-
- lib/DreamTeam/Films/
|
92
|
+
- lib/DreamTeam/Films/html_films_table.rb
|
93
93
|
- lib/DreamTeam/Films/parsing_films.rb
|
94
|
-
- lib/DreamTeam/Games/
|
94
|
+
- lib/DreamTeam/Games/html_games_table.rb
|
95
95
|
- lib/DreamTeam/Games/parsing_games.rb
|
96
96
|
- lib/DreamTeam/html_main.rb
|
97
97
|
- lib/DreamTeam/version.rb
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require_relative 'parsing_films'
|
2
|
-
|
3
|
-
def create_table_with_film(path)
|
4
|
-
fileHtml = File.new(path + "/table_film.html", "w+")
|
5
|
-
|
6
|
-
fileHtml.puts "<style>
|
7
|
-
.table_dark {
|
8
|
-
font-family: 'Lucida Sans Unicode', 'Lucida Grande', Sans-Serif;
|
9
|
-
font-size: 14px;
|
10
|
-
width: 90%;
|
11
|
-
text-align: left;
|
12
|
-
border-collapse: collapse;
|
13
|
-
background: #252F48;
|
14
|
-
margin: 10px;
|
15
|
-
}
|
16
|
-
.table_dark th {
|
17
|
-
color: #EDB749;
|
18
|
-
border-bottom: 1px solid #37B5A5;
|
19
|
-
padding: 12px 17px;
|
20
|
-
}
|
21
|
-
.table_dark td {
|
22
|
-
color: #CAD4D6;
|
23
|
-
border-bottom: 1px solid #37B5A5;
|
24
|
-
border-right: 1px solid #37B5A5;
|
25
|
-
padding: 7px 17px;
|
26
|
-
}
|
27
|
-
.table_dark tr:last-child td {
|
28
|
-
border-bottom: none;
|
29
|
-
}
|
30
|
-
.table_dark td:last-child {
|
31
|
-
border-right: none;
|
32
|
-
}
|
33
|
-
.table_dark tr:hover td {
|
34
|
-
text-decoration: underline;
|
35
|
-
} </style>
|
36
|
-
|
37
|
-
<table class='table_dark'>
|
38
|
-
<tr>
|
39
|
-
<th>Rang</th>
|
40
|
-
<th>Film name</th>
|
41
|
-
<th>Full name</th>
|
42
|
-
<th>Year</th>
|
43
|
-
<th>Image</th>
|
44
|
-
<th>The actors</th>
|
45
|
-
<th>Rating</th>
|
46
|
-
<th>Rating Count</th>
|
47
|
-
|
48
|
-
</tr>"
|
49
|
-
|
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}'
|
63
|
-
width = '102'
|
64
|
-
height = '160'>"
|
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>"
|
72
|
-
|
73
|
-
|
74
|
-
fileHtml.puts "</tr>"
|
75
|
-
end
|
76
|
-
|
77
|
-
fileHtml.puts "</table>"
|
78
|
-
fileHtml.close
|
79
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
require_relative 'parsing_games'
|
2
|
-
|
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>
|
43
|
-
|
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>"
|
60
|
-
|
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]
|
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>"
|
120
|
-
end
|
121
|
-
file_html.puts "</tbody>
|
122
|
-
</table>"
|
123
|
-
file_html.close
|
124
|
-
end
|