aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/peertube-watch.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools/peertube-watch.ts')
-rw-r--r--server/tools/peertube-watch.ts42
1 files changed, 0 insertions, 42 deletions
diff --git a/server/tools/peertube-watch.ts b/server/tools/peertube-watch.ts
deleted file mode 100644
index 892c9e7a6..000000000
--- a/server/tools/peertube-watch.ts
+++ /dev/null
@@ -1,42 +0,0 @@
1import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths()
3
4import { program, Option, OptionValues } from 'commander'
5import { join } from 'path'
6import { execSync } from 'child_process'
7
8program
9 .name('watch')
10 .arguments('<url>')
11 .addOption(
12 new Option('-g, --gui <player>', 'player type')
13 .default('vlc')
14 .choices([ 'airplay', 'stdout', 'chromecast', 'mpv', 'vlc', 'mplayer', 'xbmc' ])
15 )
16 .option('-r, --resolution <res>', 'video resolution', '480')
17 .addHelpText('after', '\n\n Examples:\n\n' +
18 ' $ peertube watch -g mpv https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10\n' +
19 ' $ peertube watch --gui stdout https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10\n' +
20 ' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10\n'
21 )
22 .action((url, options) => run(url, options))
23 .parse(process.argv)
24
25function run (url: string, options: OptionValues) {
26 if (!url) {
27 console.error('<url> positional argument is required.')
28 process.exit(-1)
29 }
30
31 const cmd = 'node ' + join(__dirname, 'node_modules', 'webtorrent-hybrid', 'bin', 'cmd.js')
32 const args = ` --${options.gui} ` +
33 url.replace(/(\/videos\/watch\/)|\/w\//, '/download/torrents/') +
34 `-${options.resolution}.torrent`
35
36 try {
37 execSync(cmd + args)
38 } catch (err) {
39 console.error('Cannto exec command.', err)
40 process.exit(-1)
41 }
42}