the_whos 0.0.1 → 0.0.4
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 +4 -4
- data/README.md +124 -0
- metadata +4 -4
- data/lib/the_whos.rb +0 -103
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fa5b573c4c22634ced5ecc74dda59a437367afab33fc235f2466ae629361bec
|
4
|
+
data.tar.gz: adad628b0f3cac1216e7cc515b8247e85116e281c061aa099ff7b901ca45a3c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16a09550fa24191ffe86350e6cb9f6dfcef58c2e0965c6655a6515fce3efea8f5c7f78242f93eba68fa46dbfd7808995f8d3148b7659be0f3c7987a229e8b6ee
|
7
|
+
data.tar.gz: a1bb5ebead1ec6341f97152c310865087b2246bbcc4bd2660978fefaf84e43e61783a091573c5f493a402e55d036e8ef5697af437dc6e59dd5b818e7b6878371
|
data/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# The Whos
|
2
|
+
|
3
|
+
## Api Key IMDB
|
4
|
+
Para poder realizar llamadas se requiere ingresar la clave de la api de IMDB, para obtener una clave gratuita tiene que registrase en el sitio de la API, [IMDB API](https://imdb-api.com/Identity/Account/Register), las cuentas gratuitas tienen un límite de 100 consultas por día.
|
5
|
+
Pará poder utilizar la clave se tiene que pasar el valor en la línea de comandos antes de ejecutar el script.
|
6
|
+
```
|
7
|
+
$ ruby example.rb k_12345678
|
8
|
+
```
|
9
|
+
## Class Title
|
10
|
+
Esta clase se encarga de almacenar la información de la llamada de los títulos.
|
11
|
+
Pará instancia el objeto se puede hacer a través de `Title.new` o `TheWhos.create` pasando como parámetro el ID de el título de IMDB.
|
12
|
+
```
|
13
|
+
movie = Title.new('tt0088763')
|
14
|
+
|
15
|
+
movie = TheWhos.create('tt0088763')
|
16
|
+
```
|
17
|
+
### Método id
|
18
|
+
Devuelve el ID del título.
|
19
|
+
```
|
20
|
+
movie = Title.new('tt0088763')
|
21
|
+
movie.id
|
22
|
+
|
23
|
+
# => "tt0088763"
|
24
|
+
```
|
25
|
+
### Método title
|
26
|
+
Devuelve el título.
|
27
|
+
```
|
28
|
+
movie = Title.new('tt0088763')
|
29
|
+
movie.title
|
30
|
+
|
31
|
+
# => "Back to the Future"
|
32
|
+
```
|
33
|
+
### Método cast
|
34
|
+
Devuelve un array con los 10 actores principales
|
35
|
+
```
|
36
|
+
movie = Title.new('tt0088763')
|
37
|
+
movie.cast
|
38
|
+
```
|
39
|
+
### Método fullcast
|
40
|
+
Devuelve un array con el reparto completo del título.
|
41
|
+
```
|
42
|
+
movie = Title.new('tt0088763')
|
43
|
+
movie.fullcast
|
44
|
+
```
|
45
|
+
### Método plot
|
46
|
+
Devuelve la sinopsis del título, se puede pasar como valor el idioma en el que se desee la respuesta, el valor por defecto es en inglés.
|
47
|
+
```
|
48
|
+
movie = Title.new('tt0088763')
|
49
|
+
movie.plot('es')
|
50
|
+
```
|
51
|
+
|
52
|
+
## Class Actor
|
53
|
+
Esta clase se encarga de almacenar la información de la llamada de los actores.
|
54
|
+
Pará instancia el objeto se puede hacer a través de `Actor.new` o `TheWhos.create` pasando como parámetro el ID de el actor de IMDB.
|
55
|
+
```
|
56
|
+
fox = Actor.new('nm0000150')
|
57
|
+
|
58
|
+
fox = TheWhos.create('nm0000150')
|
59
|
+
```
|
60
|
+
### Método id
|
61
|
+
Devuelve el ID del actor.
|
62
|
+
```
|
63
|
+
fox = Actor.new('nm0000150')
|
64
|
+
fox.id
|
65
|
+
|
66
|
+
# => "nm0000150"
|
67
|
+
```
|
68
|
+
### Método name
|
69
|
+
Devuelve el nombre del actor.
|
70
|
+
```
|
71
|
+
fox = Actor.new('nm0000150')
|
72
|
+
fox.name
|
73
|
+
|
74
|
+
# => "Michael J. Fox"
|
75
|
+
```
|
76
|
+
### Método known
|
77
|
+
Devuelve un array de las películas mas conocidas del actor.
|
78
|
+
```
|
79
|
+
fox = Actor.new('nm0000150')
|
80
|
+
fox.known
|
81
|
+
```
|
82
|
+
|
83
|
+
### Método cast
|
84
|
+
Devuelve todas las películas en las que el actor a participado.
|
85
|
+
```
|
86
|
+
fox = Actor.new('nm0000150')
|
87
|
+
fox.cast
|
88
|
+
```
|
89
|
+
|
90
|
+
## Class TheWhos
|
91
|
+
Está es la clase principal para trabajar con la información obtenida de las consultas la api de IMDB.
|
92
|
+
### Método create
|
93
|
+
Con este método se puede instanciar un objeto, detecta automáticamente si es una película o un actor y crea la clase correspondiente.
|
94
|
+
```
|
95
|
+
movie = TheWhos.create('tt0088763')
|
96
|
+
fox = TheWhos.create('nm0000150')
|
97
|
+
```
|
98
|
+
### Método search_title
|
99
|
+
Devuelve un array con el ID y título de la películas que coincidan con el parámetro.
|
100
|
+
```
|
101
|
+
rest = TheWhos.search_title('back to the future')
|
102
|
+
```
|
103
|
+
### Método search_actor
|
104
|
+
Devuelve un array con el ID y nombre del actor que coincida con el parámetro.
|
105
|
+
```
|
106
|
+
rest = TheWhos.search_actor('michael fox')
|
107
|
+
```
|
108
|
+
### Método match_actor
|
109
|
+
Devuelve un array con el ID y nombre de los actores que coincidan entre dos películas, si es que lo hay, se puede pasar como parámetro el ID del título de IMDB o un objeto ya instansiado de una película.
|
110
|
+
```
|
111
|
+
match = TheWhos.match_actor ('tt0088763','tt0101272')
|
112
|
+
```
|
113
|
+
### Método match_title
|
114
|
+
Devuelve un array con el ID y nombre de las películas que coincidan entre dos actores, si es que lo hay, se puede pasar como parámetro el ID del actor de IMDB o un objeto ya instanciado de un actor.
|
115
|
+
```
|
116
|
+
match = TheWhos.match_title ('nm0000150', 'nm0000502')
|
117
|
+
```
|
118
|
+
### Método who
|
119
|
+
Devuelve el personaje que interpreta un actor en una película, si es que actúa en esa película, se puede pasar como parámetros los ID de IMDB o los objetos ya instanciados.
|
120
|
+
```
|
121
|
+
charater = TheWhos.who ('tt0088763', 'nm0000150')
|
122
|
+
|
123
|
+
# => "Marty McFly"
|
124
|
+
```
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_whos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramiro Eloisa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Trabaja con los ID de IMDB para devolver en forma de array informacion como:
|
@@ -20,8 +20,8 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
|
-
-
|
24
|
-
homepage:
|
23
|
+
- README.md
|
24
|
+
homepage: https://github.com/RamEloisa/the_whos.git
|
25
25
|
licenses:
|
26
26
|
- MIT
|
27
27
|
metadata: {}
|
data/lib/the_whos.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require_relative 'title'
|
2
|
-
require_relative 'actor'
|
3
|
-
|
4
|
-
class TheWhos
|
5
|
-
@key_imdb = ARGV[0]
|
6
|
-
|
7
|
-
def self.create(id)
|
8
|
-
if id.chr == 't'
|
9
|
-
return Title.new(id)
|
10
|
-
elsif id.chr == 'n'
|
11
|
-
return Actor.new(id)
|
12
|
-
else
|
13
|
-
return 'Error'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.search_title(expression)
|
18
|
-
expression = expression.gsub(' ', '@')
|
19
|
-
url = "https://imdb-api.com/en/API/SearchTitle/#{@key_imdb}/#{expression}"
|
20
|
-
response = RestClient.get url
|
21
|
-
r_json = JSON.parse response.to_str
|
22
|
-
arr_search = r_json['results'].to_a
|
23
|
-
results = Array.new
|
24
|
-
arr_search.size.times do |i|
|
25
|
-
results << {id: "#{arr_search[i]['id']}", title: "#{arr_search[i]['title']}"}
|
26
|
-
end
|
27
|
-
return results
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.search_actor(expression)
|
31
|
-
expression = expression.gsub(' ', '@')
|
32
|
-
url = "https://imdb-api.com/en/API/SearchName/#{@key_imdb}/#{expression}"
|
33
|
-
response = RestClient.get url
|
34
|
-
r_json = JSON.parse response.to_str
|
35
|
-
arr_search = r_json['results'].to_a
|
36
|
-
results = Array.new
|
37
|
-
arr_search.size.times do |i|
|
38
|
-
results << {id: "#{arr_search[i]['id']}", title: "#{arr_search[i]['title']}"}
|
39
|
-
end
|
40
|
-
return results
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.match_title(title_a, title_b)
|
44
|
-
if title_a.class == String
|
45
|
-
title_a = Title.new(title_a)
|
46
|
-
end
|
47
|
-
if title_b.class == String
|
48
|
-
title_b = Title.new(title_b)
|
49
|
-
end
|
50
|
-
match = Array.new
|
51
|
-
title_a.fullcast.each do |actor_a|
|
52
|
-
title_b.fullcast.each do |actor_b|
|
53
|
-
if actor_a[:id] == actor_b[:id]
|
54
|
-
match << "#{actor_a[:actor].to_s} (#{actor_a[:id]})"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
if match.empty? == true
|
59
|
-
return 'Not Match'
|
60
|
-
else
|
61
|
-
return match
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.match_actor(actor_a, actor_b)
|
66
|
-
if actor_a.class == String
|
67
|
-
actor_a = Actor.new(actor_a)
|
68
|
-
end
|
69
|
-
if actor_b.class == String
|
70
|
-
actor_b = Actor.new(actor_b)
|
71
|
-
end
|
72
|
-
match = Array.new
|
73
|
-
actor_a.cast.each do |title_a|
|
74
|
-
actor_b.cast.each do |title_b|
|
75
|
-
if title_a[:id] == title_b[:id]
|
76
|
-
match << "#{title_a[:title]} (#{title_a[:id]})"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
if match.empty? == true
|
81
|
-
return 'Not Match'
|
82
|
-
else
|
83
|
-
return match
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.who(title, actor)
|
88
|
-
if title.class == String
|
89
|
-
title = Title.new(title)
|
90
|
-
end
|
91
|
-
if actor.class == String
|
92
|
-
actor = Actor.new(actor)
|
93
|
-
end
|
94
|
-
title.fullcast.each do |cast|
|
95
|
-
if cast[:id] == actor.id
|
96
|
-
return cast[:character]
|
97
|
-
end
|
98
|
-
end
|
99
|
-
return 'not appear'
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
end
|