-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
Sources/MarkersExtractor/Export/Profile/CSV/CSVProfile Export.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// | ||
// CSVProfile Export.swift | ||
// MarkersExtractor • https://github.com/TheAcharya/MarkersExtractor | ||
// Licensed under MIT License | ||
// | ||
|
||
import AVFoundation | ||
import CodableCSV | ||
import Foundation | ||
import Logging | ||
import OrderedCollections | ||
import TimecodeKit | ||
|
||
extension CSVProfile { | ||
public func prepareMarkers( | ||
markers: [Marker], | ||
idMode: MarkerIDMode, | ||
tcStringFormat: Timecode.StringFormat, | ||
payload: Payload, | ||
mediaInfo: ExportMarkerMediaInfo? | ||
) -> [PreparedMarker] { | ||
markers.map { | ||
PreparedMarker( | ||
$0, | ||
idMode: idMode, | ||
mediaInfo: mediaInfo, tcStringFormat: tcStringFormat | ||
) | ||
} | ||
} | ||
|
||
public func writeManifests( | ||
_ preparedMarkers: [PreparedMarker], | ||
payload: Payload, | ||
noMedia: Bool | ||
) throws { | ||
try csvWriteManifest( | ||
csvPath: payload.csvPath, | ||
noMedia: noMedia, | ||
preparedMarkers | ||
) | ||
} | ||
|
||
public func resultFileContent(payload: Payload) throws -> ExportResult.ResultDictionary { | ||
[ | ||
.csvManifestPath: .url(payload.csvPath) | ||
] | ||
} | ||
|
||
public func tableManifestFields( | ||
for marker: PreparedMarker, | ||
noMedia: Bool | ||
) -> OrderedDictionary<ExportField, String> { | ||
var dict: OrderedDictionary<ExportField, String> = [:] | ||
|
||
dict[.id] = marker.id | ||
dict[.name] = marker.name | ||
dict[.type] = marker.type | ||
dict[.checked] = marker.checked | ||
dict[.status] = marker.status | ||
dict[.notes] = marker.notes | ||
dict[.position] = marker.position | ||
dict[.clipType] = marker.clipType | ||
dict[.clipName] = marker.clipName | ||
dict[.clipDuration] = marker.clipDuration | ||
dict[.videoRole] = marker.videoRole | ||
dict[.audioRole] = marker.audioRole.flat | ||
dict[.eventName] = marker.eventName | ||
dict[.projectName] = marker.projectName | ||
dict[.libraryName] = marker.libraryName | ||
// no iconImage | ||
|
||
if !noMedia { | ||
dict[.imageFileName] = marker.imageFileName | ||
} | ||
|
||
return dict | ||
} | ||
|
||
public func nestedManifestFields( | ||
for marker: PreparedMarker, | ||
noMedia: Bool | ||
) -> OrderedDictionary<ExportField, ExportFieldValue> { | ||
var dict: OrderedDictionary<ExportField, ExportFieldValue> = [:] | ||
|
||
dict[.id] = .string(marker.id) | ||
dict[.name] = .string(marker.name) | ||
dict[.type] = .string(marker.type) | ||
dict[.checked] = .string(marker.checked) | ||
dict[.status] = .string(marker.status) | ||
dict[.notes] = .string(marker.notes) | ||
dict[.position] = .string(marker.position) | ||
dict[.clipType] = .string(marker.clipType) | ||
dict[.clipName] = .string(marker.clipName) | ||
dict[.clipDuration] = .string(marker.clipDuration) | ||
dict[.videoRole] = .string(marker.videoRole) | ||
dict[.audioRole] = .array(marker.audioRole.array) | ||
dict[.eventName] = .string(marker.eventName) | ||
dict[.projectName] = .string(marker.projectName) | ||
dict[.libraryName] = .string(marker.libraryName) | ||
// no iconImage | ||
|
||
if !noMedia { | ||
dict[.imageFileName] = .string(marker.imageFileName) | ||
} | ||
|
||
return dict | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Sources/MarkersExtractor/Export/Profile/CSV/CSVProfile.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// CSVProfile.swift | ||
// MarkersExtractor • https://github.com/TheAcharya/MarkersExtractor | ||
// Licensed under MIT License | ||
// | ||
|
||
import Foundation | ||
import Logging | ||
|
||
public class CSVProfile: NSObject, ProgressReporting, ExportProfile { | ||
// ExportProfile | ||
public typealias Payload = CSVExportPayload | ||
public typealias Icon = EmptyExportIcon | ||
public typealias PreparedMarker = StandardExportMarker | ||
public static let profile: ExportProfileFormat = .csv | ||
public static let isMediaCapable: Bool = false | ||
public var logger: Logger? | ||
|
||
// ProgressReporting | ||
public let progress: Progress | ||
|
||
public required init(logger: Logger? = nil) { | ||
self.logger = logger | ||
progress = Self.defaultProgress | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters