Remove peertube watch and peertube repl

I don't have time to maintain these scripts that cause some install
issues/maintenance difficulties
pull/4461/head
Chocobozzz 2021-09-10 15:05:53 +02:00
parent e367da949b
commit 624e42fdf9
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
11 changed files with 7 additions and 2343 deletions

View File

@ -198,8 +198,6 @@
"eslint-plugin-standard": "^5.0.0",
"fast-xml-parser": "^3.19.0",
"maildev": "^1.0.0-rc3",
"marked": "^3.0.2",
"marked-man": "^0.7.0",
"mocha": "^9.0.0",
"nodemon": "^2.0.1",
"proxy": "^1.0.2",

View File

@ -1,5 +0,0 @@
#!/bin/sh
set -eu
node_modules/marked-man/bin/marked-man server/tools/README.md > dist/server/tools/peertube.8

View File

@ -1,82 +1,3 @@
peertube(8) -- companion CLI for PeerTube
=========================================
# PeerTube CLI
SYNOPSIS
--------
```
peertube [command] [options]
```
DESCRIPTION
-----------
`peertube` wraps various utilities around PeerTube that are used either on a running local, running remote, or cold local instance.
COMMANDS
--------
Unless otherwise specified, every command can be queried for its own help or manual by passing its name to the `help` command, or by using the `--help` option.
`auth [action]`: stores credentials for your accounts on remote instances, so that you don't need to pass them at every command
`upload|up`: upload a video to a remote instance
$ peertube upload \
-u "PEERTUBE_URL" \
-U "PEERTUBE_USER" \
--password "PEERTUBE_PASSWORD"
`import-videos|import`: import a video from a streaming platform to a remote instance
$ peertube import \
-u "PEERTUBE_URL" \
-U "PEERTUBE_USER" \
--password "PEERTUBE_PASSWORD" \
-t "TARGET_URL"
The target URL can be directly the video file, or any of the supported sites of youtube-dl. The video is downloaded locally and then uploaded. Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection…
`watch|w`: watch a video in the terminal ✩°。⋆
-g, --gui <player> player type (default: ascii)
-i, --invert invert colors (ascii player only)
-r, --resolution <res> video resolution (default: 720)
It provides support for different players:
- ascii (default ; plays in ascii art in your terminal!)
- mpv
- mplayer
- vlc
- stdout
- xbmc
- airplay
- chromecast
`repl`: interact with the application libraries and objects even when PeerTube is not running
Type .help to see the repl-only functions, or to see the available PeerTube core functions:
repl> lodash.keys(context)
`help [cmd]`: display help for [cmd]
EXAMPLES
--------
$ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"
$ peertube up <videoFile>
$ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10
SEE ALSO
--------
[PeerTube Tools Documentation](https://github.com/Chocobozzz/PeerTube/blob/develop/support/doc/tools.md)
[PeerTube Admin Documentation](https://docs.joinpeertube.org/lang/en/docs/)
REPORTING BUGS
--------------
See [PeerTube repository](https://github.com/Chocobozzz/PeerTube).
See https://docs.joinpeertube.org/maintain-tools?id=remote-tools

View File

@ -5,8 +5,7 @@
"dependencies": {
"application-config": "^2.0.0",
"cli-table3": "^0.6.0",
"netrc-parser": "^3.1.6",
"webtorrent-hybrid": "^4.0.3"
"netrc-parser": "^3.1.6"
},
"devDependencies": {}
}

View File

@ -1,83 +0,0 @@
import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths()
import * as repl from 'repl'
import * as path from 'path'
import * as _ from 'lodash'
import * as Sequelize from 'sequelize'
import * as YoutubeDL from 'youtube-dl'
import { initDatabaseModels, sequelizeTypescript } from '../initializers/database'
import * as cli from '../tools/cli'
import { logger } from '../helpers/logger'
import * as constants from '../initializers/constants'
import * as modelsUtils from '../models/utils'
import * as coreUtils from '../helpers/core-utils'
import * as ffmpegUtils from '../helpers/ffmpeg-utils'
import * as peertubeCryptoUtils from '../helpers/peertube-crypto'
import * as utils from '../helpers/utils'
import * as YoutubeDLUtils from '../helpers/youtube-dl'
const start = async () => {
await initDatabaseModels(true)
const versionCommitHash = await utils.getServerCommit()
const initContext = (replServer) => {
return (context) => {
const properties = {
context,
repl: replServer,
env: process.env,
lodash: _,
path,
cli,
logger,
constants,
Sequelize,
sequelizeTypescript,
modelsUtils,
models: sequelizeTypescript.models,
transaction: sequelizeTypescript.transaction,
query: sequelizeTypescript.query,
queryInterface: sequelizeTypescript.getQueryInterface(),
YoutubeDL,
coreUtils,
ffmpegUtils,
peertubeCryptoUtils,
utils,
YoutubeDLUtils
}
for (const prop in properties) {
Object.defineProperty(context, prop, {
configurable: false,
enumerable: true,
value: properties[prop]
})
}
}
}
const replServer = repl.start({
prompt: `PeerTube [${cli.version}] (${versionCommitHash})> `
})
initContext(replServer)(replServer.context)
replServer.on('reset', initContext(replServer))
replServer.on('exit', () => process.exit())
const resetCommand = {
help: 'Reset REPL',
action () {
this.write('.clear\n')
this.displayPrompt()
}
}
replServer.defineCommand('reset', resetCommand)
replServer.defineCommand('r', resetCommand)
}
start()
.catch((err) => {
console.error(err)
})

View File

@ -1,42 +0,0 @@
import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths()
import { program, Option, OptionValues } from 'commander'
import { join } from 'path'
import { execSync } from 'child_process'
program
.name('watch')
.arguments('<url>')
.addOption(
new Option('-g, --gui <player>', 'player type')
.default('vlc')
.choices([ 'airplay', 'stdout', 'chromecast', 'mpv', 'vlc', 'mplayer', 'xbmc' ])
)
.option('-r, --resolution <res>', 'video resolution', '480')
.addHelpText('after', '\n\n Examples:\n\n' +
' $ peertube watch -g mpv https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10\n' +
' $ peertube watch --gui stdout https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10\n' +
' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10\n'
)
.action((url, options) => run(url, options))
.parse(process.argv)
function run (url: string, options: OptionValues) {
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 = ` --${options.gui} ` +
url.replace(/(\/videos\/watch\/)|\/w\//, '/download/torrents/') +
`-${options.resolution}.torrent`
try {
execSync(cmd + args)
} catch (err) {
console.error('Cannto exec command.', err)
process.exit(-1)
}
}

View File

@ -1,7 +1,5 @@
#!/usr/bin/env node
/* eslint-disable no-useless-escape */
import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths()
@ -18,8 +16,6 @@ program
.command('upload', 'upload a video').alias('up')
.command('import-videos', 'import a video from a streaming platform').alias('import')
.command('get-access-token', 'get a peertube access token', { noHelp: true }).alias('token')
.command('watch', 'watch a video in the terminal ✩°。⋆').alias('w')
.command('repl', 'initiate a REPL to access internals')
.command('plugins [action]', 'manage instance plugins/themes').alias('p')
.command('redundancy [action]', 'manage instance redundancies').alias('r')
@ -72,8 +68,7 @@ getSettings()
.addHelpText('after', '\n\n State: ' + state + '\n\n' +
' Examples:\n\n' +
' $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD"\n' +
' $ peertube up <videoFile>\n' +
' $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10\n'
' $ peertube up <videoFile>\n'
)
.parse(process.argv)
})

View File

@ -1,102 +0,0 @@
import { program } from 'commander'
import { LiveVideoCreate, VideoPrivacy } from '@shared/models'
import {
createSingleServer,
killallServers,
sendRTMPStream,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel
} from '../../shared/extra-utils'
import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths()
type CommandType = 'live-mux' | 'live-transcoding'
registerTSPaths()
const command = program
.name('test-live')
.option('-t, --type <type>', 'live-muxing|live-transcoding')
.parse(process.argv)
run()
.catch(err => {
console.error(err)
process.exit(-1)
})
async function run () {
const commandType: CommandType = command['type']
if (!commandType) {
console.error('Miss command type')
process.exit(-1)
}
console.log('Starting server.')
const server = await createSingleServer(1, {}, { hideLogs: false, nodeArgs: [ '--inspect' ] })
const cleanup = async () => {
console.log('Killing server')
await killallServers([ server ])
}
process.on('exit', cleanup)
process.on('SIGINT', cleanup)
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
await buildConfig(server, commandType)
const attributes: LiveVideoCreate = {
name: 'live',
saveReplay: true,
channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
console.log('Creating live.')
const { uuid: liveVideoUUID } = await server.live.create({ fields: attributes })
const live = await server.live.get({ videoId: liveVideoUUID })
console.log('Sending RTMP stream.')
const ffmpegCommand = sendRTMPStream({ rtmpBaseUrl: live.rtmpUrl, streamKey: live.streamKey })
ffmpegCommand.on('error', err => {
console.error(err)
process.exit(-1)
})
ffmpegCommand.on('end', () => {
console.log('ffmpeg ended')
process.exit(0)
})
}
// ----------------------------------------------------------------------------
async function buildConfig (server: PeerTubeServer, commandType: CommandType) {
await server.config.updateCustomSubConfig({
newConfig: {
instance: {
customizations: {
javascript: '',
css: ''
}
},
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: commandType === 'live-transcoding'
}
}
}
})
}

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,6 @@
- [CLI wrapper](#cli-wrapper)
- [peertube-import-videos.js](#peertube-import-videosjs)
- [peertube-upload.js](#peertube-uploadjs)
- [peertube-watch.js](#peertube-watchjs)
- [peertube-plugins.js](#peertube-pluginsjs)
- [peertube-redundancy.js](#peertube-redundancyjs)
- [Server tools](#server-tools)
@ -22,11 +21,6 @@
- [update-host.js](#update-hostjs)
- [reset-password.js](#reset-passwordjs)
- [plugin install/uninstall](#plugin-installuninstall)
- [REPL (Read Eval Print Loop)](#repl-read-eval-print-loop)
- [.help](#help)
- [Lodash example](#lodash-example)
- [YoutubeDL example](#youtubedl-example)
- [Models examples](#models-examples)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@ -75,8 +69,6 @@ You can access it as `peertube` via an alias in your `.bashrc` like `alias peert
auth [action] register your accounts on remote instances to use them with other commands
upload|up upload a video
import-videos|import import a video from a streaming platform
watch|w watch a video in the terminal ✩°。⋆
repl initiate a REPL to access internals
plugins|p [action] manage instance plugins
redundancy|r [action] manage video redundancies
help [cmd] display help for [cmd]
@ -100,12 +92,6 @@ You can now use that account to upload videos without feeding the same parameter
$ peertube up <videoFile>
```
And now that your video is online, you can watch it from the confort of your terminal (use `peertube watch --help` to see the supported players):
```bash
$ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10
```
To list, install, uninstall dynamically plugins/themes of an instance:
```bash
@ -169,22 +155,6 @@ $ cd ${CLONE}
$ node dist/server/tools/peertube-upload.js --help
```
#### peertube-watch.js
You can use this script to play videos directly from the CLI.
It provides support for different players:
- ascii (default ; plays in ascii art in your terminal!)
- mpv
- mplayer
- vlc
- stdout
- xbmc
- airplay
- chromecast
#### peertube-plugins.js
Install/update/uninstall or list local or NPM PeerTube plugins:
@ -413,134 +383,3 @@ $ # Docker installation
$ cd /var/www/peertube-docker
$ docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
```
### REPL (Read Eval Print Loop)
If you want to interact with the application libraries and objects even when PeerTube is not running, there is a REPL for that.
usage: `node ./dist/server/tools/peertube-repl.js`
"The default evaluator will, by default, assign the result of the most recently evaluated expression to the special variable `_` (underscore). Explicitly setting `_` to a value will disable this behavior."
- type `.help` to list commands available in the repl, notice it starts with a dot
- type `.exit` to exit, note that you still have to press CTRL-C to actually exit, or press CTRL-C (3 times) without typing `.exit` to exit
- type `context` to list all available objects and libraries in the context, note: `Promise` is also available but it's not listed in the context, in case you need promises for something
- type `env` to see the loaded environment variables
- type `path` to access path library
- type `lodash` to access lodash library
- type `uuidv1` to access uuid/v1 library
- type `uuidv3` to access uuid/v3 library
- type `uuidv4` to access uuid/v4 library
- type `uuidv5` to access uuid/v5 library
- type `YoutubeDL` to access youtube-dl library
- type `cli` to access the cli helpers object
- type `logger` to access the logger; if you log to it, it will write to stdout and to the peertube.log file
- type `constants` to access the constants loaded by the server
- type `coreUtils` to access the core-utils helpers object
- type `ffmpegUtils` to access the ffmpeg-utils helpers object
- type `peertubeCryptoUtils` to access the peertube-crypto helpers object
- type `signupUtils` to access the signup helpers object
- type `utils` to access the utils helpers object
- type `YoutubeDLUtils` to access the youtube-dl helpers object
- type `sequelizeTypescript` to access sequelizeTypescript
- type `modelsUtils` to access the models/utils
- type `models` to access the shortcut to sequelizeTypescript.models
- type `transaction` to access the shortcut to sequelizeTypescript.transaction
- type `query` to access the shortcut to sequelizeTypescript.query
- type `queryInterface` to access the shortcut to sequelizeTypescript.queryInterface
#### .help
```
PeerTube [1.0.0] (b10eb595)> .help
.break Sometimes you get stuck, this gets you out
.clear Break, and also clear the local context
.editor Enter editor mode
.exit Exit the repl
.help Print this help message
.load Load JS from a file into the REPL session
.r Reset REPL
.reset Reset REPL
.save Save all evaluated commands in this REPL session to a file
PeerTube [1.0.0] (b10eb595)>
```
#### Lodash example
```
PeerTube [1.0.0] (b10eb595)> lodash.keys(context)
[ 'global',
'console',
'DTRACE_NET_SERVER_CONNECTION',
'DTRACE_NET_STREAM_END',
'DTRACE_HTTP_SERVER_REQUEST',
'DTRACE_HTTP_SERVER_RESPONSE',
'DTRACE_HTTP_CLIENT_REQUEST',
'DTRACE_HTTP_CLIENT_RESPONSE',
'process',
'Buffer',
'clearImmediate',
'clearInterval',
'clearTimeout',
'setImmediate',
'setInterval',
'setTimeout',
'XMLHttpRequest',
'compact2string',
'module',
'require',
'path',
'repl',
'context',
'env',
'lodash',
'uuidv1',
'uuidv3',
'uuidv4',
'uuidv5',
'cli',
'logger',
'constants',
'Sequelize',
'sequelizeTypescript',
'modelsUtils',
'models',
'transaction',
'query',
'queryInterface',
'YoutubeDL',
'coreUtils',
'ffmpegUtils',
'peertubeCryptoUtils',
'signupUtils',
'utils',
'YoutubeDLUtils' ]
PeerTube [1.0.0] (b10eb595)>
```
#### YoutubeDL example
```
YoutubeDL.getInfo('https://www.youtube.com/watch?v=I5ZN289jjDo', function(err, data) {console.log(err, data)})
```
#### Models examples
```
PeerTube [1.0.0] (b10eb595)> new models.ActorModel({id: 3}).getVideoChannel().then(function(data){console.log(data.dataValues.name)})
Promise {
_bitField: 0,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_promise0: undefined,
_receiver0: undefined }
PeerTube [1.0.0] (b10eb595)> Main root channel
PeerTube [1.0.0] (b10eb595)> let out; new models.UserModel({id: 1}).getAccount().then(function (data) {out = data.dataValues.id})
Promise {
_bitField: 0,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_promise0: undefined,
_receiver0: undefined }
PeerTube [1.0.0] (b10eb595)> out
2
PeerTube [1.0.0] (b10eb595)>
```

View File

@ -5967,16 +5967,6 @@ markdown-it@^12.0.4:
mdurl "^1.0.1"
uc.micro "^1.0.5"
marked-man@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/marked-man/-/marked-man-0.7.0.tgz#220ba01d275d16f1a98e4e7fc3c5eac0630c68e4"
integrity sha512-zxK5E4jbuARALc+fIUAanM2njVGnrd9YvKrqoDHUg2XwNLJijo39EzMIg59LecHBHsIHNtPqepqnJp4SmL/EVg==
marked@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/marked/-/marked-3.0.2.tgz#60ce97d6aec34dd882ab4bb4df82494666854e17"
integrity sha512-TMJQQ79Z0e3rJYazY0tIoMsFzteUGw9fB3FD+gzuIT3zLuG9L9ckIvUfF51apdJkcqc208jJN2KbtPbOvXtbjA==
math-interval-parser@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/math-interval-parser/-/math-interval-parser-2.0.1.tgz#e22cd6d15a0a7f4c03aec560db76513da615bed4"