Introducing Packages
Major Overhaul with Breaking Changes split into packaged, default behavior moved into 'base' package each package has a json package description file with criteria for loading Modified Setup-Profile to refer to 'base' package path for auto loading moved Linux aliases and command to 'base.linux' package created 'docker' package to address docker supported systems modified Get-MyScripts, Edit-MyScripts and Reload-MyScripts accordingly. Dropped -System and sys.*, package json conditions will take care of it. Supplied command to create/edit package json files: - New-MyPackage - Add-PackageCondition - Set-MyPackage
This commit is contained in:
parent
80a488484b
commit
42b39f4e25
83 changed files with 505 additions and 130 deletions
31
base.linux/Get-PlexInfo.ps1
Normal file
31
base.linux/Get-PlexInfo.ps1
Normal file
|
@ -0,0 +1,31 @@
|
|||
param([switch]$FetchFromServer,[string]$PlexHost='localhost',[switch]$PassThruOnly)
|
||||
|
||||
$local:content = $(try{(Get-Content /run/plex.stream.counter/sessions -Raw -ErrorAction Stop)}catch{})
|
||||
|
||||
if( $FetchFromServer ) {
|
||||
$local:creds = New-Object System.Management.Automation.PsCredential($env:PLEX_USERNAME,$(ConvertTo-SecureString -AsPlainText $env:PLEX_PASSWORD -Force))
|
||||
$local:webResp = Invoke-WebRequest -Headers @{ "Content-Length" = "0"; "X-Plex-Client-Identifier" = "my-app" } -Credential $creds -Method Post -Uri "https://my.plexapp.com/users/sign_in.xml"
|
||||
$local:plexHeaders = @{ "X-Plex-Token" = ([xml]$webResp.Content).user.authenticationToken }
|
||||
$webResp = Invoke-WebRequest -Headers $plexHeaders "http://${PlexHost}:32400"
|
||||
$local:plexVersion = ([xml]$webResp.Content).MediaContainer.version
|
||||
Write-Host -ForegroundColor Cyan "Plex Version: $plexVersion"
|
||||
$webResp = Invoke-WebRequest -Headers $plexHeaders "http://${PlexHost}:32400/status/sessions"
|
||||
$content = $webResp.Content
|
||||
}
|
||||
|
||||
$local:PlexInfo = $(try{([xml]$content).MediaContainer}catch{})
|
||||
|
||||
$local:result = $PlexInfo.ChildNodes | ForEach-Object { [PSCustomObject]@{
|
||||
Object = $_
|
||||
Type = $_.type
|
||||
Library = $_.librarySectionTitle
|
||||
Title = $(@($_.grandparentTitle,$_.parentIndex,$_.parentTitle,$_.index,$_.title) | Where-Object {$_}) -join ' | '
|
||||
User = $_.User.title
|
||||
Offset = [TimeSpan]::FromMilliseconds($_.viewOffset).ToString() -split '\.' | select-object -first 1
|
||||
Duration = [TimeSpan]::FromMilliseconds($_.duration).ToString() -split '\.' | select-object -first 1
|
||||
Player = "$($_.Player.Platform)|$($_.Player.State)"
|
||||
# UpdateTime = [TimeSpan]::FromMilliseconds($_.).ToString()
|
||||
} }
|
||||
|
||||
if( $PassThruOnly ) { return $result }
|
||||
$result | Format-Table
|
Loading…
Add table
Add a link
Reference in a new issue