Browse Source

updating README

Rigel Kent 1 year ago
parent
commit
a4a1afaa1f
Signed by: Rigel Kent <sendmemail@rigelk.eu> GPG Key ID: EA12971B0E438F36
1 changed files with 69 additions and 0 deletions
  1. 69
    0
      README.md

+ 69
- 0
README.md View File

@@ -16,4 +16,73 @@ end
16 16
 
17 17
 ## Usage
18 18
 
19
+It's straightforward to get going:
19 20
 
21
+```elixir
22
+iex(1)> Ambroisie.add 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'
23
+:ok
24
+iex(2)> Ambroisie.get 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'
25
+%{
26
+  status: "running",
27
+  torrents: [
28
+    %{
29
+      downloadSpeed: 0,
30
+      downloaded: 129241752,
31
+      infoHash: "6a9759bffd5c0af65319979fb7832189f4f3c35d",
32
+      magnetURI: "magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com",
33
+      numPeers: 2,
34
+      path: "/tmp/webtorrent/6a9759bffd5c0af65319979fb7832189f4f3c35d",
35
+      progress: 1,
36
+      received: 0,
37
+      status: "unknown",
38
+      timeRemaining: 0,
39
+      torrentFile: <<100, 56, 58, 97, 110, 110, 111, 117, 110, 99, 101, 50, 54,
40
+        58, 119, 115, 115, 58, 47, 47, 116, 114, 97, 99, 107, 101, 114, 46, 98,
41
+        116, 111, 114, 114, 101, 110, 116, ...>>,
42
+      uploadSpeed: 0,
43
+      uploaded: 0
44
+    }
45
+  ]
46
+}
47
+iex(3)> Ambroisie.remove 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'
48
+:ok
49
+iex(4)> Ambroisie.seed '/tmp/videos/sintel.mp4'
50
+:ok
51
+```
52
+
53
+For further examples, as well as the rest of the API, please generate the documentation via `mix docs`.
54
+
55
+## Persistence
56
+
57
+The WebTorrent subprocess can and will store its state on disk. At startup of an Ambroisie process, you get to choose wether to load this state, start anew or load a state of your own!
58
+
59
+```elixir
60
+iex(1)> AmbroisieApp.start(Ambroisie, %{restore: true})
61
+:ok
62
+```
63
+
64
+You can inject a state:
65
+
66
+```elixir
67
+iex(1)> AmbroisieApp.start(Ambroisie, %{restore: true, state: %{torrents: [
68
+  %{
69
+    magnetURI: 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d',
70
+    path: '/tmp/webtorrent/sintel' #optional
71
+  }
72
+]}})
73
+:ok
74
+```
75
+
76
+You can also give a path to the [application-config](https://www.npmjs.com/package/application-config) that the subprocess loads and stores to (see the package for its default location - but probably something like `~/.config/Ambroisie/WebTorrent/config.json`):
77
+
78
+```elixir
79
+iex(1)> AmbroisieApp.start(Ambroisie, %{restore: true, path: '/tmp/state.json'})
80
+:ok
81
+```
82
+
83
+You can query Ambroisie for the state of its client via:
84
+
85
+```elixir
86
+iex(1)> Ambroisie.getClientState
87
+%{torrents: []}
88
+```

Loading…
Cancel
Save