|
@@ -137,10 +137,9 @@ module RSeed
|
|
File.open(@config.get("data_path") + "/" + params['torrentFile'][:filename], "w") do |f|
|
|
File.open(@config.get("data_path") + "/" + params['torrentFile'][:filename], "w") do |f|
|
|
f.write(params['torrentFile'][:tempfile].read)
|
|
f.write(params['torrentFile'][:tempfile].read)
|
|
end
|
|
end
|
|
- @rtorrent.add(params['torrentFile'][:filename])
|
|
|
|
- return "Success!"
|
|
|
|
|
|
+ return "OK" if @rtorrent.add(params['torrentFile'][:filename])
|
|
when 'link'
|
|
when 'link'
|
|
- # TODO
|
|
|
|
|
|
+ return "Torrent added !" if @rtorrent.add(params[:link])
|
|
when 't411'
|
|
when 't411'
|
|
throw(:halt, [404, "Ya pas d'id wesh ...."]) if params['lien'] == nil
|
|
throw(:halt, [404, "Ya pas d'id wesh ...."]) if params['lien'] == nil
|
|
if(URI(params['lien']).host == "www.t411.me")
|
|
if(URI(params['lien']).host == "www.t411.me")
|
|
@@ -151,8 +150,7 @@ module RSeed
|
|
torrentFileContent = RestClient.get "https://api.t411.me/torrents/download/#{id}", {'Authorization' => token}
|
|
torrentFileContent = RestClient.get "https://api.t411.me/torrents/download/#{id}", {'Authorization' => token}
|
|
torrentFile = @config.get("data_path") + "/" + torrentName + ".torrent"
|
|
torrentFile = @config.get("data_path") + "/" + torrentName + ".torrent"
|
|
File.open(torrentFile, 'wb') {|f| f.write(torrentFileContent) }
|
|
File.open(torrentFile, 'wb') {|f| f.write(torrentFileContent) }
|
|
- @rtorrent.add(torrentFile)
|
|
|
|
- return "Torrent ajouté !"
|
|
|
|
|
|
+ return @rtorrent.add(torrentFile)
|
|
else
|
|
else
|
|
torrentFile = @config.get("data_path") + "/" + File.basename(params['lien'])
|
|
torrentFile = @config.get("data_path") + "/" + File.basename(params['lien'])
|
|
File.open(torrentFile, 'wb') {|f| f.write(open(params['lien']).read)}
|
|
File.open(torrentFile, 'wb') {|f| f.write(open(params['lien']).read)}
|
|
@@ -161,7 +159,9 @@ module RSeed
|
|
404
|
|
404
|
|
end
|
|
end
|
|
end
|
|
end
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ # API
|
|
|
|
+ # ---
|
|
get '/api/:request' do
|
|
get '/api/:request' do
|
|
content_type :json
|
|
content_type :json
|
|
case params[:request]
|
|
case params[:request]
|