1 import * as program from 'commander'
2 import { join } from 'path'
3 import { execSync } from 'child_process'
8 .option('-g, --gui <player>', 'player type', /^(airplay|stdout|chromecast|mpv|vlc|mplayer|xbmc)$/i, 'vlc')
9 .option('-r, --resolution <res>', 'video resolution', '480')
10 .on('--help', function () {
11 console.log(' Available Players:')
14 console.log(' - mplayer')
16 console.log(' - stdout')
17 console.log(' - xbmc')
18 console.log(' - airplay')
19 console.log(' - chromecast')
22 console.log(' Examples:')
24 console.log(' $ peertube watch -g mpv https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
25 console.log(' $ peertube watch --gui stdout https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
26 console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
29 .action((url, cmd) => {
38 async function run (url: string, program: any) {
40 console.error('<url> positional argument is required.')
44 const cmd = 'node ' + join(__dirname, 'node_modules', 'webtorrent-hybrid', 'bin', 'cmd.js')
45 const args = ` --${program.gui} ` +
46 url.replace('videos/watch', 'download/torrents') +
47 `-${program.resolution}.torrent`