Skip to content

Commit

Permalink
Feature + Spotify Title Cleanup
Browse files Browse the repository at this point in the history
1. Added hidden $i variable for using in the output format. This will
display the track ID from Spotify. #110
2. Tested many characters for proper title detection, including these
characters: ~, !, @, #, $, %, &, *, (, ), [, ], ;, :, ', ", ., / and
maybe some more. #116
  • Loading branch information
David Rudie committed Sep 18, 2016
1 parent 0be2389 commit 2747e2c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions Snip/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static class Globals
public const string ArtistVariable = "$a";
public const string AlbumVariable = "$l";
public const string NewLineVariable = "$n";
public const string TrackIdVariable = "$i";

#endregion

Expand Down
38 changes: 20 additions & 18 deletions Snip/TextHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public static void UpdateText(string title, string artist, string album, string
output = output.Replace(Globals.TrackVariable, title);
output = output.Replace(Globals.ArtistVariable, artist);
output = output.Replace(Globals.NewLineVariable, "\r\n");
output = output.Replace(Globals.TrackIdVariable, trackId);

if (!string.IsNullOrEmpty(album))
{
Expand All @@ -158,9 +159,9 @@ public static void UpdateText(string title, string artist, string album, string
// Check if we want to save artist and track to separate files.
if (Globals.SaveSeparateFiles)
{
File.WriteAllText(@Application.StartupPath + @"\Snip_Artist.txt", Globals.ArtistFormat.Replace(Globals.ArtistVariable, artist));
File.WriteAllText(@Application.StartupPath + @"\Snip_Track.txt", Globals.TrackFormat.Replace(Globals.TrackVariable, title));
File.WriteAllText(@Application.StartupPath + @"\Snip_Album.txt", Globals.AlbumFormat.Replace(Globals.AlbumVariable, album));
File.WriteAllText(@Application.StartupPath + @"\Snip_Artist.txt", artist);
File.WriteAllText(@Application.StartupPath + @"\Snip_Track.txt", title);
File.WriteAllText(@Application.StartupPath + @"\Snip_Album.txt", album);
File.WriteAllText(@Application.StartupPath + @"\Snip_TrackId.txt", trackId);
}

Expand All @@ -178,21 +179,22 @@ public static string UnifyTitles(string title)
{
title = title.ToUpper(CultureInfo.InvariantCulture);

title = title.Replace(@".", string.Empty);
title = title.Replace(@"/", string.Empty);
title = title.Replace(@"\", string.Empty);
title = title.Replace(@",", string.Empty);
title = title.Replace(@"'", string.Empty);
title = title.Replace(@"(", string.Empty);
title = title.Replace(@")", string.Empty);
title = title.Replace(@"[", string.Empty);
title = title.Replace(@"]", string.Empty);
title = title.Replace(@"!", string.Empty);
title = title.Replace(@"$", string.Empty);
title = title.Replace(@"%", string.Empty);
title = title.Replace(@"&", string.Empty);
title = title.Replace(@"?", string.Empty);
title = title.Replace(@":", string.Empty);
// title = title.Replace(@".", " "); // Causes failed search result from Spotify
title = title.Replace(@"/", " ");
title = title.Replace(@"\", " ");
title = title.Replace(@",", " ");
// title = title.Replace(@"'", " "); // Causes failed search result from Spotify
title = title.Replace(@"(", " ");
title = title.Replace(@")", " ");
title = title.Replace(@"[", " ");
title = title.Replace(@"]", " ");
title = title.Replace(@"!", " ");
title = title.Replace(@"$", " ");
title = title.Replace(@"%", " ");
title = title.Replace(@"&", " ");
title = title.Replace(@"?", " ");
title = title.Replace(@":", " ");
title = title.Replace(@"*", " ");

title = CompactWhitespace(title);

Expand Down

0 comments on commit 2747e2c

Please sign in to comment.