-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
362 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: omdbapi | ||
Title: Tools to Access Movie, Television and Game Data from the 'Open Movie Database' | ||
Version: 0.1.0.9000 | ||
Version: 0.2.0.9000 | ||
Authors@R: c(person("Bob", "Rudis", email = "[email protected]", role = c("aut", "cre"))) | ||
Description: Provides API access to the 'Open Movie Database' which maintains metadata | ||
about movies, games and television shows through a public API. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#' Get actors from an omdb object as a vector | ||
#' | ||
#' Splits the field at commas and returns a vector of individual entries | ||
#' | ||
#' @param omdb an object returned by \code{find_by_title} or \code{find_by_id} | ||
#' @export | ||
#' @return A character vector of actors | ||
#' @examples | ||
#' get_actors(find_by_id("tt0031381")) | ||
get_actors <- function(omdb) { | ||
|
||
if (!inherits(omdb, "omdb")) { | ||
message("get_actors() expects an omdb object") | ||
return(NULL) | ||
} | ||
|
||
if ("Actors" %in% names(omdb)) { | ||
str_split(omdb$Actors, ",[ ]*")[[1]] | ||
} | ||
|
||
} | ||
|
||
#' Get directors from an omdb object as a vector | ||
#' | ||
#' Splits the field at commas and returns a vector of individual entries | ||
#' | ||
#' @param omdb an object returned by \code{find_by_title} or \code{find_by_id} | ||
#' @export | ||
#' @return A character vector of directors | ||
#' @examples | ||
#' get_directors(find_by_id("tt0031381")) | ||
get_directors <- function(omdb) { | ||
|
||
if (!inherits(omdb, "omdb")) { | ||
message("get_directors() expects an omdb object") | ||
return(NULL) | ||
} | ||
|
||
if ("Director" %in% names(omdb)) { | ||
str_split(omdb$Director, ",[ ]*")[[1]] | ||
} | ||
|
||
} | ||
|
||
#' Get writers from an omdb object as a vector | ||
#' | ||
#' Splits the field at commas and returns a vector of individual entries | ||
#' | ||
#' @param omdb an object returned by \code{find_by_title} or \code{find_by_id} | ||
#' @export | ||
#' @return A character vector of writers | ||
#' @examples | ||
#' get_writers(find_by_id("tt0031381")) | ||
get_writers <- function(omdb) { | ||
|
||
if (!inherits(omdb, "omdb")) { | ||
message("get_writers() expects an omdb object") | ||
return(NULL) | ||
} | ||
|
||
if ("Writer" %in% names(omdb)) { | ||
str_split(omdb$Writer, ",[ ]*")[[1]] | ||
} | ||
|
||
} | ||
|
||
#' Get countries from an omdb object as a vector | ||
#' | ||
#' Splits the field at commas and returns a vector of individual entries | ||
#' | ||
#' @param omdb an object returned by \code{find_by_title} or \code{find_by_id} | ||
#' @export | ||
#' @return A character vector of countries | ||
#' @examples | ||
#' get_countries(find_by_id("tt0031381")) | ||
get_countries <- function(omdb) { | ||
|
||
if (!inherits(omdb, "omdb")) { | ||
message("get_countries() expects an omdb object") | ||
return(NULL) | ||
} | ||
|
||
if ("Country" %in% names(omdb)) { | ||
str_split(omdb$Country, ",[ ]*")[[1]] | ||
} | ||
|
||
} | ||
|
||
#' Get genres from an omdb object as a vector | ||
#' | ||
#' Splits the field at commas and returns a vector of individual entries | ||
#' | ||
#' @param omdb an object returned by \code{find_by_title} or \code{find_by_id} | ||
#' @export | ||
#' @return A character vector of genres | ||
#' @examples | ||
#' get_genres(find_by_id("tt0031381")) | ||
get_genres <- function(omdb) { | ||
|
||
if (!inherits(omdb, "omdb")) { | ||
message("get_genres() expects an omdb object") | ||
return(NULL) | ||
} | ||
|
||
if ("Genre" %in% names(omdb)) { | ||
str_split(omdb$Genre, ",[ ]*")[[1]] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
fix_omdb <- function(x) { | ||
|
||
if ("Released" %in% colnames(x)) x$Released <- as.Date(x$Released, format="%d %b %Y") | ||
if ("DVD" %in% colnames(x)) x$DVD <- as.Date(x$DVD, format="%d %b %Y") | ||
|
||
if ("imdbRating" %in% colnames(x)) x$imdbRating <- as.numeric(x$imdbRating) | ||
if ("imdbVotes" %in% colnames(x)) x$imdbVotes <- as.numeric(gsub(",", "", x$imdbVotes)) | ||
if ("tomatoRating" %in% colnames(x)) x$tomatoRating <- as.numeric(x$tomatoRating) | ||
if ("tomatoUserRating" %in% colnames(x)) x$tomatoUserRating <- as.numeric(x$tomatoUserRating) | ||
|
||
if ("tomatoMeter" %in% colnames(x)) x$tomatoMeter <- as.integer(x$tomatoMeter) | ||
if ("tomatoReviews" %in% colnames(x)) x$tomatoReviews <- as.integer(x$tomatoReviews) | ||
if ("tomatoFresh" %in% colnames(x)) x$tomatoFresh <- as.integer(x$tomatoFresh) | ||
if ("tomatoRotten" %in% colnames(x)) x$tomatoRotten <- as.integer(x$tomatoRotten) | ||
if ("tomatoUserMeter" %in% colnames(x)) x$tomatoUserMeter <- as.numeric(x$tomatoUserMeter) | ||
if ("tomatoUserReviews" %in% colnames(x)) x$tomatoUserReviews <- as.integer(x$tomatoUserReviews) | ||
|
||
x | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.