Jelajahi Sumber

DL torrent file from url or with t411 api if needed

Boulet 11 tahun lalu
induk
melakukan
fc9e576a6f
6 mengubah file dengan 27 tambahan dan 4 penghapusan
  1. 3 1
      config.yml-dist
  2. 4 1
      lib/rSeed.rb
  3. 8 1
      lib/rSeed/rtorrent.rb
  4. 3 0
      public/js/custom.js
  5. 8 0
      views/add.haml
  6. 1 1
      views/index.haml

+ 3 - 1
config.yml-dist

@@ -7,4 +7,6 @@ rtorrent:
   rpc_port: 80              # Default port for your HTTP server
   rpc_path: "/RPC2"         # Location directive in your HTTP instance to connect to rTorrent
 
-
+t411:
+#  t411_username: "login"    # T411.me username
+#  t411_password: "password" # T411.me password

+ 4 - 1
lib/rSeed.rb

@@ -13,7 +13,10 @@ require "sinatra"
 require "xmlrpc/client"
 require "sys/filesystem"
 require "yaml"
-
+require "rest_client"
+require "nokogiri"
+require "open-uri"
+ 
 require "rSeed/server"
 require "rSeed/config"
 require "rSeed/session"

+ 8 - 1
lib/rSeed/rtorrent.rb

@@ -72,7 +72,14 @@ module RSeed
     end
 
     def add(file)
-      
+      begin
+        @client.call("load_start",file)
+      rescue XMLRPC::FaultException => e
+        puts "Error:"
+        puts e.faultCode
+        puts e.faultString
+      end
+
     end
 
   end

+ 3 - 0
public/js/custom.js

@@ -75,3 +75,6 @@ function bytesToSize(bytes, speed) {
   }
 };
 
+function poppupAddTorrent(){
+  window.open("/add", "Ajout d'un torrent", config='height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
+}

+ 8 - 0
views/add.haml

@@ -0,0 +1,8 @@
+-# coding: utf-8
+.row
+  .col-md-4{:class => "col-md-offset-4"}
+    %form{:role => "form", :method => "post", :action => "add/t411"}
+      %h2.text-center Ajout Torrent
+      .form-group
+        %input{:type => "text", :name => "lien", :class => "form-control", :placeholder => "Lien", :style => "border-radius: 4px 4px 0 0;"}
+      %button{:type => "submit", :class => "btn btn-primary btn-lg btn-block", :style => "text-align='center'"} Go Go Go

+ 1 - 1
views/index.haml

@@ -30,7 +30,7 @@
                 %strong#down-info
           %ul.left
             %li
-              %a.button.radius.alert{href: "#"} Add
+              %a.button.radius.alert{href: "#", onClick: "poppupAddTorrent()"} Add
     %section.main-section{style: "margin: 50px 10px"}
       %table{style: "width: 100%;"}
         %thead