rango3221 0 Posted July 11, 2017 Posted July 11, 2017 Hello everyone, iam trying to create a script which will allow me to backup the watched statuses of multiple users in my household. I have the following code to get the movies list from my current installation. The issue is when i query the movie list that is returned, i do not see the watched status of the movies. Can anyone please point me in the right direction. Thanks Jay $embyServerUrl = "http://localhost:8096"$embyUsername = "dummy"$embyPassword = "xxxxxx"$embyClientName = "PowerShellScript"$embyDeviceName = "PowerShellScriptEpisodeFiller"$embyDeviceId = "1"$embyApplicationVersion = "1.0.0";$authUrl = "{0}/Users/AuthenticateByName?format=json" -f $embyServerUrlFunction Get-StringHash([string] $String,$HashName = "MD5"){ $StringBuilder = New-Object System.Text.StringBuilder [system.Security.Cryptography.HashAlgorithm]::Create($HashName).ComputeHash([system.Text.Encoding]::UTF8.GetBytes($String))|%{ [Void]$StringBuilder.Append($_.ToString("x2")) } $StringBuilder.ToString()}function Get-EmbyAccessToken { [CmdletBinding()] param ($username, $password) $authUrl = "{0}/Users/AuthenticateByName?format=json" -f $embyServerUrl $sha1Pass = Get-StringHash -String $password -HashName "SHA1" $md5Pass = Get-StringHash -String $password $postParams = (@{Username="$username";password="$sha1Pass";passwordMd5="$md5Pass"} | ConvertTo-Json) $headers = @{"Authorization"="MediaBrowser Client=`"$embyClientName`", Device=`"$embyDeviceName`", DeviceId=`"$embyDeviceId`", Version=`"$embyApplicationVersion`""} Write-Verbose ("authUrl={0},Username={1},sha1Pass={2},md5Pass={3},params={4}" -f $authUrl, $Username,$sha1Pass,$md5Pass,$postParams) return (Invoke-WebRequest -Uri $authUrl -Method POST -Body $postParams -ContentType "application/json" -Headers $headers)}function Get-EmbyMovieList { [CmdletBinding()] param ($AccessToken) $url = "{0}/Items/UserData?format=json&recursive=true&IncludeItemTypes=Movie" -f $embyServerUrl $embyHeaderWithAccessToken = @{"X-MediaBrowser-Token"=$user.AccessToken} Write-Verbose ("authUrl={0},Header={1}" -f $url, $embyHeaderWithAccessToken) return (Invoke-WebRequest -Uri $url -Method GET -ContentType "application/json" -Headers $embyHeaderWithAccessToken)}function Write-Feedback(){ param ( [Parameter(Position=0,ValueFromPipeline=$true)] [string]$msg, [string]$BackgroundColor = "Yellow", [string]$ForegroundColor = "Black" ) Write-Host -BackgroundColor $BackgroundColor -ForegroundColor $ForegroundColor $msg; $msg | Out-File "c:\Users\kodi-client\Desktop\movielist.json"; # <<< or add a param to location}$authResult = Get-EmbyAccessToken -Username $embyUsername -Password $embyPassword$user = $authResult.Content | ConvertFrom-Json$userAccessToken = $user.AccessToken$movieList = Get-EmbyMovieList -AccessToken $userAccessTokenWrite-Feedback $movieList#Write-Host ($movieList)
Luke 40074 Posted July 11, 2017 Posted July 11, 2017 Have you checked out our wiki on the api? https://github.com/MediaBrowser/Emby/wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now