-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlex-Parse.ps1
38 lines (35 loc) · 3.9 KB
/
Plex-Parse.ps1
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
<#
Chris' Plex Library Parsing Script
-----------------------------------
v0.1 - Chris Hall - Apr 14
v0.2 - John Stallan - Aug 14
See https://www.github.com/chall32/plex-parse
for details and usage guidelines
#>
$PSScriptRoot = $MyInvocation.MyCommand.Path | Split-Path
Function get-epochdate ($epochdate) {
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($epochdate))
}
$results = @()
[xml]$xmldata=(Get-Content -Path ($PSScriptRoot +"\Library.xml"))
$media = $xmldata.MediaContainer.Video
foreach ($i in $media) {
$out = new-object psobject
$out | add-member noteproperty Title $i.title
$out | add-member noteproperty "Year Released" $i.year
$out | add-member noteproperty "Added to Plex" (get-epochdate ($i.addedAt))
$out | add-member noteproperty "Updated by Plex" (get-epochdate ($i.updatedAt))
$out | add-member noteproperty "Last Viewed At" ((get-epochdate ($i.lastViewedAt)) -replace "01/01/1970 00:00:00","Unwatched")
$out | add-member noteproperty Duration (new-timespan -seconds ($i.Media.duration/1000))
$out | add-member noteproperty Rating $i.contentRating
$out | add-member noteproperty Resolution $i.Media.videoResolution
$out | add-member noteproperty Container $i.Media.container
$out | add-member noteproperty "Video Codec" $i.Media.videoCodec
$out | add-member noteproperty "Audio Codec" $i.Media.audioCodec
$out | add-member noteproperty Width $i.Media.width
$out | add-member noteproperty Height $i.Media.height
$out | add-member noteproperty "File Size (GB)" ([System.Math]::Round($i.Media.Part.size/1GB,3))
$out | add-member noteproperty "Summary" $i.summary
$results += $out
}
$results | export-csv -path ($PSScriptRoot + "\Library.csv") -notype