|
@@ -110,6 +110,10 @@ module RSeed
|
|
|
|
|
|
# Add Torrent File
|
|
|
# ----------------
|
|
|
+ get '/add' do
|
|
|
+ haml :add
|
|
|
+ end
|
|
|
+
|
|
|
post '/add/:type' do
|
|
|
case params[:type]
|
|
|
when 'file'
|
|
@@ -122,6 +126,22 @@ module RSeed
|
|
|
# TODO
|
|
|
when 'magnet'
|
|
|
# TODO
|
|
|
+ when 't411'
|
|
|
+ throw(:halt, [404, "Ya pas d'id wesh ...."]) if params['lien'] == nil
|
|
|
+ if(URI(params['lien']).host == "www.t411.me")
|
|
|
+ throw(:halt, [401, "Go conf user/password pour t411 !"]) if @config.get("t411_username") == nil or @config.get("t411_password") == nil
|
|
|
+ id = /\d+/.match(Nokogiri::HTML(open(params['lien'])).css("a.btn.call").first.values[0]).to_s
|
|
|
+ token = JSON.parse(RestClient.post "https://api.t411.me/auth", :username => @config.get("t411_username"), :password => @config.get("t411_password"))['token']
|
|
|
+ torrentName = JSON.parse(RestClient.get "https://api.t411.me/torrents/details/#{id}", {'Authorization' => token})['rewritename']
|
|
|
+ torrentFileContent = RestClient.get "https://api.t411.me/torrents/download/#{id}", {'Authorization' => token}
|
|
|
+ torrentFile = @config.get("data_path") + "/" + torrentName + ".torrent"
|
|
|
+ File.open(torrentFile, 'wb') {|f| f.write(torrentFileContent) }
|
|
|
+ @rtorrent.add(torrentFile)
|
|
|
+ return "Torrent ajouté !"
|
|
|
+ else
|
|
|
+ torrentFile = @config.get("data_path") + "/" + File.basename(params['lien'])
|
|
|
+ File.open(torrentFile, 'wb') {|f| f.write(open(params['lien']).read)}
|
|
|
+ end
|
|
|
else
|
|
|
404
|
|
|
end
|