Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
Added playlist downloading and improved logger
Browse files Browse the repository at this point in the history
  • Loading branch information
andruzzzhka committed Sep 26, 2018
1 parent 570f1a9 commit 2bc2ae7
Show file tree
Hide file tree
Showing 13 changed files with 478 additions and 234 deletions.
24 changes: 9 additions & 15 deletions BeatSaverDownloader/Misc/Logger.cs
Expand Up @@ -13,35 +13,29 @@ public Logger(string _name)
{
loggerName = _name;
}

public static void StaticLog(string message)
public static void Log(string message)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[BeatSaverDownloader @ " + DateTime.Now.ToString("HH:mm") + "] " + message);
Console.WriteLine("[BeatSaverDownloader @ " + DateTime.Now.ToString("HH:mm")+"] "+message);
}

public void Log(string message)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("["+loggerName+" @ "+DateTime.Now.ToString("HH:mm")+"] "+message);
}

public void Warning(string message)
public static void Warning(string message)
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("[" + loggerName + " @ " + DateTime.Now.ToString("HH:mm") + "] " + message);
Console.WriteLine("[BeatSaverDownloader @ " + DateTime.Now.ToString("HH:mm") + "] " + message);
}

public void Error(string message)
public static void Error(string message)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("[" + loggerName + " @ " + DateTime.Now.ToString("HH:mm") + "] " + message);
Console.WriteLine("[BeatSaverDownloader @ " + DateTime.Now.ToString("HH:mm") + "] " + message);
}

public void Exception(string message)
public static void Exception(string message)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[" + loggerName + " @ " + DateTime.Now.ToString("HH:mm") + "] " + message);
Console.WriteLine("[BeatSaverDownloader @ " + DateTime.Now.ToString("HH:mm") + "] " + message);
}

}
Expand Down
26 changes: 13 additions & 13 deletions BeatSaverDownloader/Misc/PluginConfig.cs
Expand Up @@ -46,7 +46,7 @@ public static void LoadOrCreateConfig()
if (!ModPrefs.HasKey("BeatSaverDownloader", "beatsaverURL"))
{
ModPrefs.SetString("BeatSaverDownloader", "beatsaverURL", "https://beatsaver.com");
Logger.StaticLog("Created config");
Logger.Log("Created config");
}
else
{
Expand All @@ -55,11 +55,11 @@ public static void LoadOrCreateConfig()
{
ModPrefs.SetString("BeatSaverDownloader", "beatsaverURL", "https://beatsaver.com");
beatsaverURL = "https://beatsaver.com";
Logger.StaticLog("Created config");
Logger.Log("Created config");
}
else
{
Logger.StaticLog("Loaded config");
Logger.Log("Loaded config");
}
}

Expand All @@ -80,7 +80,7 @@ public static void LoadOrCreateConfig()
if (!ModPrefs.HasKey("BeatSaverDownloader", "disableDeleteButton"))
{
ModPrefs.SetBool("BeatSaverDownloader", "disableDeleteButton", false);
Logger.StaticLog("Created config");
Logger.Log("Created config");
}
else
{
Expand All @@ -96,7 +96,7 @@ public static void LoadOrCreateConfig()

if(IllusionInjector.PluginManager.Plugins.Count(x => x.Name == "Song Browser") > 0)
{
Logger.StaticLog("Song Browser installed, disabling Song List Tweaks");
Logger.Log("Song Browser installed, disabling Song List Tweaks");
disableSongListTweaks = true;
return;
}
Expand Down Expand Up @@ -124,15 +124,15 @@ public static void LoadOrCreateConfig()
}
catch (Exception e)
{
Logger.StaticLog($"Can't open registry key! Exception: {e}");
Logger.Log($"Can't open registry key! Exception: {e}");
if (Directory.Exists("%LocalAppData%\\Programs\\BeatDrop\\playlists"))
{
beatDropInstalled = true;
beatDropInstallLocation = "%LocalAppData%\\Programs\\BeatDrop\\playlists";
}
else
{
Logger.StaticLog("Can't find the BeatDrop installation folder!");
Logger.Log("Can't find the BeatDrop installation folder!");
}
}

Expand Down Expand Up @@ -169,7 +169,7 @@ public static void LoadSongBrowserConfig()
}
catch (Exception e)
{
Logger.StaticLog($"Can't parse BeatSaberSongBrowser settings file! Exception: {e}");
Logger.Log($"Can't parse BeatSaberSongBrowser settings file! Exception: {e}");
if (fs != null) { fs.Close(); }
}
}
Expand All @@ -183,11 +183,11 @@ public static void LoadPlaylists()
{
string[] beatDropPlaylists = Directory.GetFiles(Path.Combine(beatDropInstallLocation, "playlists"), "*.json");
playlistFiles.AddRange(beatDropPlaylists);
Logger.StaticLog($"Found {beatDropPlaylists.Length} playlists in BeatDrop folder");
Logger.Log($"Found {beatDropPlaylists.Length} playlists in BeatDrop folder");
}
string[] localPlaylists = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory, "Playlists"), "*.json");
playlistFiles.AddRange(localPlaylists);
Logger.StaticLog($"Found {localPlaylists.Length} playlists in Playlists folder");
Logger.Log($"Found {localPlaylists.Length} playlists in Playlists folder");

foreach(string path in playlistFiles)
{
Expand Down Expand Up @@ -215,16 +215,16 @@ public static void LoadPlaylists()
playlist.fileLoc = path;

playlists.Add(playlist);
Logger.StaticLog($"Found \"{playlist.playlistTitle}\" by {playlist.playlistAuthor}");
Logger.Log($"Found \"{playlist.playlistTitle}\" by {playlist.playlistAuthor}");
} catch (Exception e)
{
Logger.StaticLog($"Can't parse playlist at {path}! Exception: {e}");
Logger.Log($"Can't parse playlist at {path}! Exception: {e}");
}
}
}
catch (Exception e)
{
Logger.StaticLog("Can't load playlists! Exception: " + e);
Logger.Log("Can't load playlists! Exception: " + e);
}
}

Expand Down

0 comments on commit 2bc2ae7

Please sign in to comment.