updated
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
5c948438a1
commit
b7369213f2
@ -19,10 +19,12 @@ namespace SongCrawler
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if(args.Last() == "-sl")
|
||||
//FindDuplicates(args);
|
||||
if (args.Last() == "-sl")
|
||||
{
|
||||
UploadSongList(args);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
CrawlSongs(args);
|
||||
}
|
||||
@ -91,9 +93,9 @@ namespace SongCrawler
|
||||
songs = new List<Song>();
|
||||
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(FindFiles("mp4", songpath));
|
||||
files.AddRange(FindFiles("mp3", songpath));
|
||||
files.AddRange(FindFiles("zip", songpath));
|
||||
files.AddRange(FindFiles("mp4", songpath));
|
||||
|
||||
Song song = null;
|
||||
int i = 0;
|
||||
@ -115,6 +117,152 @@ namespace SongCrawler
|
||||
|
||||
}
|
||||
|
||||
private static void CrawlNoDupeSongs(string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
Console.WriteLine("usage: songcrawler partyid songspath");
|
||||
return;
|
||||
}
|
||||
string controller = args[0];
|
||||
string songpath = args[1];
|
||||
IFirebaseConfig config = new FirebaseConfig
|
||||
{
|
||||
AuthSecret = ConfigurationManager.AppSettings["Firebase.Secret"],
|
||||
BasePath = ConfigurationManager.AppSettings["Firebase.Path"]
|
||||
};
|
||||
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
|
||||
string firepath = string.Format("controllers/{0}/songs", controller);
|
||||
Console.WriteLine("Loading current library");
|
||||
List<Song> songs = new List<Song>();
|
||||
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(FindFiles("mp4", songpath));
|
||||
files.AddRange(FindFiles("mp3", songpath));
|
||||
files.AddRange(FindFiles("zip", songpath));
|
||||
|
||||
Song song = null;
|
||||
int i = 0;
|
||||
foreach (string filepath in files)
|
||||
{
|
||||
i++;
|
||||
try
|
||||
{
|
||||
song = MakeSong(filepath);
|
||||
Console.WriteLine(string.Format("{0:000000}/{1} - {2}", i, files.Count(), song.Title));
|
||||
if (!songs.Any(s => s.Title.ToLower() == song.Title.ToLower() && s.Artist.ToLower() == song.Artist.ToLower())) songs.Add(song);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
Console.WriteLine(string.Format("{0:000000}/{1} unique songs", songs.Count(), files.Count()));
|
||||
client.Set(firepath, songs);
|
||||
}
|
||||
|
||||
private static void FindDuplicates(string[] args)
|
||||
{
|
||||
string songpath = @"D:\KaraokeData\Karaoke"; // args[0];
|
||||
List<Song> songs = songs = new List<Song>();
|
||||
|
||||
List<string> files = new List<string>();
|
||||
files.AddRange(FindFiles("mp3", songpath));
|
||||
files.AddRange(FindFiles("zip", songpath));
|
||||
files.AddRange(FindFiles("mp4", songpath));
|
||||
|
||||
Song song = null;
|
||||
int i = 0;
|
||||
foreach (string filepath in files)
|
||||
{
|
||||
i++;
|
||||
try
|
||||
{
|
||||
song = MakeSong(filepath);
|
||||
Console.WriteLine(string.Format("{0:000000}/{1} - {2}", i, files.Count, song.Title));
|
||||
songs.Add(song);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
Dictionary<string, List<Song>> dupes = new Dictionary<string, List<Song>>();
|
||||
foreach (var localsong in songs)
|
||||
{
|
||||
i++;
|
||||
Console.WriteLine(string.Format("Checking for {0:000000}/{1}) {2} - {3}", i, files.Count, localsong.Artist, localsong.Title));
|
||||
if (!string.IsNullOrEmpty(localsong.Artist) && !string.IsNullOrEmpty(localsong.Title))
|
||||
{
|
||||
string key = localsong.Artist + " - " + localsong.Title;
|
||||
if (dupes.ContainsKey(key) == false)
|
||||
{
|
||||
var dsongs = songs.Where(s => s.Title.ToLower() == localsong.Title.ToLower() && s.Artist.ToLower() == localsong.Artist.ToLower());
|
||||
if (dsongs.Count() > 1)
|
||||
{
|
||||
List<Song> d = new List<Song>();
|
||||
d.AddRange(dsongs.ToList());
|
||||
dupes.Add(key, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File.WriteAllText(@"D:\dupliates.json", JsonConvert.SerializeObject(dupes.OrderBy(o => o.Key)));
|
||||
}
|
||||
private static void DisableDuplicates(string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
Console.WriteLine("usage: songcrawler partyid songspath");
|
||||
return;
|
||||
}
|
||||
string controller = args[0];
|
||||
IFirebaseConfig config = new FirebaseConfig
|
||||
{
|
||||
AuthSecret = ConfigurationManager.AppSettings["Firebase.Secret"],
|
||||
BasePath = ConfigurationManager.AppSettings["Firebase.Path"]
|
||||
};
|
||||
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
|
||||
string firepath = string.Format("controllers/{0}/songs", controller);
|
||||
Console.WriteLine("Loading current library");
|
||||
List<Song> songs = client.Get(firepath).ResultAs<List<Song>>();
|
||||
|
||||
Dictionary<string, List<Song>> dupes = new Dictionary<string, List<Song>>();
|
||||
|
||||
int i = 0;
|
||||
foreach (var localsong in songs)
|
||||
{
|
||||
i++;
|
||||
Console.WriteLine(string.Format("Checking for {0:000000}/{1}) {2} - {3}", i, songs.Count, localsong.Artist, localsong.Title));
|
||||
if (!string.IsNullOrEmpty(localsong.Artist) && !string.IsNullOrEmpty(localsong.Title) && localsong.Disabled == false && localsong.Path.Contains(".mp4"))
|
||||
{
|
||||
string key = localsong.Artist + " - " + localsong.Title;
|
||||
if (dupes.ContainsKey(key) == false)
|
||||
{
|
||||
var dsongs = songs.Where(s =>
|
||||
s.Path != localsong.Path &&
|
||||
s.Title.ToLower() == localsong.Title.ToLower() &&
|
||||
s.Artist.ToLower() == localsong.Artist.ToLower() &&
|
||||
localsong.Disabled == false);
|
||||
|
||||
if (dsongs.Count() > 1)
|
||||
{
|
||||
List<Song> d = new List<Song>();
|
||||
d.AddRange(dsongs.ToList());
|
||||
dupes.Add(key, d);
|
||||
}
|
||||
foreach (var item in dsongs)
|
||||
{
|
||||
item.Disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
client.Set(firepath, songs);
|
||||
}
|
||||
|
||||
private static Song MakeSong(string filepath)
|
||||
{
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user