Jipy Posted October 21, 2007 Report Posted October 21, 2007 I'm developing a .NET library for the UTorrent WebUI, you'll find it on a svn :http://88.191.26.230/UTorrentLibLogin : utorrent / utorrentIt comes with a very simple Gui, to show how to use the lib with windows forms.Simple gui example : Edit2: For IE only online Gui launcher : HereP.S: if you have some time feel free to help P.S 2 : Not really documented yet.
Chay Posted November 21, 2007 Report Posted November 21, 2007 Jipy, I get:svn import "http://88.191.26.230/UTorrentLib" --username utorrent --password utorrent svn: MKACTIVITY of '/UTorrentLib/!svn/act/1ade8b64-ca84-7747-b62b-3f93a7c63904': 403 Forbidden (http://88.191.26.230)Can you confirm access from external IP's?Thanks,ChayEDIT--- dammit. wrong command - ignore me!svn checkout "http://88.191.26.230/UTorrentLib" --username utorrent --password utorrent
Jipy Posted November 28, 2007 Author Report Posted November 28, 2007 i haven't comitted the last changes, since no one seemed to be interrested i'll do it next week.
Vakuum Posted December 21, 2007 Report Posted December 21, 2007 Looks good, need to check it when i get home.I'm looking for a .net dll to directly access utorrent, but i guess it needs to go through the webui.
smithimage Posted December 24, 2007 Report Posted December 24, 2007 Hi Jippy..I have downloaded and started to use your code in a attempt enclose the webiu within an ASP.NET 2.0 webapplication (this to higher the security level, i my case let IIS, windows server & security policies handle brute force attack etc.). Doing this I have used your nice code. However I have changed som of your code (e.g refactored the 'UpdateLists' method and added a mtheod called 'StartNewTorrent' within the TorrentSession class.)If you are intressted in the changes / additions (or want a look at the ASP.NET project in progress please let me know)Best regards!smithimage
taxik Posted December 28, 2007 Report Posted December 28, 2007 Hi smithimage, i try make web app on uTorrent Web UI with multiuser, forum, statistics and other features. I tryed Jippy's library, but I had some problems.I´m interested in your project and I can help you with developing. Could you tell me something about your idea and show me your project?Thanks, Lukas.
Jipy Posted December 29, 2007 Author Report Posted December 29, 2007 Ok I've been busy lately, I've just moved in Montreal.I'll resume my work on the lib starting tomorrow. I'm interrested in your changes, can you contact me by msn or mail (jipy666(at)hotmail(dot)com)
smithimage Posted December 29, 2007 Report Posted December 29, 2007 Hi there Jipy and taxik.I have now published my work and the changes I made at this address :http://www.smithimage.com/home/development.aspxMy basic idea was / is just to make it "safely", publicly (but restricted) publishable on a windows server (i.e. asp.NET). This since the security implemented in the webui as is don't implement any brute force security checks (as far as I could figure out anyhow). My idea is just to use the C# UTorrentlib and wire a simple (ajax enabled) asp.net UI around the UTorrentlib and let IIS-folder security and security policies (or any other security solution usable within the asp.net) handle multiple faulty login tries (with lookout rules). This by publicly publish this restricted asp.net application on my webserver (on port 80) having the UTorrent WebUI running behind the firewall on a port not publicly visable from outside the firewall.Please have in mind this is a work in progress just started, but don't hesitate to make any remark in regard to the idea or problem solution.. Best regards!smithimage
taxik Posted January 27, 2008 Report Posted January 27, 2008 Hi smithimage, good job... I like your WebUI. Do you have a new realease? Because I must start on my multiuser WebUI. I have extern app, that can start torrents to directory of every user, but I need UI with better loggin and with session of every user.Taxik.
McBainUK Posted April 17, 2008 Report Posted April 17, 2008 I'm interested in making a uTorrent front end for GB-PVR (www.gbpvr.com) via the WebUI.Has any progress been made with the .NET library? I've downloaded it from the svn but there are some bugs...
abstract800 Posted June 12, 2008 Report Posted June 12, 2008 hi everyoneI have downloaded this .net code. I get hazy when i debug it and check for UTorrentStatus field in torrent object. I found its 233/201. it means more than 1 state is set in that long variable. why is it like this? 233 means start,pause states are set. but the torrent is in pause mode. i can find out by ANDing it but the problem is when both are set in 233 case what should i take?one more thing. start,stop,pause actions do not update internal data structures about modified torrents. The code given here calls updateLists() periodically and updates internal structures which reflect new values. I dont want to call updateList() periodically in my project. to overcome this problem what i did is , i called updateLists() method whenever i do any action(like start,stop,pause) on any torrent.somebody pls help me out
Lord Alderaan Posted June 12, 2008 Report Posted June 12, 2008 About the status. Its a bitwise integer:http://forum.utorrent.com/viewtopic.php?pid=272592#p272592A torrent can be started (=not stopped) and then paused. So yes it has bot statuses at the same time.
abstract800 Posted June 13, 2008 Report Posted June 13, 2008 helloWhen we add a torrent file from webUI it makes a HTTP POST request and sends the torrent file right. I have done multipart/form-data post but the result is error.Torrent logger shows "?action=add-file" in its log, but that doesn't mean success or failure. I did not find this piece of code in the .NET library i downloaded here. pls find the c# code here and correct me where i'm wrong.c# code==============================================================HttpWebRequest ts = (HttpWebRequest)HttpWebRequest.Create("http://" + this.m_strHostname + ":" + this.m_iPort.ToString() + "/gui/" + request); ts.KeepAlive = false; ts.Headers.Add("Authorization: Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(this.m_strUsername + ":" + this.m_strPassword))); string postdata = ""; string boundary = "------------------------BoundaryLine"; postdata += "\r\n"+"--" + boundary + "\r\n"; postdata += "Content-Disposition: form-data; name=\"file\" filename=\""+new FileInfo(torrentFilePath).Name+"\""+"\r\n"; postdata += "Content-Type: application/x-bittorrent" + "\r\n";//+ getContentType(@torrentFilePath) + "\r\n"; postdata += "" + "\r\n"; char[] chartowrite1 = postdata.ToCharArray(); byte[] w1 = Encoding.ASCII.GetBytes(postdata); postdata = "\r\n" + "--" + boundary + "--\r\n"; char[] chartowrite2 = postdata.ToCharArray(); byte[] w2 = Encoding.ASCII.GetBytes(postdata);//fileBytes contains the torrenfile contents . its type is byte[] byte[] bytesToWrite = new byte[w1.Length + w2.Length + fileBytes.Length]; int index = 0; for (int i = 0; i < w1.Length; i++) { bytesToWrite[index + i] = (byte)w1; } index += w1.Length; for(int i=0; i<fileBytes.Length;i++) { bytesToWrite[index+i]=fileBytes; } index += fileBytes.Length; for (int i = 0; i < w2.Length; i++) { bytesToWrite[index + i] = (byte)w2; } ts.Method = "POST"; ts.ContentType = "multipart/form-data; boundary=" + boundary; ts.ContentLength = bytesToWrite.Length; Stream writeStream = ts.GetRequestStream(); writeStream.Write(bytesToWrite, 0, bytesToWrite.Length); writeStream.Close(); resp = (HttpWebResponse)ts.GetResponse(); StreamReader responseReader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8); String response = responseReader.ReadToEnd(); Object GuiResp = JavaScriptConvert.DeserializeObject(response);=========================================================data posted looks like this.--------------------------BoundaryLineContent-Disposition: form-data; name="file" filename="TorrentSession.cs.torrent"Content-Type: application/x-bittorrentd10:created by13:uTorrent/177013:creation datei1213169314e8:encoding5:UTF-84:infod6:lengthi12615e4:name17:TorrentSession.cs12:piece lengthi65536e6:pieces20:?6?"·]û¬ºù♫↓?↔µ↓Y▲►ee--------------------------BoundaryLine--=============================================================in the content-disposition i tried name="torrent_file" also but of no use.GuiResp at the end of code shows error as the response.some one pls help me out adding torrent
Tyron Posted June 14, 2008 Report Posted June 14, 2008 Hi,This looks great but i am getting an error when testing your sample. IT also happens when i call the code in my version.here is the error"The given key was not present in the dictionary."this is the line throwing the exeptionJavaScriptArray mjsTorrents = (JavaScriptArray)GuiResp["torrentp"]; // More code below here is the code sample generating the error: public void UpdateLists() { //Sending request and retrieving response. JavaScriptObject GuiResp = GetResponseFromUi("?list=1&cid=" + this.m_strLastCache); this.m_strLastCache = (String)GuiResp["torrentc"]; //Creating a List of the modified torrents. List<JavaScriptArray> mTorrents = new List<JavaScriptArray>(); JavaScriptArray mjsTorrents = (JavaScriptArray)GuiResp["torrentp"]; for (int i = 0; i < mjsTorrents.Count; i++) { mTorrents.Add((JavaScriptArray)mjsTorrents[i]); }and full exeption detailSystem.Collections.Generic.KeyNotFoundException was unhandled Message="The given key was not present in the dictionary." Source="mscorlib" StackTrace: at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at UTorrentLib.TorrentSession.UpdateLists() in C:\Users\Tyron\Desktop\New Folder\UTorrentLib\TorrentSession.cs:line 122 at UtorrentApp.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Tyron\Documents\Visual Studio 2008\Projects\Utorrent\Utorrent\Form1.cs:line 28 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at UtorrentApp.Program.Main() in C:\Users\Tyron\Documents\Visual Studio 2008\Projects\Utorrent\Utorrent\Program.cs:line 19 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
abstract800 Posted June 16, 2008 Report Posted June 16, 2008 HiI have a reason why you are getting KeyNotFoundException. If the response from utorrent client doesn't contain records for "torrentp", you will get this exception. Because without checking whether there is any record with key "torrentp" you are trying to get results for it. The code which you have is outdated. There is a new code for updateList() where there is check for the key something like below JavaScriptObject GuiResp = GetResponseFromUi("?list=1&cid=" + this.m_strLastCache); this.m_strLastCache = (String)GuiResp["torrentc"]; //Creating a List of the modified torrents. List<JavaScriptArray> mTorrents = new List<JavaScriptArray>();if(GuiResp.ContainsKey("torrentp"){ JavaScriptArray mjsTorrents = (JavaScriptArray)GuiResp["torrentp"]; for (int i = 0; i < mjsTorrents.Count; i++) { mTorrents.Add((JavaScriptArray)mjsTorrents); }}If any of you have code to POST torrent file pls share with me. I need it immediately
kamia Posted June 16, 2008 Report Posted June 16, 2008 I haven't done .Net programing in a while, but I can offer you the way to do it in Javascriptshould be simple enough to change around to either C# or whatever language you use in your .Netwell, lets just say your also missing a semicolon after your file="torrent_file"but otherwise I can't really see much of an error in your coding...and IDK about this, wouldn't it be easier to create a binaryWriter than to convert it using that method. Also just for pretifying code, wouldn't it be easier to create a function to write your bytes for you, i mean you are essentially calling the same code 3 times. Bleh, nvm me I'm not the one to talk about making code efficient . Anyways... I think thats your problem though, i haven't really tested it... But thats what I think you are missing the semicolon.BTW >>> code is from the uTorrent firefox extension, and isn't written by mevar multipartBoundary = "=*=*=*=*=*=";function writeBinary(ostream, string){ for(i=0; i != string.length; ++i) { ostream.write8(string.charAt(i)); }}function addTorrent(uri, torrentData){ var body = Components.classes["@mozilla.org/storagestream;1"] .createInstance(Components.interfaces.nsIStorageStream); body.init(1024, 1024*1024, null); var bodyOutput = body.getOutputStream(0); var bodyBinary = Components.classes["@mozilla.org/binaryoutputstream;1"] .createInstance(Components.interfaces.nsIBinaryOutputStream); bodyBinary.setOutputStream(bodyOutput); var filename = getFilenameFromUri(uri); writeBinary(bodyBinary, "--" + multipartBoundary + "\r\n" + "Content-Disposition: form-data; name=\"torrent_file\"; filename=\"" + filename + "\"\r\n" + "Content-Type: application/x-bittorrent\r\n" + "\r\n"); writeBinary(bodyBinary, torrentData); writeBinary(bodyBinary, "\r\n--" + multipartBoundary + "--\r\n"); bodyOutput.close(); var request = new XMLHttpRequest(); request.open("POST", gUTorrentPrefs.getConnectionType() + "://" + gUTorrentPrefs.serverAddress() + ":" + gUTorrentPrefs.serverPort() + "/gui/?action=add-file", true, gUTorrentPrefs.adminUsername(), gUTorrentPrefs.adminPassword()); request.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + multipartBoundary); request.onreadystatechange = function(event) { if (request.readyState == 4) { if (request.status == 200) { var response = request.responseText.parseJSON(); var message = response.error; if (message != null) displayError("uTorrent responded with an error for torrent \"" + uri.spec + "\". The error was: " + message); } else { displayError("Error uploading torrent file \"" + uri.spec + "\" to uTorrent. Error code was " + request.status + "."); } } }; var bodyInput = bodyOutput.newInputStream(0); request.send(bodyInput);}
Maedhros Posted November 11, 2008 Report Posted November 11, 2008 Hi everyone,What ever became of this library?I am looking for a way to hook into uTorrent, which I found has to be the webUI. I then found references to this wrapper, which I would like to check out. However I am not able to get contact to the SVN and checkout the source using TortoiseSVN.Can anyone confirm if this project is dead or still in development?Thanks,Bo
tombull Posted December 8, 2008 Report Posted December 8, 2008 Hi, I've written a new .NET API, you can find it here: http://www.codeplex.com/uTorrentClientThe new API uses WCF / .NET Framework 3.5, and fully supports all the functions of the uTorrent Web UI.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.