Browse Source

Static data and restart on update

master
Maxime Wack 6 years ago
parent
commit
61564a33ed
2 changed files with 21 additions and 24 deletions
  1. +13
    -24
      app.R
  2. +8
    -0
      dl_imdb.sh

+ 13
- 24
app.R View File

@@ -1,43 +1,32 @@
library(tidyverse)
library(plotly)

readRDS("imdb.rds") -> imdb

imdb %>%
distinct(id, .keep_all = T) %>%
mutate(title = str_c(seriesTitle, " (", startYear, ")")) %>%
select(id, title) -> shows

shows$id %>%
setNames(shows$title) -> shows

ui <- fluidPage(
inputPanel(width = "20%", height = "100%",
uiOutput("show_choice")
h1("GraphTV"),
selectizeInput("show", "Search show", shows, selected = "tt0944947", width = "600px")
),
plotlyOutput("show_graph", width = "100%", height = "800px")
)

server <- function(input, output, session)
{
imdb <- reactive({
readRDS("imdb.rds")
})

shows <- reactive({
req(imdb())

imdb() %>%
distinct(id, .keep_all = T) %>%
mutate(title = str_c(seriesTitle, " (", startYear, ")")) %>%
select(id, title) -> shows

shows$id %>%
setNames(shows$title)
})

output$show_choice <- renderUI({
req(shows())

selectizeInput("show", "Please choose…", shows(), selected = "")
})

output$show_graph <- renderPlotly({
req(input$show)

show_id <- input$show

imdb() %>%
imdb %>%
filter(id == show_id) %>%
collect %>%
mutate_at(vars(season, episode, averageRating, numVotes), as.numeric) %>%


+ 8
- 0
dl_imdb.sh View File

@@ -1,3 +1,11 @@
cd /srv/shiny/GraphTV

curl https://datasets.imdbws.com/title.basics.tsv.gz | gzip -d | cut -f 1-3,6 | sed 's/"/\\"/g' > basics.tsv
curl https://datasets.imdbws.com/title.ratings.tsv.gz | gzip -d > ratings.tsv
curl https://datasets.imdbws.com/title.episode.tsv.gz | gzip -d > episodes.tsv

Rscript preprocess.R

rm *.tsv

touch restart.txt

Loading…
Cancel
Save