@ctrl/transmission 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ctrl/transmission",
|
3
|
-
"version": "4.1.
|
3
|
+
"version": "4.1.1",
|
4
4
|
"description": "TypeScript api wrapper for transmission using got",
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
6
6
|
"license": "MIT",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"main": "./dist/src/index.js",
|
14
14
|
"typings": "./dist/src/index.d.ts",
|
15
15
|
"files": [
|
16
|
-
"dist"
|
16
|
+
"dist/src"
|
17
17
|
],
|
18
18
|
"sideEffects": false,
|
19
19
|
"scripts": {
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,136 +0,0 @@
|
|
1
|
-
import fs from 'fs';
|
2
|
-
import path from 'path';
|
3
|
-
import pWaitFor from 'p-wait-for';
|
4
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
5
|
-
import { TorrentState } from '@ctrl/shared-torrent';
|
6
|
-
import { Transmission } from '../src/index.js';
|
7
|
-
const baseUrl = 'http://localhost:9091/';
|
8
|
-
const torrentName = 'ubuntu-18.04.1-desktop-amd64.iso';
|
9
|
-
const torrentFile = path.join(__dirname, '/ubuntu-18.04.1-desktop-amd64.iso.torrent');
|
10
|
-
async function setupTorrent(transmission) {
|
11
|
-
const res = await transmission.addTorrent(torrentFile);
|
12
|
-
await pWaitFor(async () => {
|
13
|
-
const r = await transmission.listTorrents(undefined, ['id']);
|
14
|
-
return r.arguments.torrents.length === 1;
|
15
|
-
}, { timeout: 10000, interval: 200 });
|
16
|
-
return res.arguments['torrent-added'].hashString;
|
17
|
-
}
|
18
|
-
describe('Transmission', () => {
|
19
|
-
afterEach(async () => {
|
20
|
-
const transmission = new Transmission({ baseUrl });
|
21
|
-
const res = await transmission.listTorrents();
|
22
|
-
// clean up all torrents
|
23
|
-
for (const torrent of res.arguments.torrents) {
|
24
|
-
// eslint-disable-next-line no-await-in-loop
|
25
|
-
await transmission.removeTorrent(torrent.id, false);
|
26
|
-
}
|
27
|
-
});
|
28
|
-
it('should be instantiable', () => {
|
29
|
-
const transmission = new Transmission({ baseUrl });
|
30
|
-
expect(transmission).toBeTruthy();
|
31
|
-
});
|
32
|
-
it('should add torrent from file path string', async () => {
|
33
|
-
const transmission = new Transmission({ baseUrl });
|
34
|
-
const res = await transmission.addTorrent(torrentFile);
|
35
|
-
expect(res.result).toBe('success');
|
36
|
-
});
|
37
|
-
it('should add magnet link', async () => {
|
38
|
-
const magnet = 'magnet:?xt=urn:btih:B0B81206633C42874173D22E564D293DAEFC45E2&dn=Ubuntu+11+10+Alternate+Amd64+Iso&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2710%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.open-internet.nl%3A6969%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.si%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.pirateparty.gr%3A6969%2Fannounce&tr=udp%3A%2F%2Fdenis.stalker.upeer.me%3A6969%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce';
|
39
|
-
const client = new Transmission({ baseUrl });
|
40
|
-
const res = await client.addMagnet(magnet);
|
41
|
-
expect(res.result).toBe('success');
|
42
|
-
});
|
43
|
-
it('should add normalized magnet link', async () => {
|
44
|
-
const magnet = 'magnet:?xt=urn:btih:B0B81206633C42874173D22E564D293DAEFC45E2&dn=Ubuntu+11+10+Alternate+Amd64+Iso&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2710%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.open-internet.nl%3A6969%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.si%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.pirateparty.gr%3A6969%2Fannounce&tr=udp%3A%2F%2Fdenis.stalker.upeer.me%3A6969%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce';
|
45
|
-
const client = new Transmission({ baseUrl });
|
46
|
-
const res = await client.normalizedAddTorrent(magnet);
|
47
|
-
expect(res.id).toBeTruthy();
|
48
|
-
});
|
49
|
-
it('should add torrent from file buffer', async () => {
|
50
|
-
const transmission = new Transmission({ baseUrl });
|
51
|
-
const res = await transmission.addTorrent(fs.readFileSync(torrentFile));
|
52
|
-
expect(res.result).toBe('success');
|
53
|
-
});
|
54
|
-
it('should add torrent from file contents base64', async () => {
|
55
|
-
const transmission = new Transmission({ baseUrl });
|
56
|
-
const contents = Buffer.from(fs.readFileSync(torrentFile)).toString('base64');
|
57
|
-
const res = await transmission.addTorrent(contents);
|
58
|
-
expect(res.result).toBe('success');
|
59
|
-
});
|
60
|
-
it('should get torrents', async () => {
|
61
|
-
const transmission = new Transmission({ baseUrl });
|
62
|
-
await setupTorrent(transmission);
|
63
|
-
const res = await transmission.listTorrents(undefined, ['id']);
|
64
|
-
expect(res.arguments.torrents).toHaveLength(1);
|
65
|
-
});
|
66
|
-
it('should get normalized all torrent data', async () => {
|
67
|
-
const transmission = new Transmission({ baseUrl });
|
68
|
-
await setupTorrent(transmission);
|
69
|
-
const res = await transmission.getAllData();
|
70
|
-
expect(res.torrents).toHaveLength(1);
|
71
|
-
expect(res.torrents[0].name).toBe(torrentName);
|
72
|
-
});
|
73
|
-
it('should get normalized torrent data', async () => {
|
74
|
-
const transmission = new Transmission({ baseUrl });
|
75
|
-
const id = await setupTorrent(transmission);
|
76
|
-
const res = await transmission.getTorrent(id);
|
77
|
-
expect(res.name).toBe(torrentName);
|
78
|
-
});
|
79
|
-
it('should remove torrent', async () => {
|
80
|
-
const transmission = new Transmission({ baseUrl });
|
81
|
-
const key = await setupTorrent(transmission);
|
82
|
-
await transmission.removeTorrent(key, false);
|
83
|
-
});
|
84
|
-
it('should verify torrent', async () => {
|
85
|
-
const transmission = new Transmission({ baseUrl });
|
86
|
-
const key = await setupTorrent(transmission);
|
87
|
-
await transmission.verifyTorrent(key);
|
88
|
-
});
|
89
|
-
it('should move in queue', async () => {
|
90
|
-
const transmission = new Transmission({ baseUrl });
|
91
|
-
const key = await setupTorrent(transmission);
|
92
|
-
await transmission.queueUp(key);
|
93
|
-
await transmission.queueDown(key);
|
94
|
-
await transmission.queueTop(key);
|
95
|
-
await transmission.queueBottom(key);
|
96
|
-
});
|
97
|
-
it('should report free space', async () => {
|
98
|
-
const transmission = new Transmission({ baseUrl });
|
99
|
-
const p = '/downloads';
|
100
|
-
const res = await transmission.freeSpace(p);
|
101
|
-
expect(res.result).toBe('success');
|
102
|
-
expect(res.arguments.path).toBe(p);
|
103
|
-
expect(typeof res.arguments['size-bytes']).toBe('number');
|
104
|
-
});
|
105
|
-
it('should add from url', async () => {
|
106
|
-
const transmission = new Transmission({ baseUrl });
|
107
|
-
const res = await transmission.addUrl('https://releases.ubuntu.com/20.10/ubuntu-20.10-desktop-amd64.iso.torrent');
|
108
|
-
expect(res.result).toBe('success');
|
109
|
-
});
|
110
|
-
it('should add torrent with normalized response', async () => {
|
111
|
-
const client = new Transmission({ baseUrl });
|
112
|
-
const torrent = await client.normalizedAddTorrent(fs.readFileSync(torrentFile), {
|
113
|
-
label: 'test',
|
114
|
-
});
|
115
|
-
expect(torrent.connectedPeers).toBe(0);
|
116
|
-
expect(torrent.connectedSeeds).toBe(0);
|
117
|
-
expect(torrent.downloadSpeed).toBe(0);
|
118
|
-
expect(torrent.eta).toBe(-1);
|
119
|
-
expect(torrent.isCompleted).toBe(false);
|
120
|
-
expect(torrent.label).toBe('test');
|
121
|
-
expect(torrent.name).toBe(torrentName);
|
122
|
-
expect(torrent.progress).toBeGreaterThanOrEqual(0);
|
123
|
-
expect(torrent.queuePosition).toBe(0);
|
124
|
-
// expect(torrent.ratio).toBe(0);
|
125
|
-
expect(torrent.savePath).toBe('/downloads');
|
126
|
-
expect(torrent.state).toBe(TorrentState.checking);
|
127
|
-
expect(torrent.stateMessage).toBe('');
|
128
|
-
expect(torrent.totalDownloaded).toBe(0);
|
129
|
-
expect(torrent.totalPeers).toBe(0);
|
130
|
-
expect(torrent.totalSeeds).toBe(0);
|
131
|
-
expect(torrent.totalSelected).toBe(1953349632);
|
132
|
-
// expect(torrent.totalSize).toBe(undefined);
|
133
|
-
expect(torrent.totalUploaded).toBe(0);
|
134
|
-
expect(torrent.uploadSpeed).toBe(0);
|
135
|
-
});
|
136
|
-
});
|
package/dist/vitest.config.d.ts
DELETED