namespace CaptionSpeak
{
public class Plugin : IPlugin
{
string userPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase), "CaptionSpeak"); //gets working directory of the K-Relay plugin
public string GetAuthor()
{
return "ElGato";
}
public string[] GetCommands()
{
string[] TODO = new String[1];
TODO[1] = "TODO";
return TODO;
}
public string GetDescription()
{
return "TODO";
}
public string GetName()
{
return "CaptionSpeak";
}
public void Initialize(Proxy proxy)
{
proxy.HookCommand("capspeak", captionDownload);
Console.WriteLine(userPath);
if (!File.Exists(userPath)) //creates directory for downloads if not already created
{
Directory.CreateDirectory(userPath);
}
}
private void captionParse(string file) //parses the file, removing timestamps and the like
{
var parser = new SubtitlesParser.Classes.Parsers.SrtParser();
using (var fileStream = File.OpenRead(file))
{
var items = parser.ParseStream(fileStream, Encoding.Unicode);
}
}
private PlayerTextPacket playback(string path) //TODO chats the text from the caption file
{
PlayerTextPacket captionSpeak = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
captionSpeak.Text = " ";
return captionSpeak;
}
private async void captionDownload(Client client, string command, string[] args)
{
if (args.Length == 0)
{
return;
}
if (args[0] == "get")
{
if (args[1] == null)
{
client.SendToClient(PluginUtils.CreateNotification(client.ObjectId, "No URL Specified"));
//TextPacket invalid = (TextPacket)Packet.Create(PacketType.TEXT);
//invalid.Name = "CaptionSpeak";
//invalid.Text = "No URL Specified";
//client.SendToClient(invalid); //using chat instead of notifications
return;
}
else
{
int num = 1;
string[] files = Directory.GetFiles(userPath);
for (int i = 0; i < files.Length; i++) //puts files in a numerical order
{
if (files[i][0] == Convert.ToChar(num))
{
num++;
}
else
{
break;
}
}
var youtubeClient = new YoutubeClient(); //code pretty much copied from the GitHub page
var videoInfo = await youtubeClient.GetVideoInfoAsync(args[1]);
var captionTrackInfo = videoInfo.ClosedCaptionTracks.FirstOrDefault(c => c.Language.Code == "en" && c.IsAutoGenerated);
if (captionTrackInfo != null)
{
string fileName = Path.Combine(userPath, num.ToString() + videoInfo.Title);
await youtubeClient.DownloadClosedCaptionTrackAsync(captionTrackInfo, fileName);
//captionParse(fileName);
}
else
{
Console.WriteLine("Captions not found for specified video");
}
}
}
}
}
}
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at K_Relay.FrmMainMetro.InitPlugins()
at K_Relay.FrmMainMetro.<FrmMainMetro_Load>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2102.0 built by: NET47REL1LAST
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
K_Relay
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/K_Relay.exe
----------------------------------------
MetroFramework
Assembly Version: 1.3.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/K_Relay.exe
----------------------------------------
MetroFramework.Design
Assembly Version: 1.3.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/K_Relay.exe
----------------------------------------
MetroFramework.Fonts
Assembly Version: 1.3.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/K_Relay.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2104.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2103.2 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2046.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Lib K Relay
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/Lib%20K%20Relay.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2046.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2102.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2102.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2102.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2046.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
System.Xml.Linq
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2046.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
AutoAbility
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/Plugins/AutoAbility.dll
----------------------------------------
AutoNexus
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/Plugins/AutoNexus.dll
----------------------------------------
MapCacher
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/Plugins/MapCacher.DLL
----------------------------------------
BouncyCastle.Crypto
Assembly Version: 1.8.1.0
Win32 Version: 1.8.15362.1
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/Plugins/BouncyCastle.Crypto.dll
----------------------------------------
CaptionSpeak
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/kmcgr/Documents/RotMG/K-Relay/Plugins/CaptionSpeak.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
private void startCaptionDownload(Client client, string command, string[] args)
{
captionDownload(client, command, args);
}
proxy.HookCommand("capspeak", startCaptionDownload);