2
* This file is part of SubLib.
3
* Copyright (C) 2007 Pedro Castro
5
* SubLib is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* SubLib is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
using System.Text.RegularExpressions;
25
internal class SubtitleFormatKaraokeLyricsLRC : SubtitleFormat {
27
public SubtitleFormatKaraokeLyricsLRC() {
28
name = "Karaoke Lyrics LRC";
29
type = SubtitleType.KaraokeLyricsLRC;
30
mode = SubtitleMode.Times;
31
extensions = new string[] { "lrc" };
33
lineBreak = "|"; // It does not manage line breaks, but still using this char as a separator
35
format = @"\[\s*\d+:\d+.\d+\s*\].+\n+\[\s*\d+:\d+.\d+\s*\]";
37
subtitleIn = @"\[\s*(?<StartMinutes>\d+)\s*:\s*(?<StartSeconds>\d+)\s*.\s*(?<StartCentiseconds>\d+)\s*\]\s*(?<Text>.*)\n+\[\s*(?<EndMinutes>\d+)\s*:\s*(?<EndSeconds>\d+)\s*.\s*(?<EndCentiseconds>\d+)\s*\]";
39
subtitleOut = "[<<StartMinutes>>:<<StartSeconds>>.<<StartCentiseconds>>]<<Text>>\n" +
40
"[<<EndMinutes>>:<<EndSeconds>>.<<EndCentiseconds>>]";
42
headers = new string[] {
43
@"\[\s*ti:(?<Title>.*)\s*]" ,
44
@"\[\s*au:(?<Author>.*)\s*]" ,
45
@"\[\s*ar:(?<Artist>.*)\s*]" ,
46
@"\[\s*al:(?<Album>.*)\s*]" ,
47
@"\[\s*by:(?<Maker>.*)\s*]" ,
48
@"\[\s*ve:(?<Version>.*)\s*]" ,
49
@"\[\s*re:(?<Program>.*)\s*]"
54
internal override string HeadersToString (SubtitleProperties subtitleProperties, FileProperties fileProperties) {
55
Headers headers = subtitleProperties.Headers;
56
return "[ti: " + headers.Title + "]\n" +
57
"[au:" + headers.MovieAuthor + "]\n" +
58
"[ar:" + headers.Artist + "]\n" +
59
"[al:" + headers.Album + "]\n" +
60
"[by:" + headers.Author + "]\n" +
61
"[ve:" + headers.Version + "]\n" +
62
"[re:" + headers.Program + "]\n";