-
Notifications
You must be signed in to change notification settings - Fork 4
/
GenerateXspf.cs
39 lines (34 loc) · 1.27 KB
/
GenerateXspf.cs
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
using System;
namespace PlayListGenerator
{
/// <summary>
/// Generate a xspf playlist file
/// </summary>
internal class GenerateXspf : GeneratePlaylistBase
{
public override string FileExtension
{
get
{
return "xspf";
}
}
protected override string GetHeader()
{
return @"<?xml version=""1.0"" encoding=""UTF-8""?><playlist version=""1"" xmlns=""http://xspf.org/ns/0/""><title></title><trackList>"+Environment.NewLine;
}
protected override string GetFooter()
{
return @"</track></trackList></playlist>";
}
protected override string GetForOneFile(string aFileName)
{
return "<track><location>" + EncodeStringToXML(aFileName) + "</location></track>"+Environment.NewLine;
}
private static string EncodeStringToXML(string aStringToEncore)
{
// From http://weblogs.sqlteam.com/mladenp/archive/2008/10/21/Different-ways-how-to-escape-an-XML-string-in-C.aspx
return aStringToEncore.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
}
}
}