-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommentaireoriginaldesignalayout.R
59 lines (47 loc) · 1.7 KB
/
commentaireoriginaldesignalayout.R
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
library(shiny)
library(plyr)
library(tuber)
library(purrr)
options(max.print=100000000)
ui <- fluidPage(
title = "YT Comments",
titlePanel("Ranking YouTube Comments"),
sidebarLayout(
sidebarPanel(
p("Sort and Rank Comments of a YouTube Video"),
helpText("The key for a YouTube video is the code at the end of a YouTube link as shown in", strong("bold"), "below"),
p("www.youtube.com/watch?v=",strong("1SvZsXAMpqQ")),
textInput(inputId = "commentkey",
label = "Enter YouTube Comment Key:",
value = ""),
downloadButton("downloadCSV", "Download CSV"),
br(),
br(),
strong("Video Details"),
textOutput('commentsdetails')
),
mainPanel(
id = 'dataset',
DT::dataTableOutput("commenttable")
)
)
)
server <- function(input, output) {
output$commentsdetails <- renderText({ paste(get_video_details(input$commentkey))})
output$commenttable <- DT::renderDataTable({
validate(
need(input$commentkey != '', 'Please enter YouTube Key...(some comments may take a long time to load)')
)
DT::datatable(get_all_comments(input$commentkey, src = "youtube", auto.assign = FALSE, colnames = c('Comment' = 2)),
options = list(pageLength = 10,lengthMenu = list(c(5, 15, -1), list('5', '15', 'All'))))
})
output$downloadCSV <- downloadHandler(
filename = function() {
paste("YT.csv", sep = "")
},
content = function(file) {
write.csv(get_all_comments(input$comments, src = "youtube", auto.assign = FALSE), file)
}
)
}
shinyApp(ui, server)