Skip to content

Commit 3e63f5b

Browse files
committedOct 4, 2019
Let's make this 0.15.0
1 parent d2b73eb commit 3e63f5b

17 files changed

+54
-41
lines changed
 

‎DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: tRakt
33
Title: Get Data from 'trakt.tv'
4-
Version: 0.14.0.9000
4+
Version: 0.15.0
55
Authors@R:
66
person(given = "Lukas",
77
family = "Burk",

‎NEWS.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# tRakt 0.14.0.90000
1+
# tRakt 0.15.0
22

3-
This is a big one, like v1.0.0 big one.
3+
This is a big one, but not 1.0.0 big one I guess.
4+
This is a consolidation release with lots of internal improvements, but for the 1.0.0 I decided to overhaul the structure of the package *again*, so before I completely break any kind of backwards compatiblity, I thought I'd get this one out.
45

56
## Consolidation for the people
67

‎R/api.R

+10-5
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@
4343
#' }
4444
trakt_credentials <- function(username, client_id, silent = TRUE) {
4545
username <- ifelse(missing(username),
46-
Sys.getenv("trakt_username"), username)
46+
Sys.getenv("trakt_username"), username
47+
)
4748
client_id <- ifelse(missing(client_id),
48-
Sys.getenv("trakt_client_id"), client_id)
49+
Sys.getenv("trakt_client_id"), client_id
50+
)
4951

5052
if (username != "") {
5153
options(trakt_username = username)
@@ -58,8 +60,10 @@ trakt_credentials <- function(username, client_id, silent = TRUE) {
5860
} else {
5961
options(trakt_client_id = tRakt_client_id)
6062
if (!silent) {
61-
message("I provided my client_id as a fallback for you. ",
62-
"Please use it responsibly.")
63+
message(
64+
"I provided my client_id as a fallback for you. ",
65+
"Please use it responsibly."
66+
)
6367
}
6468
}
6569

@@ -195,7 +199,8 @@ trakt_get_token <- function() {
195199

196200
# 3. Get OAuth credentials
197201
oauth2.0_token(
198-
trakt_endpoint, app, use_oob = TRUE,
202+
trakt_endpoint, app,
203+
use_oob = TRUE,
199204
config_init = user_agent("https://github.com/jemus42/tRakt")
200205
)
201206
}

‎R/fanarttv.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fanarttv_get <- function(tvdb) {
3434
)
3535

3636
res_y <- res[!(names(res) %in% c("name", "thetvdb_id"))] %>%
37-
map(~list(.x)) %>%
37+
map(~ list(.x)) %>%
3838
as_tibble()
3939

4040
bind_cols(res_x, res_y)

‎R/omdb_get.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
#' }
2222
omdb_get <- function(imdb) {
2323
base_url <- modify_url("https://www.omdbapi.com/",
24-
query = list(apikey = Sys.getenv("OMDB_API_KEY")))
24+
query = list(apikey = Sys.getenv("OMDB_API_KEY"))
25+
)
2526

2627
url <- modify_url(base_url, query = list(i = imdb))
2728

‎R/trakt-people.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ trakt.media.people <- function(type = c("shows", "movies"), target,
174174
url <- build_trakt_url(type, target, "people", extended = extended)
175175
response <- trakt_get(url = url)
176176

177-
if (is_empty(response)) return(tibble())
177+
if (is_empty(response)) {
178+
return(tibble())
179+
}
178180

179181
# Flatten the data.frame
180182
if (has_name(response, "cast") & !is_empty(response$cast)) {

‎R/trakt-search.R

+8-5
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,23 @@
4848
trakt.search <- function(query, type = "show",
4949
years = NULL, n_results = 1L,
5050
extended = c("min", "full")) {
51-
5251
ok_types <- c("movie", "show", "episode", "person", "list")
5352
type <- match.arg(type, choices = ok_types, several.ok = TRUE)
5453
extended <- match.arg(extended)
5554
years <- check_filter_arg(years, "years")
5655

5756
if (length(type) > 1) {
58-
return(map_df(type, ~ trakt.search(query, type = .x, years,
59-
n_results, extended)))
57+
return(map_df(type, ~ trakt.search(query,
58+
type = .x, years,
59+
n_results, extended
60+
)))
6061
}
6162

6263
# Construct URL, make API call
63-
url <- build_trakt_url("search", type, query = query, years = years,
64-
extended = extended)
64+
url <- build_trakt_url("search", type,
65+
query = query, years = years,
66+
extended = extended
67+
)
6568
response <- trakt_get(url = url)
6669

6770
if (identical(response, tibble())) {

‎R/trakt-seasons.R

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ trakt.seasons.season <- function(target, seasons = 1L, extended = c("min", "full
7979
#' @examples
8080
#' # Get just the season numbers and their IDs
8181
#' trakt.seasons.summary("breaking-bad", extended = "min")
82-
#'
8382
#' \dontrun{
8483
#' # Get season numbers, ratings, votes, titles and other metadata as well as
8584
#' # a list-column containing all episode data

‎R/trakt-user-collection.R

+5-2
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ trakt.user.collection <- function(user = getOption("trakt_username"),
4242
if (length(user) > 1) {
4343
names(user) <- user
4444
return(map_df(user, ~ trakt.user.collection(user = .x, type, unnest_episodes),
45-
.id = "user"))
45+
.id = "user"
46+
))
4647
}
4748

4849
# Construct URL, make API call
4950
url <- build_trakt_url("users", user, "collection", type)
5051
response <- trakt_get(url = url)
5152

52-
if (is_empty(response)) return(tibble())
53+
if (is_empty(response)) {
54+
return(tibble())
55+
}
5356

5457
if (type == "shows") {
5558
response <- response %>%

‎R/trakt-user-history.R

+8-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#' trakt.user.history(
3131
#' user = "jemus42", type = "shows", limit = 5,
3232
#' start_at = "2015-12-24", end_at = "2015-12-28"
33-
#' )
33+
#' )
3434
#' }
3535
trakt.user.history <- function(user = getOption("trakt_username"),
3636
type = c("shows", "movies"),
@@ -41,12 +41,13 @@ trakt.user.history <- function(user = getOption("trakt_username"),
4141
extended <- match.arg(extended)
4242

4343
start_at <- if (!is.null(start_at)) format(as.POSIXct(start_at), "%FT%T.000Z", tz = "UTC")
44-
end_at <- if (!is.null(end_at)) format(as.POSIXct(end_at), "%FT%T.000Z", tz = "UTC")
44+
end_at <- if (!is.null(end_at)) format(as.POSIXct(end_at), "%FT%T.000Z", tz = "UTC")
4545

4646
if (length(user) > 1) {
4747
names(user) <- user
4848
return(map_df(user, ~ trakt.user.history(user = .x, type, limit, start_at, end_at, extended),
49-
.id = "user"))
49+
.id = "user"
50+
))
5051
}
5152

5253
# Construct URL, make API call
@@ -56,7 +57,9 @@ trakt.user.history <- function(user = getOption("trakt_username"),
5657
response <- trakt_get(url = url)
5758
response <- as_tibble(response)
5859

59-
if (identical(response, tibble())) return(response)
60+
if (identical(response, tibble())) {
61+
return(response)
62+
}
6063

6164
if (type == "shows") {
6265
response <- bind_cols(
@@ -71,7 +74,7 @@ trakt.user.history <- function(user = getOption("trakt_username"),
7174
bind_cols(fix_ids(response$episode$ids)) %>%
7275
rename(episode = number) %>%
7376
fix_tibble_response() %>%
74-
rename_all(~paste0("episode_", .x))
77+
rename_all(~ paste0("episode_", .x))
7578
)
7679
}
7780
if (type == "movies") {

‎R/trakt-user-watched.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ trakt.user.watched <- function(user = getOption("trakt_username"),
4141
url <- build_trakt_url("users", user, "watched", type, extended = extended)
4242
response <- trakt_get(url = url)
4343

44-
if (identical(response, tibble())) return(response)
44+
if (identical(response, tibble())) {
45+
return(response)
46+
}
4547

4648
if (type == "shows") {
4749
# Unpack the show media object and bind it to the base tbl

‎R/utils-extract-fix.R

+5-8
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fix_datetime <- function(response) {
175175

176176
if (inherits(response, "data.frame")) {
177177
response %>%
178-
mutate_at(.vars = vars(datevars), ~{
178+
mutate_at(.vars = vars(datevars), ~ {
179179
# Don't convert already POSIXct vars
180180
if (!(inherits(.x, "POSIXct"))) {
181181
ymd_hms(.x)
@@ -242,7 +242,6 @@ fix_missing <- function(x) {
242242
#' @keywords internal
243243
#' @importFrom httr stop_for_status
244244
check_username <- function(user, validate = FALSE) {
245-
246245
fail_empty_chr <- identical(user, "")
247246
fail_null <- is.null(user)
248247
fail_chr <- !is.character(user)
@@ -284,7 +283,9 @@ check_filter_arg <- function(filter,
284283
filter_type <- match.arg(filter_type)
285284

286285
# Empty in, empty out. Can't explain that.
287-
if (is_empty(filter) | identical(filter, "")) return(NULL)
286+
if (is_empty(filter) | identical(filter, "")) {
287+
return(NULL)
288+
}
288289

289290
if (filter_type == "query") {
290291
filter <- as.character(filter)
@@ -303,7 +304,7 @@ check_filter_arg <- function(filter,
303304
if (grepl(x = filter, pattern = "(^\\d{4}-\\d{4}$)|(^\\d{4}$)")) {
304305
filter
305306
} else {
306-
warning("'years' must be interpretable as 4 digit year or range of 4-digit years")
307+
warning("'years' must be interpretable as 4 digit year or range of 4-digit years")
307308
}
308309
}
309310
if (filter_type == "runtimes") {
@@ -344,19 +345,15 @@ check_filter_arg <- function(filter,
344345
}
345346
if (filter_type == "genres") {
346347
filter <- check_filter_arg_fixed(filter, filter_type, genres$slug)
347-
348348
}
349349
if (filter_type == "languages") {
350350
filter <- check_filter_arg_fixed(filter, filter_type, languages$code)
351-
352351
}
353352
if (filter_type == "countries") {
354353
filter <- check_filter_arg_fixed(filter, filter_type, countries$code)
355-
356354
}
357355
if (filter_type == "certifications") {
358356
filter <- check_filter_arg_fixed(filter, filter_type, certifications$slug)
359-
360357
}
361358
if (filter_type == "networks") {
362359
filter <- check_filter_arg_fixed(filter, filter_type, networks)

‎data-raw/episodes.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ library(stringr)
66
library(tidyr)
77

88
# Futurama ----
9-
futurama <- trakt.seasons.season("futurama", seasons = 1:7, extended = "full")
9+
futurama <- trakt.seasons.season("futurama", seasons = 1:7, extended = "full")
1010
usethis::use_data(futurama, overwrite = TRUE)
1111

1212

‎data-raw/static_data.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ languages <- full_join(
1414
trakt_get("languages/movies"),
1515
trakt_get("languages/shows"),
1616
by = c("name", "code")
17-
) %>%
17+
) %>%
1818
as_tibble()
1919

2020
use_data(languages, overwrite = TRUE)
@@ -24,7 +24,7 @@ genres <- full_join(
2424
trakt_get("genres/movies"),
2525
trakt_get("genres/shows"),
2626
by = c("name", "slug")
27-
) %>%
27+
) %>%
2828
as_tibble()
2929

3030
use_data(genres, overwrite = TRUE)
@@ -34,13 +34,13 @@ countries <- full_join(
3434
trakt_get("countries/movies"),
3535
trakt_get("countries/shows"),
3636
by = c("name", "code")
37-
) %>%
37+
) %>%
3838
as_tibble()
3939

4040
use_data(countries, overwrite = TRUE)
4141

4242
# Certifications ----
43-
certifications <- map_df(c("movies", "shows"), ~{
43+
certifications <- map_df(c("movies", "shows"), ~ {
4444
trakt_get(build_trakt_url("certifications", .x)) %>%
4545
map_df(as_tibble, .id = "country") %>%
4646
mutate(type = .x)

‎tests/testthat/test-misc.R

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ test_that("check_user throws errors when it should", {
4848
})
4949

5050
test_that("check_filter_arg fails how it should", {
51-
5251
expect_null(check_filter_arg(NULL))
5352

5453
expect_warning(check_filter_arg(10239, "years"))

‎tests/testthat/test-stats.R

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ test_that("trakt.user.stats works", {
2020
"movies", "shows", "seasons", "episodes",
2121
"network", "ratings"
2222
))
23-
2423
})
2524

2625
test_that("trakt.media.stats does things", {

‎tests/testthat/test-user-friendfollow.R

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ test_that("trakt.user.network works", {
2727
})
2828

2929
test_that("No NULLs or \"\" in trakt.user.network", {
30-
3130
friends <- trakt.user.network("followers", "jemus42", "full")
3231
expect_true(!any(map_lgl(friends, function(col) any(is.null(col)))))
3332
expect_true(!any(map_lgl(friends, function(col) any(identical(col, "")))))

0 commit comments

Comments
 (0)
Please sign in to comment.