~ubuntu-branches/ubuntu/lucid/gnome-subtitles/lucid

« back to all changes in this revision

Viewing changes to sublib-0.8/src/SubLib/Persistency/SubtitleFormatKaraokeLyricsLRC.cs

  • Committer: Bazaar Package Importer
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2007-12-03 20:52:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071203205252-2y6uuv4gcw9mi9n5
Tags: 0.7-1
* New upstream release;
* Add libxml-parser-perl to Build-Depends-Indep. Thanks to Lucas Nussbaum.
  (Closes: #445799);
* Fixes manpage issue with dpatch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of SubLib.
 
3
 * Copyright (C) 2007 Pedro Castro
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 */
 
19
 
 
20
using System;
 
21
using System.Text.RegularExpressions;
 
22
 
 
23
namespace SubLib {
 
24
        
 
25
internal class SubtitleFormatKaraokeLyricsLRC : SubtitleFormat {
 
26
                
 
27
        public SubtitleFormatKaraokeLyricsLRC() {
 
28
                name = "Karaoke Lyrics LRC";
 
29
                type = SubtitleType.KaraokeLyricsLRC;
 
30
                mode = SubtitleMode.Times;
 
31
                extensions = new string[] { "lrc" };
 
32
                
 
33
                lineBreak = "|"; // It does not manage line breaks, but still using this char as a separator
 
34
                
 
35
                format = @"\[\s*\d+:\d+.\d+\s*\].+\n+\[\s*\d+:\d+.\d+\s*\]";
 
36
                
 
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*\]";
 
38
                
 
39
                subtitleOut = "[<<StartMinutes>>:<<StartSeconds>>.<<StartCentiseconds>>]<<Text>>\n" +
 
40
                        "[<<EndMinutes>>:<<EndSeconds>>.<<EndCentiseconds>>]";
 
41
                        
 
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*]"
 
50
                };
 
51
                
 
52
        }
 
53
        
 
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";
 
63
        }
 
64
}
 
65
 
 
66
}
 
67