first working play using the polymer data structure.
This commit is contained in:
parent
18fee93f93
commit
b5ab01e054
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "herse.models"]
|
||||
path = herse.models
|
||||
url = git@bitbucket.org:teamherse/herse.models.git
|
||||
@ -1,32 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using KaraokePlayer.Interfaces;
|
||||
using KaraokePlayer.Enums;
|
||||
using FireSharp.Interfaces;
|
||||
using FireSharp.Config;
|
||||
using FireSharp;
|
||||
using Newtonsoft.Json;
|
||||
using System.Configuration;
|
||||
|
||||
namespace KaraokePlayer.Classes
|
||||
{
|
||||
public class FirebaseSong : ISong
|
||||
|
||||
public class Singer
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public int Order { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Artist { get; set; }
|
||||
public FileType FileType { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string Description { get { return Artist + " - " + Title; } }
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class FirebaseController : IController
|
||||
public class Song
|
||||
{
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonProperty("artist")]
|
||||
public string Artist { get; set; }
|
||||
|
||||
[JsonProperty("genre")]
|
||||
public string Genre { get; set; }
|
||||
|
||||
[JsonProperty("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[JsonProperty("path")]
|
||||
public string Path { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public FileType FileType
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Path.Substring(Path.Length - 3, 3).ToLower())
|
||||
{
|
||||
case "cdg":
|
||||
case "mp3":
|
||||
return FileType.CDG;
|
||||
case "mp4":
|
||||
return FileType.MP4;
|
||||
case "zip":
|
||||
return FileType.ZIP;
|
||||
default:
|
||||
throw new Exception("file type not handled");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class QueueItem
|
||||
{
|
||||
[JsonProperty("singer")]
|
||||
public Singer Singer { get; set; }
|
||||
|
||||
[JsonProperty("song")]
|
||||
public Song Song { get; set; }
|
||||
}
|
||||
|
||||
public class FirebaseController
|
||||
{
|
||||
public static Guid TestGuid = Guid.Parse("f1ec2c8a-6f11-4ac0-8b0e-e576d15f2759");
|
||||
private IFirebaseConfig config = new FirebaseConfig
|
||||
{
|
||||
AuthSecret = "wj0ERDFZqNSysTtIXcCgCr8Itahr6pJOBeqCjvDF",
|
||||
BasePath = "https://karaokecontroller.firebaseio.com/"
|
||||
AuthSecret = ConfigurationManager.AppSettings["Firebase.Secret"],
|
||||
BasePath = ConfigurationManager.AppSettings["Firebase.Path"]
|
||||
};
|
||||
private string _state = "stop";
|
||||
private IFirebaseClient _client;
|
||||
@ -36,36 +81,36 @@ namespace KaraokePlayer.Classes
|
||||
|
||||
private string StatePath
|
||||
{
|
||||
get { return string.Format("Controllers/{0}/State", this.Id); }
|
||||
get { return string.Format("controllers/{0}/state/", this.Id); }
|
||||
}
|
||||
private string PlayQueuePath
|
||||
{
|
||||
get { return string.Format("Controllers/{0}/PlayQueue", this.Id); }
|
||||
get { return string.Format("controllers/{0}/queue/", this.Id); }
|
||||
}
|
||||
private string CurrentSongPath
|
||||
{
|
||||
get { return string.Format("Controllers/{0}/CurrentSong", this.Id); }
|
||||
get { return string.Format("controllers/{0}/queue/0/", this.Id); }
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public ISong CurrentSong { get; set; }
|
||||
public List<ISong> PlayQueue { get; set; }
|
||||
public string Id { get; set; }
|
||||
public Song CurrentSong { get; set; }
|
||||
public List<Song> PlayQueue { get; set; }
|
||||
|
||||
public string State {
|
||||
get { return State; }
|
||||
set {
|
||||
_state = value;
|
||||
Update(string.Format("Controllers/{0}", this.Id), new { State = _state });
|
||||
Update(string.Format("controllers/{0}", this.Id), new { state = _state });
|
||||
}
|
||||
}
|
||||
|
||||
public FirebaseController(Guid clientId, ControllerStateChangedEventHandler stateChanged, ControllerSongChangedEventHandler songChanged, ControllerPlayQueueChangedEventHandler playQueueChanged)
|
||||
public FirebaseController(string clientId, ControllerStateChangedEventHandler stateChanged, ControllerSongChangedEventHandler songChanged, ControllerPlayQueueChangedEventHandler playQueueChanged)
|
||||
{
|
||||
Id = clientId;
|
||||
_stateChanged = stateChanged;
|
||||
_songChanged = songChanged;
|
||||
_playQueueChanged = playQueueChanged;
|
||||
PlayQueue = new List<ISong>();
|
||||
PlayQueue = new List<Song>();
|
||||
_client = new FirebaseClient(config);
|
||||
Reset();
|
||||
SetupListener();
|
||||
@ -73,46 +118,12 @@ namespace KaraokePlayer.Classes
|
||||
|
||||
public void NextSong()
|
||||
{
|
||||
ISong song = PlayQueue.FirstOrDefault();
|
||||
Song song = PlayQueue.FirstOrDefault();
|
||||
Stop();
|
||||
if(song != null) { PlaySong(song); }
|
||||
}
|
||||
|
||||
public void PlaySong(ISong song) { Update(string.Format("Controllers/{0}", this.Id), new { CurrentSong = song }); }
|
||||
|
||||
public void AddSong(ISong song) { Update(string.Format("Controllers/{0}/PlayQueue/{1}", this.Id, song.Id), song); }
|
||||
|
||||
public void RemoveSong(ISong song)
|
||||
{
|
||||
ISong found = PlayQueue.FirstOrDefault(s => s.Id == song.Id);
|
||||
if (found != null)
|
||||
{
|
||||
PlayQueue.Remove(found);
|
||||
Delete(PlayQueuePath + "/" + song.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public void SkipSong()
|
||||
{
|
||||
ISong song = null;
|
||||
int count = PlayQueue.Count();
|
||||
int index = PlayQueue.FindIndex(s => s.Id == CurrentSong.Id);
|
||||
if (index + 1 == count && count > 1)
|
||||
{
|
||||
song = PlayQueue.First();
|
||||
}
|
||||
else {
|
||||
if (PlayQueue.Count() > index)
|
||||
{
|
||||
song = PlayQueue[index + 1];
|
||||
}
|
||||
}
|
||||
Stop();
|
||||
if(song != null)
|
||||
{
|
||||
PlaySong(song);
|
||||
}
|
||||
}
|
||||
public void PlaySong(Song song) { Update(string.Format("Controllers/{0}", this.Id), new { CurrentSong = song }); }
|
||||
|
||||
public void Next() { this.State = "Next"; }
|
||||
|
||||
@ -138,24 +149,26 @@ namespace KaraokePlayer.Classes
|
||||
await _client.OnAsync(CurrentSongPath,
|
||||
added: (s, args, obj) =>
|
||||
{
|
||||
if (args.Path.Contains("Id"))
|
||||
if (args.Path == "/singer/name")
|
||||
{
|
||||
Console.WriteLine("added " + args.Path + " " + args.Data);
|
||||
CurrentSongDidChange();
|
||||
}
|
||||
},
|
||||
changed: (s, args, obj) =>
|
||||
removed: (s, args, obj) =>
|
||||
{
|
||||
if (args.Path.Contains("Id"))
|
||||
//TODO: the current song was removed from the queue
|
||||
if (args.Path == "/singer")
|
||||
{
|
||||
CurrentSongDidChange();
|
||||
Console.WriteLine("removed " + args.Path);
|
||||
}
|
||||
}
|
||||
},
|
||||
removed: null
|
||||
);
|
||||
|
||||
/*
|
||||
await _client.OnAsync(PlayQueuePath,
|
||||
added: (s, args, obj) =>
|
||||
{
|
||||
Console.WriteLine(args.Path);
|
||||
if (args.Path.Contains("Id"))
|
||||
{
|
||||
PlayQueueDidChange();
|
||||
@ -185,18 +198,19 @@ namespace KaraokePlayer.Classes
|
||||
},
|
||||
removed: null
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
private void PlayQueueDidChange()
|
||||
{
|
||||
bool autoPlay = PlayQueue.Count() == 0;
|
||||
var response = _client.Get(PlayQueuePath);
|
||||
var dict = response.ResultAs<Dictionary<string, FirebaseSong>>();
|
||||
var dict = response.ResultAs<Dictionary<string, Song>>();
|
||||
|
||||
PlayQueue.Clear();
|
||||
if (dict != null && dict.Count() > 0)
|
||||
{
|
||||
var array = dict.Values.OrderBy(s => s.Order).ToArray();
|
||||
var array = dict.Values.ToArray();
|
||||
PlayQueue.AddRange(array);
|
||||
if (autoPlay)
|
||||
{
|
||||
@ -209,11 +223,11 @@ namespace KaraokePlayer.Classes
|
||||
private void CurrentSongDidChange()
|
||||
{
|
||||
var response = _client.Get(CurrentSongPath);
|
||||
var song = response.ResultAs<FirebaseSong>();
|
||||
if (song != null)
|
||||
var item = response.ResultAs<QueueItem>();
|
||||
if (item != null)
|
||||
{
|
||||
CurrentSong = song;
|
||||
_songChanged(new ControllerSongChangedEventArgs(false, song));
|
||||
CurrentSong = item.Song;
|
||||
_songChanged(new ControllerSongChangedEventArgs(item.Song));
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,7 +247,7 @@ namespace KaraokePlayer.Classes
|
||||
{
|
||||
s = PlayerState.Next;
|
||||
}
|
||||
_stateChanged(new ControllerStateChangedEventArgs(s));
|
||||
//_stateChanged(new ControllerStateChangedEventArgs(s));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Net.Http.Extensions, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
@ -73,7 +74,6 @@
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="FirebaseController.cs" />
|
||||
<Compile Include="Interfaces.cs" />
|
||||
<Compile Include="PlayerDelegates.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
using KaraokePlayer.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KaraokePlayer.Interfaces
|
||||
{
|
||||
public interface ISong
|
||||
{
|
||||
Guid Id { get; set; }
|
||||
int Order { get; set; }
|
||||
string Title { get; set; }
|
||||
string Artist { get; set; }
|
||||
FileType FileType { get; set; }
|
||||
string Path { get; set; }
|
||||
string Description { get; }
|
||||
}
|
||||
|
||||
public interface IController
|
||||
{
|
||||
Guid Id { get; set; }
|
||||
ISong CurrentSong { get; set; }
|
||||
string State { get; set; }
|
||||
List<ISong> PlayQueue { get; set; }
|
||||
void NextSong();
|
||||
void RemoveSong(ISong song);
|
||||
void AddSong(ISong song);
|
||||
void SkipSong();
|
||||
void Play();
|
||||
void Pause();
|
||||
void Stop();
|
||||
void Next();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using KaraokePlayer.Enums;
|
||||
using KaraokePlayer.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -18,17 +17,17 @@ namespace KaraokePlayer.Classes
|
||||
}
|
||||
public class ControllerSongChangedEventArgs
|
||||
{
|
||||
public ControllerSongChangedEventArgs(ISong song)
|
||||
public ControllerSongChangedEventArgs(Song song)
|
||||
{
|
||||
ShouldPlay = true;
|
||||
Song = song;
|
||||
}
|
||||
public ControllerSongChangedEventArgs(bool shouldPlay, ISong song)
|
||||
public ControllerSongChangedEventArgs(bool shouldPlay, Song song)
|
||||
{
|
||||
ShouldPlay = shouldPlay;
|
||||
Song = song;
|
||||
}
|
||||
public ISong Song { get; }
|
||||
public Song Song { get; }
|
||||
public bool ShouldPlay { get; }
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CdgLib", "CdgLib\CdgLib.csproj", "{3203DFD2-DA5B-47B3-B009-18DD9C401FC3}"
|
||||
EndProject
|
||||
@ -13,10 +13,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KaraokePlayer", "KaraokePla
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CdgPlayer", "CdgPlayer\CdgPlayer.csproj", "{A5324295-6BD2-4415-92CD-6EA77D708E00}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSelector", "TestSelector\TestSelector.csproj", "{B81665BC-A207-47F5-BBF4-2DE59965325F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirebaseKaraoke", "FirebaseKaraoke\FirebaseKaraoke.csproj", "{4FE25E6D-1BEB-4902-9815-C2B421233BD7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SongCrawler", "SongCrawler\SongCrawler.csproj", "{82F60DD0-80EC-49C8-9E7C-95A250783E68}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Herse.Models", "herse.models\Herse.Models.csproj", "{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -35,14 +37,18 @@ Global
|
||||
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B81665BC-A207-47F5-BBF4-2DE59965325F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B81665BC-A207-47F5-BBF4-2DE59965325F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B81665BC-A207-47F5-BBF4-2DE59965325F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B81665BC-A207-47F5-BBF4-2DE59965325F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4FE25E6D-1BEB-4902-9815-C2B421233BD7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -3,10 +3,13 @@
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
|
||||
<connectionStrings>
|
||||
<add providerName="System.Data.SqlClient" connectionString="Data Source=tcp:herse.database.windows.net,1433;Initial Catalog=herse;Persist Security Info=True;User ID=herse;password=94diablo!" name="HerseDb" />
|
||||
</connectionStrings>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<add key="Firebase.Secret" value="9BQHUEJhScgK2FP10hvlToxTlGQpXT94Cvx01piO"/>
|
||||
<add key="Firebase.Path" value="https://herse.firebaseio.com/"/>
|
||||
<add key="KaraokePlayer.ControllerId" value="archer1"/>
|
||||
</appSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
|
||||
@ -79,6 +79,7 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing.Design" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
|
||||
@ -7,9 +7,9 @@ using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO.Compression;
|
||||
using System.Windows.Forms;
|
||||
using KaraokePlayer.Interfaces;
|
||||
using KaraokePlayer.Classes;
|
||||
using System.Threading.Tasks;
|
||||
using System.Configuration;
|
||||
|
||||
namespace KaraokePlayer
|
||||
{
|
||||
@ -18,8 +18,8 @@ namespace KaraokePlayer
|
||||
private SongInfoForm songInfoForm = new SongInfoForm();
|
||||
private delegate void Action();
|
||||
private KaraokeVideoPlayer currentPlayer = null;
|
||||
private IController controller;
|
||||
private ISong currentSong;
|
||||
private FirebaseController controller;
|
||||
private Song currentSong;
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -35,7 +35,7 @@ namespace KaraokePlayer
|
||||
karaokeMP4Player.Dock = DockStyle.Fill;
|
||||
|
||||
controller = new FirebaseController(
|
||||
clientId: FirebaseController.TestGuid,
|
||||
clientId: ConfigurationManager.AppSettings["KaraokePlayer.ControllerId"],
|
||||
stateChanged: (args) =>
|
||||
{
|
||||
if (args.State == Enums.PlayerState.Play)
|
||||
@ -70,7 +70,8 @@ namespace KaraokePlayer
|
||||
songInfoForm.Update(currentSong);
|
||||
songInfoForm.Show();
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
controller.Play();
|
||||
//controller.Play();
|
||||
play();
|
||||
songInfoForm.Hide();
|
||||
}
|
||||
|
||||
@ -81,7 +82,6 @@ namespace KaraokePlayer
|
||||
|
||||
private void next()
|
||||
{
|
||||
controller.RemoveSong(currentSong);
|
||||
controller.NextSong();
|
||||
}
|
||||
|
||||
|
||||
4
KaraokePlayer/SongInfoForm.Designer.cs
generated
4
KaraokePlayer/SongInfoForm.Designer.cs
generated
@ -1,6 +1,4 @@
|
||||
using KaraokePlayer.Interfaces;
|
||||
|
||||
namespace KaraokePlayer
|
||||
namespace KaraokePlayer
|
||||
{
|
||||
partial class SongInfoForm
|
||||
{
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using KaraokePlayer.Interfaces;
|
||||
using KaraokePlayer.Classes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -21,7 +21,7 @@ namespace KaraokePlayer
|
||||
this.ShowInTaskbar = false;
|
||||
}
|
||||
|
||||
public void Update(ISong song)
|
||||
public void Update(Song song)
|
||||
{
|
||||
previewLabel.Text = "Up Next:" + "\r\n\r\n" + song.Artist + "\r\n\r\n\r\n" + song.Title;
|
||||
}
|
||||
|
||||
14
SongCrawler/App.config
Normal file
14
SongCrawler/App.config
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
40
SongCrawler/Program.cs
Normal file
40
SongCrawler/Program.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using FireSharp.Config;
|
||||
using FireSharp.Interfaces;
|
||||
using FireSharp.Response;
|
||||
using Herse.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SongCrawler
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string controller = args[0];
|
||||
string songpath = args[1];
|
||||
IFirebaseConfig config = new FirebaseConfig
|
||||
{
|
||||
AuthSecret = "9BQHUEJhScgK2FP10hvlToxTlGQpXT94Cvx01piO",
|
||||
BasePath = "https://herse.firebaseio.com/"
|
||||
};
|
||||
FireSharp.FirebaseClient client = new FireSharp.FirebaseClient(config);
|
||||
string firepath = string.Format("controllers/{0}/songs", controller);
|
||||
|
||||
|
||||
string[] files = Directory.GetFiles(songpath, "*.mp3");
|
||||
List<Song> songs = new List<Song>();
|
||||
foreach (string file in files)
|
||||
{
|
||||
TagLib.File tagFile = TagLib.File.Create(file);
|
||||
songs.Add(new Song() { Title = tagFile.Tag.Title, Artist = tagFile.Tag.FirstPerformer, Path = file, Genre = tagFile.Tag.FirstGenre, Year = (int)tagFile.Tag.Year });
|
||||
}
|
||||
|
||||
SetResponse response = client.Set(firepath, songs);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
SongCrawler/Properties/AssemblyInfo.cs
Normal file
36
SongCrawler/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SongCrawler")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("SongCrawler")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("82f60dd0-80ec-49c8-9e7c-95a250783e68")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
109
SongCrawler/SongCrawler.csproj
Normal file
109
SongCrawler/SongCrawler.csproj
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{82F60DD0-80EC-49C8-9E7C-95A250783E68}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SongCrawler</RootNamespace>
|
||||
<AssemblyName>SongCrawler</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FireSharp, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FireSharp.2.0.4\lib\portable-net45+sl5+wp8+win8\FireSharp.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Net.Http.Extensions, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Primitives, Version=4.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="taglib-sharp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=db62eba44689b5b0, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>libs\taglib-sharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\herse.models\Herse.Models.csproj">
|
||||
<Project>{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}</Project>
|
||||
<Name>Herse.Models</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="libs\taglib-sharp.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
BIN
SongCrawler/libs/taglib-sharp.dll
Normal file
BIN
SongCrawler/libs/taglib-sharp.dll
Normal file
Binary file not shown.
10
SongCrawler/packages.config
Normal file
10
SongCrawler/packages.config
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FireSharp" version="2.0.4" targetFramework="net452" />
|
||||
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net452" />
|
||||
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net452" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net452" />
|
||||
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
|
||||
<package id="TagLib.Portable" version="1.0.4" targetFramework="net452" />
|
||||
</packages>
|
||||
@ -83,7 +83,6 @@ namespace TestSelector
|
||||
_fileList = filtered.Select(file => new FileInfo(file)).ToList();
|
||||
listBox1.DataSource = _fileList;
|
||||
listBox1.DisplayMember = "Name";
|
||||
|
||||
}
|
||||
}
|
||||
private static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
|
||||
|
||||
BIN
TestSongs/SF365/Thumbs.db
Normal file
BIN
TestSongs/SF365/Thumbs.db
Normal file
Binary file not shown.
1
herse.models
Submodule
1
herse.models
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit bb1162615a259730c3c5786142525060bc1a3128
|
||||
Loading…
Reference in New Issue
Block a user