diff options
Diffstat (limited to 'server/tools/peertube-watch.ts')
-rw-r--r-- | server/tools/peertube-watch.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/tools/peertube-watch.ts b/server/tools/peertube-watch.ts index 6d9cfa3b7..892c9e7a6 100644 --- a/server/tools/peertube-watch.ts +++ b/server/tools/peertube-watch.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../helpers/register-ts-paths' |
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import * as program from 'commander' | 4 | import { program, Option, OptionValues } from 'commander' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { execSync } from 'child_process' | 6 | import { execSync } from 'child_process' |
7 | 7 | ||
@@ -9,7 +9,7 @@ program | |||
9 | .name('watch') | 9 | .name('watch') |
10 | .arguments('<url>') | 10 | .arguments('<url>') |
11 | .addOption( | 11 | .addOption( |
12 | new program.Option('-g, --gui <player>', 'player type') | 12 | new Option('-g, --gui <player>', 'player type') |
13 | .default('vlc') | 13 | .default('vlc') |
14 | .choices([ 'airplay', 'stdout', 'chromecast', 'mpv', 'vlc', 'mplayer', 'xbmc' ]) | 14 | .choices([ 'airplay', 'stdout', 'chromecast', 'mpv', 'vlc', 'mplayer', 'xbmc' ]) |
15 | ) | 15 | ) |
@@ -22,7 +22,7 @@ program | |||
22 | .action((url, options) => run(url, options)) | 22 | .action((url, options) => run(url, options)) |
23 | .parse(process.argv) | 23 | .parse(process.argv) |
24 | 24 | ||
25 | function run (url: string, options: program.OptionValues) { | 25 | function run (url: string, options: OptionValues) { |
26 | if (!url) { | 26 | if (!url) { |
27 | console.error('<url> positional argument is required.') | 27 | console.error('<url> positional argument is required.') |
28 | process.exit(-1) | 28 | process.exit(-1) |
@@ -30,7 +30,7 @@ function run (url: string, options: program.OptionValues) { | |||
30 | 30 | ||
31 | const cmd = 'node ' + join(__dirname, 'node_modules', 'webtorrent-hybrid', 'bin', 'cmd.js') | 31 | const cmd = 'node ' + join(__dirname, 'node_modules', 'webtorrent-hybrid', 'bin', 'cmd.js') |
32 | const args = ` --${options.gui} ` + | 32 | const args = ` --${options.gui} ` + |
33 | url.replace('videos/watch', 'download/torrents') + | 33 | url.replace(/(\/videos\/watch\/)|\/w\//, '/download/torrents/') + |
34 | `-${options.resolution}.torrent` | 34 | `-${options.resolution}.torrent` |
35 | 35 | ||
36 | try { | 36 | try { |