-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (48 loc) · 1.62 KB
/
Copy pathProgram.cs
File metadata and controls
58 lines (48 loc) · 1.62 KB
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
58
using CsvHelper;
using CsvHelper.Configuration.Attributes;
using System;
using System.IO;
using System.Text;
namespace pscgen
{
public class Chapter
{
[Name("#")]
public string MarkerId { get; set; }
[Name("Name")]
public string Name { get; set; }
[Name("Start")]
public string Start { get; set; }
[Name("End")]
public string End { get; set; }
[Name("Length")]
public string Length { get; set; }
[Name("Color")]
public string Color { get; set; }
}
class Program
{
static void Main(string[] args)
{
var sourcePath = args[0];
var targetPath = args[1];
using (var reader = new StreamReader(sourcePath))
using (var csv = new CsvReader(reader))
{
var records = csv.GetRecords<Chapter>();
string output = String.Empty;
output += "<? xml version=\"1.0\" encoding=\"utf-8\" ?>";
output += Environment.NewLine;
output += "<psc:chapters version=\"1.2\" xmlns:psc=\"http://podlove.org/simple-chapters\">";
output += Environment.NewLine;
foreach (var chapter in records)
{
output += String.Concat("\t", "<psc:chapter start=\"" + chapter.Start + "\" title=\"" + chapter.Name + "\" />");
output += Environment.NewLine;
}
output += "</psc:chapters>";
File.WriteAllText(targetPath, output, Encoding.UTF8);
}
}
}
}