-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
184 lines (126 loc) · 4.5 KB
/
README.Rmd
1
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "##",
out.width = "100%",
fig.path = "man/figures/"
)
```
omdbr <img src="man/figures/logo.png" height="170px" align="right" style="float:right; height:170px;"/>
=======================
<!-- badges: start -->
[![R build status](https://github.com/inSileco/omdbr/workflows/R-CMD-check/badge.svg)](https://github.com/inSileco/omdbr/actions)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/omdbr)](https://cran.r-project.org/package=omdbr)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![r-universe](https://insileco.r-universe.dev/badges/omdbr)](https://insileco.r-universe.dev/ui#builds)
<!-- badges: end -->
The package `omdbr` is an R client to the [OMDb API](http://www.omdbapi.com).
User can retrieve information on movies (title, actors, year, genres, etc.)
and download cover (if available) using the [YTS API](https://yts.mx/api/v2/).
## Prerequisites
This package uses the [OMDb API](http://www.omdbapi.com) which requires an **API
Key**. You can freely obtain your own [here](http://www.omdbapi.com/apikey.aspx).
When you'll use the package `omdbr` for the first time, you'll be guided on
how to store your personal API key.
## Installation
To install the `omdbr` package, run the following command:
```{r echo=TRUE, eval=FALSE}
remotes::install_github("inSileco/omdbr")
```
and load the package:
```{r echo=TRUE, eval=TRUE}
library(omdbr)
```
<br />
<p align="center">
```{r echo=FALSE, eval=TRUE, out.width="12.5%"}
knitr::include_graphics("man/figures/tt0128445.jpg")
knitr::include_graphics("man/figures/tt0265666.jpg")
knitr::include_graphics("man/figures/tt0362270.jpg")
knitr::include_graphics("man/figures/tt0838221.jpg")
knitr::include_graphics("man/figures/tt0432283.jpg")
knitr::include_graphics("man/figures/tt1748122.jpg")
knitr::include_graphics("man/figures/tt2278388.jpg")
knitr::include_graphics("man/figures/tt5104604.jpg")
```
</p>
## Example
> **Objective**: Getting information and cover for
[_The Darjeeling Limited_](https://imdb.com/title/tt0838221) movie directed by
[Wes Anderson](https://en.wikipedia.org/wiki/Wes_Anderson).
**STEP 1**: Find the IMDb identifier of the movie
The package `omdbr` uses the IMDb ID the retrieves information and cover of a movie.
The function `find_imdb_id()` tries to find this ID.
```{r echo=TRUE, eval=TRUE}
x <- find_imdb_id("The Darjeeling Limited")
```
```{r echo=TRUE, eval=TRUE}
str(x)
```
```{r echo=FALSE, eval=TRUE}
x
```
:bulb: The argument `year` can be used to reduce results.
:bulb: You can also find this ID by searching the movie title on the
[IMDb website](https://imdb.com) and extract it from the URL.
The URL of _The Darjeeling Limited_ is:
[https://imdb.com/title/tt0838221](https://imdb.com/title/tt0838221).
**STEP 2**: Get movie information
```{r echo=FALSE, eval=TRUE}
imdb_id <- "tt0838221"
path <- "README_files/"
```
To retrieve information about the movie we will use the function `get_details()`:
```{r echo=TRUE, eval=FALSE}
x <- get_details(imdb_id = "tt0838221")
```
```{r echo=FALSE, eval=TRUE}
x <- get_details(imdb_id = "tt0838221", path = path)
```
```{r echo=TRUE, eval=TRUE}
class(x)
```
```{r echo=FALSE, eval=TRUE}
x
```
:bulb: Results are stored in `data/tt0838221.yml` (path can be changed
by using the argument `path`).
If you want to get access to these data you can use the function `read_details()`:
```{r echo=TRUE, eval=TRUE}
x <- read_details(imdb_id = "tt0838221")
```
```{r echo=FALSE, eval=TRUE}
x
```
**STEP 3**: Get movie cover
Now, we can try to download the movie cover with the function `get_cover()`:
```{r echo=TRUE, eval=FALSE}
get_cover(imdb_id = "tt0838221")
```
```{r echo=FALSE, eval=TRUE}
get_cover(imdb_id = "tt0838221", path = path)
```
<p align="center">
```{r echo=FALSE, eval=TRUE, out.width = "50%"}
covers <- list.files("man/figures", full.names = TRUE)
knitr::include_graphics("man/figures/tt0838221.jpg")
```
</p>
:bulb: Results are stored as follow:
```{r echo=TRUE, eval=FALSE}
.
├── covers
│ └──tt0838221.jpg
└── data
└──tt0838221.yml
2 directories, 2 files
```
## Code of Conduct
Please note that the `omdbr` project is released with a
[Contributor Code of
Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.