-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build-SegmentMetaFile.ps1
57 lines (44 loc) · 1.25 KB
/
Build-SegmentMetaFile.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# This script is for creating segment files for mpv-segment-linking
# Available at: https://github.com/CogentRedTester/mpv-segment-linking
# Segment File version: v0.1
$output_file = ".segment-linking"
$files = @()
$flag = $false
foreach ($arg in $args) {
if ($arg -eq "-o") {
$flag = $true
continue
}
if ($flag) {
$output_file = $arg
continue
}
foreach ($item in $args) {
if ($item.Name) {
$files += $item.Name
}
else {
$files += $item
}
}
}
"# mpv-segment-linking v0.1" > $output_file
"" >> $output_file
foreach ($file in $files) {
$out = mkvinfo "$file"
# echo $out
if ( $LASTEXITCODE -ne 0 ) {
continue;
}
$file >> $output_file
if ( $UID = ($out | Select-String -Pattern 'Segment UID: ([^\n\r]+)' -CaseSensitive)) {
"UID="+$UID.Matches.Groups[1] >> $output_file
}
if ( $prev = ($out | Select-String -Pattern 'Previous segment UID: ([^\n\r]+)' -CaseSensitive)) {
"PREV="+$prev.Matches.Groups[1] >> $output_file
}
if ( $next = ($out | Select-String -Pattern 'Next segment UID: ([^\n\r]+)' -CaseSensitive)) {
"NEXT="+$next.Matches.Groups[1] >> $output_file
}
"" >> $output_file
}