Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get-UDDashboard | Stop-UDDashboard
- # Palette (Darkest to lightest)
- #383c4a
- #404552
- #4b5162
- #7c818c
- #5294e2 (Blue Accent Color)
- $Theme = New-UDTheme -Name "Basic" -Definition @{
- UDDashboard = @{
- BackgroundColor = "#292d3e"
- FontColor = "#b2b4c1"
- }
- UDFooter = @{
- BackgroundColor = "#292d3e"
- FontColor = "#292d3e"
- }
- UDNavBar = @{
- BackgroundColor = "#383c4a"
- FontColor = "#b2b4c1"
- }
- UDCard = @{
- BackgroundColor = "#383c4a"
- FontColor = "#b2b4c1"
- }
- UDChart = @{
- BackgroundColor = "#292d3e"
- FontColor = "#b2b4c1"
- }
- UDCounter = @{
- BackgroundColor = "#292d3e"
- FontColor = "#b2b4c1"
- }
- UDMonitor = @{
- BackgroundColor = "#292d3e"
- FontColor = "#b2b4c1"
- }
- UDGrid = @{
- BackgroundColor = "#292d3e"
- FontColor = "#b2b4c1"
- }
- UDTable = @{
- BackgroundColor = "#292d3e"
- FontColor = "#b2b4c1"
- }
- UDInput = @{
- BackgroundColor = "#292d3e"
- FontColor = "#b2b4c1"
- }
- }
- $Cache:MyGoodReadsID = ""
- $Cache:API_key = ""
- $Cache:Api_secret = ""
- $Schedule30 = New-UDEndpointSchedule -Every 30 -Minute
- function Get-Books {
- $r = Invoke-WebRequest -Uri "https://www.goodreads.com/review/list/$Cache:MyGoodReadsID.xml?key=$($Cache:API_key)&v=2&per_page=200&shelf=Read"
- $ResponseContentXML = [XML]$r.Content
- $AllBooksInfo = $ResponseContentXML.GoodreadsResponse.reviews.review.book
- $MyBooks = foreach ($Book in $AllBooksInfo) {
- $URL = "https://www.goodreads.com/work/$($Book.work.id)/series?format=xml&key=$($Cache:API_key)"
- $Response = Invoke-WebRequest -Uri $URL -Method Get -UseBasicParsing
- [XML]$series_overview_XML = $Response.Content
- [INT]$series_overview_work_id = $series_overview_XML.GoodreadsResponse.series_works.series_work.series.id | Select -First 1
- [INT]$series_overview_primary_work_count = $series_overview_XML.GoodreadsResponse.series_works.series_work.series.primary_work_count | Select -First 1
- if ($series_overview_XML.GoodreadsResponse.series_works.series_work.series.title."#cdata-section") {
- [STRING]$series_overview_title = ($series_overview_XML.GoodreadsResponse.series_works.series_work.series.title."#cdata-section").trim()
- }
- else { [STRING]$series_overview_title = 'No Series Found' }
- [pscustomobject]@{
- id = $Book.id.'#text'
- title_without_series = $Book.id.title_without_series
- title = $Book.title
- small_image_url = $Book.small_image_url
- large_image_url = $Book.large_image_url
- link = $Book.link
- description = $Book.description
- work_id = $Book.work.id
- author_image_url = $Book.authors.author.image_url
- author_small_image_url = $Book.authors.author.small_image_url
- author_id = $Book.authors.author.id
- series_overview_XML = $series_overview_XML
- series_overview_title = $series_overview_title
- series_overview_primary_work_count = $series_overview_primary_work_count
- series_overview_work_id = $series_overview_work_id
- owned_books_in_series = "0"
- }
- Start-Sleep -Seconds 1
- }
- Write-Output $MyBooks
- }
- $EI = New-UDEndpointInitialization -Function @("Get-Books")
- $EndpointMyBooks = New-UDEndpoint -Schedule $Schedule30 -Endpoint {
- $Cache:MyBooks = Get-Books
- }
- $SeriesCollection = @()
- foreach ($Series in ($MyBooks.series_overview_title | Sort-Object -Unique)) {
- $NewPage = New-UDPage -Name "$Series" -Icon "home" -Content {
- New-UDCard }
- New-Variable -Name $Series.Replace(" ", "_") -Value $NewPage -Force
- $SeriesCollection += $Series.Replace(" ", "_")
- }
- $a = @()
- foreach ($Series in $SeriesCollection) {
- $a += ("$" + "$Series")
- }
- #$allVaribles = $a -join ","
- # Create Dashboard and Add Pages.
- $MyBooksDashboard = New-UDDashboard -Theme $Theme -Title "GRDB" -Pages @($a) -EndpointInitialization $EI
- #Run Dashboard
- Start-UDDashboard -Dashboard $MyBooksDashboard -Port 7777 -AutoReload -Endpoint @($EndpointMyBooks)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement