Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Get-UDDashboard | Stop-UDDashboard
  2. # Palette (Darkest to lightest)
  3. #383c4a
  4. #404552
  5. #4b5162
  6. #7c818c
  7. #5294e2 (Blue Accent Color)
  8.  
  9. $Theme = New-UDTheme -Name "Basic" -Definition @{
  10.     UDDashboard = @{
  11.         BackgroundColor = "#292d3e"
  12.         FontColor       = "#b2b4c1"
  13.     }
  14.     UDFooter    = @{
  15.         BackgroundColor = "#292d3e"
  16.         FontColor       = "#292d3e"
  17.     }
  18.     UDNavBar    = @{
  19.         BackgroundColor = "#383c4a"
  20.         FontColor       = "#b2b4c1"
  21.     }
  22.     UDCard      = @{
  23.         BackgroundColor = "#383c4a"
  24.         FontColor       = "#b2b4c1"
  25.     }
  26.     UDChart     = @{
  27.         BackgroundColor = "#292d3e"
  28.         FontColor       = "#b2b4c1"
  29.     }
  30.     UDCounter   = @{
  31.         BackgroundColor = "#292d3e"
  32.         FontColor       = "#b2b4c1"
  33.     }
  34.     UDMonitor   = @{
  35.         BackgroundColor = "#292d3e"
  36.         FontColor       = "#b2b4c1"
  37.     }
  38.     UDGrid      = @{
  39.         BackgroundColor = "#292d3e"
  40.         FontColor       = "#b2b4c1"
  41.     }
  42.     UDTable     = @{
  43.         BackgroundColor = "#292d3e"
  44.         FontColor       = "#b2b4c1"
  45.     }
  46.     UDInput     = @{
  47.         BackgroundColor = "#292d3e"
  48.         FontColor       = "#b2b4c1"
  49.     }
  50. }
  51.  
  52. $Cache:MyGoodReadsID = ""
  53. $Cache:API_key = ""
  54. $Cache:Api_secret = ""
  55.  
  56. $Schedule30 = New-UDEndpointSchedule -Every 30 -Minute
  57.  
  58. function Get-Books {
  59.     $r = Invoke-WebRequest -Uri "https://www.goodreads.com/review/list/$Cache:MyGoodReadsID.xml?key=$($Cache:API_key)&v=2&per_page=200&shelf=Read"
  60.     $ResponseContentXML = [XML]$r.Content
  61.     $AllBooksInfo = $ResponseContentXML.GoodreadsResponse.reviews.review.book
  62.  
  63.     $MyBooks = foreach ($Book in $AllBooksInfo) {
  64.         $URL = "https://www.goodreads.com/work/$($Book.work.id)/series?format=xml&key=$($Cache:API_key)"
  65.         $Response = Invoke-WebRequest -Uri $URL -Method Get -UseBasicParsing
  66.         [XML]$series_overview_XML = $Response.Content
  67.         [INT]$series_overview_work_id = $series_overview_XML.GoodreadsResponse.series_works.series_work.series.id | Select -First 1
  68.         [INT]$series_overview_primary_work_count = $series_overview_XML.GoodreadsResponse.series_works.series_work.series.primary_work_count | Select -First 1
  69.         if ($series_overview_XML.GoodreadsResponse.series_works.series_work.series.title."#cdata-section") {
  70.             [STRING]$series_overview_title = ($series_overview_XML.GoodreadsResponse.series_works.series_work.series.title."#cdata-section").trim()
  71.         }
  72.         else { [STRING]$series_overview_title = 'No Series Found' }
  73.  
  74.         [pscustomobject]@{
  75.             id                                 = $Book.id.'#text'
  76.             title_without_series               = $Book.id.title_without_series
  77.             title                              = $Book.title
  78.             small_image_url                    = $Book.small_image_url
  79.             large_image_url                    = $Book.large_image_url
  80.             link                               = $Book.link
  81.             description                        = $Book.description
  82.             work_id                            = $Book.work.id
  83.             author_image_url                   = $Book.authors.author.image_url
  84.             author_small_image_url             = $Book.authors.author.small_image_url
  85.             author_id                          = $Book.authors.author.id
  86.             series_overview_XML                = $series_overview_XML
  87.             series_overview_title              = $series_overview_title
  88.             series_overview_primary_work_count = $series_overview_primary_work_count
  89.             series_overview_work_id            = $series_overview_work_id
  90.             owned_books_in_series              = "0"
  91.         }
  92.         Start-Sleep -Seconds 1
  93.     }
  94.     Write-Output $MyBooks
  95. }
  96.  
  97.  
  98. $EI = New-UDEndpointInitialization -Function @("Get-Books")
  99.  
  100. $EndpointMyBooks = New-UDEndpoint -Schedule $Schedule30 -Endpoint {
  101.     $Cache:MyBooks = Get-Books
  102. }
  103.  
  104.  
  105. $SeriesCollection = @()
  106. foreach ($Series in ($MyBooks.series_overview_title | Sort-Object -Unique)) {
  107.     $NewPage = New-UDPage -Name "$Series" -Icon "home" -Content {
  108.         New-UDCard }
  109.  
  110.     New-Variable -Name $Series.Replace(" ", "_") -Value $NewPage -Force
  111.     $SeriesCollection += $Series.Replace(" ", "_")
  112. }
  113.  
  114. $a = @()
  115. foreach ($Series in $SeriesCollection) {
  116.     $a += ("$" + "$Series")
  117. }
  118. #$allVaribles = $a -join ","
  119.  
  120.  
  121. # Create Dashboard and Add Pages.
  122. $MyBooksDashboard = New-UDDashboard -Theme $Theme -Title "GRDB" -Pages @($a) -EndpointInitialization $EI
  123.  
  124. #Run Dashboard
  125. Start-UDDashboard -Dashboard $MyBooksDashboard -Port 7777 -AutoReload -Endpoint @($EndpointMyBooks)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement