Remove summon install

pull/1851/head
Chocobozzz 2019-05-24 17:42:35 +02:00 committed by Chocobozzz
parent 7e9d3f259d
commit 46b2cec73c
5 changed files with 1205 additions and 2159 deletions

View File

@ -13,4 +13,4 @@ rm -rf ./dist/server/tools/
npm run tsc -- --build ./server/tools/tsconfig.json
cp -r "./server/tools/node_modules" "./dist/server/tools"
mv "./server/tools/node_modules" "./dist/server/tools"

View File

@ -17,6 +17,7 @@ if [ "$1" = "misc" ]; then
server/tests/helpers/index.ts
elif [ "$1" = "cli" ]; then
npm run build:server
CC=gcc-4.9 CXX=g++-4.9 npm run setup:cli
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/cli/index.ts
elif [ "$1" = "api-1" ]; then
npm run build:server
@ -28,8 +29,7 @@ elif [ "$1" = "api-3" ]; then
npm run build:server
sh ./server/tests/api/travis-3.sh 2
elif [ "$1" = "api-4" ]; then
npm run setup:cli
npm run build-server
npm run build:server
sh ./server/tests/api/travis-4.sh 2
elif [ "$1" = "lint" ]; then
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"

View File

@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"application-config": "^1.0.1",
"summon-install": "^0.4.6"
"webtorrent-hybrid": "^2.1.0"
},
"summon": {
"silent": true

View File

@ -1,21 +1,15 @@
import * as program from 'commander'
import * as summon from 'summon-install'
import { join } from 'path'
import { execSync } from 'child_process'
import { root } from '../helpers/core-utils'
let videoURL
program
.name('watch')
.arguments('<url>')
.option('-g, --gui <player>', 'player type', /^(airplay|stdout|chromecast|mpv|vlc|mplayer|ascii|xbmc)$/i, 'ascii')
.option('-i, --invert', 'invert colors (ascii player only)', true)
.option('-r, --resolution <res>', 'video resolution', /^(240|360|720|1080)$/i, '720')
.option('-g, --gui <player>', 'player type', /^(airplay|stdout|chromecast|mpv|vlc|mplayer|xbmc)$/i, 'vlc')
.option('-r, --resolution <res>', 'video resolution', '480')
.on('--help', function () {
console.log(' Available Players:')
console.log()
console.log(' - ascii')
console.log(' - mpv')
console.log(' - mplayer')
console.log(' - vlc')
@ -24,7 +18,6 @@ program
console.log(' - airplay')
console.log(' - chromecast')
console.log()
console.log(' Note: \'ascii\' is the only option not using WebTorrent and not seeding back the video.')
console.log()
console.log(' Examples:')
console.log()
@ -33,29 +26,25 @@ program
console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
console.log()
})
.action((url) => {
videoURL = url
.action((url, cmd) => {
run(url, cmd)
.catch(err => {
console.error(err)
process.exit(-1)
})
})
.parse(process.argv)
if (!videoURL) {
console.error('<url> positional argument is required.')
process.exit(-1)
} else { program['url'] = videoURL }
handler(program)
function handler (argv) {
if (argv['gui'] === 'ascii') {
summon('peerterminal')
const peerterminal = summon('peerterminal')
peerterminal([ '--link', videoURL, '--invert', argv['invert'] ])
} else {
summon('webtorrent-hybrid')
const CMD = 'node ' + join(root(), 'node_modules', 'webtorrent-hybrid', 'bin', 'cmd.js')
const CMDargs = ` --${argv.gui} ` +
argv['url'].replace('videos/watch', 'download/torrents') +
`-${argv.resolution}.torrent`
execSync(CMD + CMDargs)
async function run (url: string, program: any) {
if (!url) {
console.error('<url> positional argument is required.')
process.exit(-1)
}
const cmd = 'node ' + join(__dirname, 'node_modules', 'webtorrent-hybrid', 'bin', 'cmd.js')
const args = ` --${program.gui} ` +
url.replace('videos/watch', 'download/torrents') +
`-${program.resolution}.torrent`
execSync(cmd + args)
}

File diff suppressed because it is too large Load Diff