Skip to content

Commit

Permalink
Add magnet support (#7)
Browse files Browse the repository at this point in the history
* Add magnet support

Add torrent from magnet link
line 188-195

* Update index.js

import/export fix
  • Loading branch information
martinvidalperez committed Apr 16, 2020
1 parent af0330f commit 9a3a939
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/index.js
@@ -1,9 +1,9 @@
import axios from 'axios'
import * as stream from 'stream'
import * as FormData from 'form-data'
const stream = require('stream')
const { default: axios } = require('axios')
const FormData = require('form-data')
const isNode = typeof stream !== 'undefined'

export default class DelugeRPC {
module.exports = class DelugeRPC {
/**
* @constructor
* @param {string} delugeRpcBaseUrl deluge-web rpc url (without json)
Expand Down Expand Up @@ -185,11 +185,11 @@ export default class DelugeRPC {
}

// a URL
let isURL = false
let url = false
try {
isURL = !!new URL(torrent)
url = new URL(torrent)
} catch (e) {}
if (isURL) {
if (url && url.protocol !== 'magnet:') {
torrent = await this.call('web.download_torrent_from_url', [torrent, config.cookie])
delete config.cookie
}
Expand Down

0 comments on commit 9a3a939

Please sign in to comment.