Skip to content

Commit 8efc756

Browse files
committed
Touch up Debug program
1 parent f883d23 commit 8efc756

File tree

1 file changed

+159
-161
lines changed

1 file changed

+159
-161
lines changed

src/Debug/Program.cs

Lines changed: 159 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -4,174 +4,172 @@
44
using TagLib;
55
using File = System.IO.File;
66

7-
namespace Debug
7+
namespace Debug;
8+
9+
/// <summary>
10+
/// Stub program to debug some scenarios. Modify it as you need, this is not meant to be reuseable program.
11+
/// </summary>
12+
class Program
813
{
14+
static readonly string AssemblyLocation = Path.GetDirectoryName (Assembly.GetAssembly (typeof (Program)).Location);
15+
public static readonly string Samples = Path.Combine (AssemblyLocation, "..", "..", "..", "..", "TaglibSharp.Tests", "samples");
16+
917
/// <summary>
10-
/// Stub program to debug some scenarios. Modify it as you need, this is not meant to be reuseable program.
18+
/// Output message on the console and on the Visual Studio Output
1119
/// </summary>
12-
class Program
20+
/// <param name="str"></param>
21+
static void Log (string str)
1322
{
14-
static readonly string AssemblyLocation = Path.GetDirectoryName (Assembly.GetAssembly (typeof (Program)).Location);
15-
public static readonly string Samples = Path.Combine (AssemblyLocation, "..", "..", "..", "..", "TaglibSharp.Tests", "samples");
16-
17-
/// <summary>
18-
/// Ouput message on the console and on the Visual Studio Output
19-
/// </summary>
20-
/// <param name="str"></param>
21-
static void Log (string str)
22-
{
23-
Console.WriteLine (str);
24-
System.Diagnostics.Debug.WriteLine (str);
25-
}
23+
Console.WriteLine (str);
24+
System.Diagnostics.Debug.WriteLine (str);
25+
}
26+
27+
static void Main (string[] args)
28+
{
29+
Log ("--------------------");
30+
Log ($"* Start : Samples directory: {Samples}");
31+
Log ("");
2632

27-
static void Main (string[] args)
28-
{
29-
Log ("--------------------");
30-
Log ("* Start : Samples directory: " + Samples);
31-
Log ("");
32-
33-
// Override command arguments
34-
args = new[] { "sample.wav" };
35-
36-
foreach (var fname in args) {
37-
var fpath = Samples + fname;
38-
var tpath = Samples + "tmpwrite" + Path.GetExtension (fname);
39-
40-
Log ("+ File : " + fpath);
41-
if (!File.Exists (fpath)) {
42-
Log (" # File not found: " + fpath);
43-
continue;
44-
}
45-
46-
Log (" read : " + fpath);
47-
var rfile = TagLib.File.Create (fpath);
48-
Log (" Type : " + rfile.MimeType);
49-
50-
File.Copy (fpath, tpath, true);
51-
52-
var file = TagLib.File.Create (tpath);
53-
Log (" Type : " + file.MimeType);
54-
55-
Log (" rboy1 test start : " + file.MimeType);
56-
57-
var MKVTag = (TagLib.Matroska.Tag)file.GetTag (TagTypes.Matroska);
58-
MKVTag.Title = "my Title";
59-
MKVTag.Set ("SUBTITLE", null, "my SubTitle");
60-
MKVTag.Set ("DESCRIPTION", null, "my Description");
61-
MKVTag.Set ("TVCHANNEL", null, "my Network");
62-
MKVTag.Set ("LAW_RATING", null, "my Rating");
63-
MKVTag.Set ("ACTOR", null, "my MediaCredits");
64-
MKVTag.Set ("GENRE", null, "my Genres");
65-
MKVTag.Set ("SEASON", null, "my Season");
66-
MKVTag.Set ("EPISODE", null, "my Episode");
67-
68-
var bannerFile = Samples + "sample_invalidifdoffset.jpg";
69-
var videoPicture = new Picture (bannerFile);
70-
MKVTag.Pictures = new IPicture[] { videoPicture };
71-
72-
Log (" rboy1 test save : " + file.MimeType);
73-
file.Save ();
74-
75-
Log (" rboy1 test read : " + file.MimeType);
76-
var tagFile = TagLib.File.Create (tpath);
77-
78-
Log (" rboy1 test end : " + file.MimeType);
79-
80-
var tag = file.Tag;
81-
var pics = file.Tag.Pictures;
82-
83-
var mtag = (TagLib.Matroska.Tag)file.GetTag (TagTypes.Matroska);
84-
mtag.PerformersRole = new[] { "TEST role 1", "TEST role 2" };
85-
86-
Log (" Picture : " + pics[0].Description);
87-
88-
var tracks = mtag.Tags.Tracks;
89-
var audiotag = mtag.Tags.Get (tracks[1]);
90-
if (audiotag != null) {
91-
audiotag.Clear ();
92-
audiotag.Title = "The Noise";
93-
audiotag.Set ("DESCRIPTION", null, "Useless background noise");
94-
}
95-
96-
Log (" Erase : " + tag.Title);
97-
file.RemoveTags (TagTypes.Matroska);
98-
file.Save ();
99-
100-
Log (" Write : " + tag.Title);
101-
102-
tag.TitleSort = "title, TEST";
103-
tag.AlbumSort = "album, TEST";
104-
tag.PerformersSort = new[] { "performer 1, TEST", "performer 2, TEST" };
105-
tag.ComposersSort = new[] { "composer 1, TEST", "composer 2, TEST" };
106-
tag.AlbumArtistsSort = new[] { "album artist 1, TEST", "album artist 2, TEST" };
107-
108-
109-
tag.Album = "TEST album";
110-
tag.AlbumArtists = new[] { "TEST album artist 1", "TEST album artist 2" };
111-
tag.BeatsPerMinute = 120;
112-
tag.Comment = "TEST comment";
113-
tag.Composers = new[] { "TEST composer 1", "TEST composer 2" };
114-
tag.Conductor = "TEST conductor";
115-
tag.Copyright = "TEST copyright";
116-
tag.Disc = 1;
117-
tag.DiscCount = 2;
118-
tag.Genres = new[] { "TEST genre 1", "TEST genre 2" };
119-
tag.Grouping = "TEST grouping";
120-
tag.Lyrics = "TEST lyrics 1\r\nTEST lyrics 2";
121-
tag.Performers = new[] { "TEST performer 1", "TEST performer 2" };
122-
tag.Title = "TEST title";
123-
tag.Track = 5;
124-
tag.TrackCount = 10;
125-
tag.Year = 1999;
126-
127-
// Insert new picture
128-
Array.Resize (ref pics, 2);
129-
pics[1] = new Picture (Samples + "sample_sony2.jpg");
130-
file.Tag.Pictures = pics;
131-
132-
file.Save ();
133-
134-
135-
Log (" Done : " + tag.Title);
136-
137-
// Now read it again
138-
file = TagLib.File.Create (tpath);
139-
tag = file.Tag;
140-
mtag = (TagLib.Matroska.Tag)file.GetTag (TagTypes.Matroska);
141-
142-
Log (" Read : " + tag.Title);
143-
144-
Log (" Album : " + tag.Album);
145-
Log (" JoinedAlbumArtists : " + tag.JoinedAlbumArtists);
146-
Log (" BeatsPerMinute : " + tag.BeatsPerMinute);
147-
Log (" Comment : " + tag.Comment);
148-
Log (" JoinedComposers : " + tag.JoinedComposers);
149-
Log (" Conductor : " + tag.Conductor);
150-
Log (" Copyright : " + tag.Copyright);
151-
Log (" Disc : " + tag.Disc);
152-
Log (" DiscCount : " + tag.DiscCount);
153-
Log (" JoinedGenres : " + tag.JoinedGenres);
154-
Log (" Grouping : " + tag.Grouping);
155-
Log (" Lyrics : " + tag.Lyrics);
156-
Log (" JoinedPerformers : " + tag.JoinedPerformers);
157-
Log (" Title : " + tag.Title);
158-
Log (" Track : " + tag.Track);
159-
Log (" TrackCount : " + tag.TrackCount);
160-
Log (" Year : " + tag.Year);
161-
162-
Log (" TitleSort : " + tag.TitleSort);
163-
Log (" AlbumSort : " + tag.AlbumSort);
164-
Log (" PerformersSort : " + tag.JoinedPerformersSort);
165-
Log (" ComposersSort : " + string.Join ("; ", tag.ComposersSort));
166-
Log (" AlbumArtistsSort : " + string.Join ("; ", tag.AlbumArtistsSort));
167-
168-
169-
Log (" PerformersRole : " + string.Join ("; ", mtag.PerformersRole));
170-
171-
Log (" Done : " + tag.Title);
33+
// Override command arguments
34+
args = ["sample.wav"];
35+
36+
foreach (var fname in args) {
37+
var fpath = Samples + fname;
38+
var tpath = $"{Samples}tmpwrite{Path.GetExtension (fname)}";
39+
40+
Log ($"+ File : {fpath}");
41+
if (!File.Exists (fpath)) {
42+
Log ($" # File not found: {fpath}");
43+
continue;
17244
}
17345

174-
Log ("* End");
46+
Log ($" read : {fpath}");
47+
var rfile = TagLib.File.Create (fpath);
48+
Log ($" Type : {rfile.MimeType}");
49+
50+
File.Copy (fpath, tpath, true);
51+
52+
var file = TagLib.File.Create (tpath);
53+
Log ($" Type : {file.MimeType}");
54+
55+
Log ($" rboy1 test start : {file.MimeType}");
56+
57+
var MKVTag = (TagLib.Matroska.Tag)file.GetTag (TagTypes.Matroska);
58+
MKVTag.Title = "my Title";
59+
MKVTag.Set ("SUBTITLE", null, "my SubTitle");
60+
MKVTag.Set ("DESCRIPTION", null, "my Description");
61+
MKVTag.Set ("TVCHANNEL", null, "my Network");
62+
MKVTag.Set ("LAW_RATING", null, "my Rating");
63+
MKVTag.Set ("ACTOR", null, "my MediaCredits");
64+
MKVTag.Set ("GENRE", null, "my Genres");
65+
MKVTag.Set ("SEASON", null, "my Season");
66+
MKVTag.Set ("EPISODE", null, "my Episode");
67+
68+
var bannerFile = $"{Samples}sample_invalidifdoffset.jpg";
69+
var videoPicture = new Picture (bannerFile);
70+
MKVTag.Pictures = [videoPicture];
71+
72+
Log ($" rboy1 test save : {file.MimeType}");
73+
file.Save ();
74+
75+
Log ($" rboy1 test read : {file.MimeType}");
76+
var tagFile = TagLib.File.Create (tpath);
77+
78+
Log ($" rboy1 test end : {file.MimeType}");
79+
80+
var tag = file.Tag;
81+
var pics = file.Tag.Pictures;
82+
83+
var mtag = (TagLib.Matroska.Tag)file.GetTag (TagTypes.Matroska);
84+
mtag.PerformersRole = ["TEST role 1", "TEST role 2"];
85+
86+
Log ($" Picture : {pics[0].Description}");
87+
88+
var tracks = mtag.Tags.Tracks;
89+
var audiotag = mtag.Tags.Get (tracks[1]);
90+
if (audiotag != null) {
91+
audiotag.Clear ();
92+
audiotag.Title = "The Noise";
93+
audiotag.Set ("DESCRIPTION", null, "Useless background noise");
94+
}
95+
96+
Log ($" Erase : {tag.Title}");
97+
file.RemoveTags (TagTypes.Matroska);
98+
file.Save ();
99+
100+
Log ($" Write : {tag.Title}");
101+
102+
tag.TitleSort = "title, TEST";
103+
tag.AlbumSort = "album, TEST";
104+
tag.PerformersSort = ["performer 1, TEST", "performer 2, TEST"];
105+
tag.ComposersSort = ["composer 1, TEST", "composer 2, TEST"];
106+
tag.AlbumArtistsSort = ["album artist 1, TEST", "album artist 2, TEST"];
107+
108+
109+
tag.Album = "TEST album";
110+
tag.AlbumArtists = ["TEST album artist 1", "TEST album artist 2"];
111+
tag.BeatsPerMinute = 120;
112+
tag.Comment = "TEST comment";
113+
tag.Composers = ["TEST composer 1", "TEST composer 2"];
114+
tag.Conductor = "TEST conductor";
115+
tag.Copyright = "TEST copyright";
116+
tag.Disc = 1;
117+
tag.DiscCount = 2;
118+
tag.Genres = ["TEST genre 1", "TEST genre 2"];
119+
tag.Grouping = "TEST grouping";
120+
tag.Lyrics = "TEST lyrics 1\r\nTEST lyrics 2";
121+
tag.Performers = ["TEST performer 1", "TEST performer 2"];
122+
tag.Title = "TEST title";
123+
tag.Track = 5;
124+
tag.TrackCount = 10;
125+
tag.Year = 1999;
126+
127+
// Insert new picture
128+
Array.Resize (ref pics, 2);
129+
pics[1] = new Picture ($"{Samples}sample_sony2.jpg");
130+
file.Tag.Pictures = pics;
131+
132+
file.Save ();
133+
134+
135+
Log ($" Done : {tag.Title}");
136+
137+
// Now read it again
138+
file = TagLib.File.Create (tpath);
139+
tag = file.Tag;
140+
mtag = (TagLib.Matroska.Tag)file.GetTag (TagTypes.Matroska);
141+
142+
Log ($" Read : {tag.Title}");
143+
144+
Log ($" Album : {tag.Album}");
145+
Log ($" JoinedAlbumArtists : {tag.JoinedAlbumArtists}");
146+
Log ($" BeatsPerMinute : {tag.BeatsPerMinute}");
147+
Log ($" Comment : {tag.Comment}");
148+
Log ($" JoinedComposers : {tag.JoinedComposers}");
149+
Log ($" Conductor : {tag.Conductor}");
150+
Log ($" Copyright : {tag.Copyright}");
151+
Log ($" Disc : {tag.Disc}");
152+
Log ($" DiscCount : {tag.DiscCount}");
153+
Log ($" JoinedGenres : {tag.JoinedGenres}");
154+
Log ($" Grouping : {tag.Grouping}");
155+
Log ($" Lyrics : {tag.Lyrics}");
156+
Log ($" JoinedPerformers : {tag.JoinedPerformers}");
157+
Log ($" Title : {tag.Title}");
158+
Log ($" Track : {tag.Track}");
159+
Log ($" TrackCount : {tag.TrackCount}");
160+
Log ($" Year : {tag.Year}");
161+
162+
Log ($" TitleSort : {tag.TitleSort}");
163+
Log ($" AlbumSort : {tag.AlbumSort}");
164+
Log ($" PerformersSort : {tag.JoinedPerformersSort}");
165+
Log ($" ComposersSort : {string.Join ("; ", tag.ComposersSort)}");
166+
Log ($" AlbumArtistsSort : {string.Join ("; ", tag.AlbumArtistsSort)}");
167+
168+
Log ($" PerformersRole : {string.Join ("; ", mtag.PerformersRole)}");
169+
170+
Log ($" Done : {tag.Title}");
175171
}
172+
173+
Log ("* End");
176174
}
177175
}

0 commit comments

Comments
 (0)