Remove summon install
This commit is contained in:
parent
7e9d3f259d
commit
46b2cec73c
5 changed files with 1205 additions and 2159 deletions
|
@ -13,4 +13,4 @@ rm -rf ./dist/server/tools/
|
||||||
|
|
||||||
npm run tsc -- --build ./server/tools/tsconfig.json
|
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"
|
||||||
|
|
|
@ -17,6 +17,7 @@ if [ "$1" = "misc" ]; then
|
||||||
server/tests/helpers/index.ts
|
server/tests/helpers/index.ts
|
||||||
elif [ "$1" = "cli" ]; then
|
elif [ "$1" = "cli" ]; then
|
||||||
npm run build:server
|
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
|
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/cli/index.ts
|
||||||
elif [ "$1" = "api-1" ]; then
|
elif [ "$1" = "api-1" ]; then
|
||||||
npm run build:server
|
npm run build:server
|
||||||
|
@ -28,8 +29,7 @@ elif [ "$1" = "api-3" ]; then
|
||||||
npm run build:server
|
npm run build:server
|
||||||
sh ./server/tests/api/travis-3.sh 2
|
sh ./server/tests/api/travis-3.sh 2
|
||||||
elif [ "$1" = "api-4" ]; then
|
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
|
sh ./server/tests/api/travis-4.sh 2
|
||||||
elif [ "$1" = "lint" ]; then
|
elif [ "$1" = "lint" ]; then
|
||||||
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"
|
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"application-config": "^1.0.1",
|
"application-config": "^1.0.1",
|
||||||
"summon-install": "^0.4.6"
|
"webtorrent-hybrid": "^2.1.0"
|
||||||
},
|
},
|
||||||
"summon": {
|
"summon": {
|
||||||
"silent": true
|
"silent": true
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
import * as program from 'commander'
|
import * as program from 'commander'
|
||||||
import * as summon from 'summon-install'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
import { root } from '../helpers/core-utils'
|
|
||||||
|
|
||||||
let videoURL
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.name('watch')
|
.name('watch')
|
||||||
.arguments('<url>')
|
.arguments('<url>')
|
||||||
.option('-g, --gui <player>', 'player type', /^(airplay|stdout|chromecast|mpv|vlc|mplayer|ascii|xbmc)$/i, 'ascii')
|
.option('-g, --gui <player>', 'player type', /^(airplay|stdout|chromecast|mpv|vlc|mplayer|xbmc)$/i, 'vlc')
|
||||||
.option('-i, --invert', 'invert colors (ascii player only)', true)
|
.option('-r, --resolution <res>', 'video resolution', '480')
|
||||||
.option('-r, --resolution <res>', 'video resolution', /^(240|360|720|1080)$/i, '720')
|
|
||||||
.on('--help', function () {
|
.on('--help', function () {
|
||||||
console.log(' Available Players:')
|
console.log(' Available Players:')
|
||||||
console.log()
|
console.log()
|
||||||
console.log(' - ascii')
|
|
||||||
console.log(' - mpv')
|
console.log(' - mpv')
|
||||||
console.log(' - mplayer')
|
console.log(' - mplayer')
|
||||||
console.log(' - vlc')
|
console.log(' - vlc')
|
||||||
|
@ -24,7 +18,6 @@ program
|
||||||
console.log(' - airplay')
|
console.log(' - airplay')
|
||||||
console.log(' - chromecast')
|
console.log(' - chromecast')
|
||||||
console.log()
|
console.log()
|
||||||
console.log(' Note: \'ascii\' is the only option not using WebTorrent and not seeding back the video.')
|
|
||||||
console.log()
|
console.log()
|
||||||
console.log(' Examples:')
|
console.log(' Examples:')
|
||||||
console.log()
|
console.log()
|
||||||
|
@ -33,29 +26,25 @@ program
|
||||||
console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
|
console.log(' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10')
|
||||||
console.log()
|
console.log()
|
||||||
})
|
})
|
||||||
.action((url) => {
|
.action((url, cmd) => {
|
||||||
videoURL = url
|
run(url, cmd)
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err)
|
||||||
|
process.exit(-1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
|
|
||||||
if (!videoURL) {
|
async function run (url: string, program: any) {
|
||||||
|
if (!url) {
|
||||||
console.error('<url> positional argument is required.')
|
console.error('<url> positional argument is required.')
|
||||||
process.exit(-1)
|
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
Loading…
Reference in a new issue