Add ability to import just one video from youtube

pull/304/head
Chocobozzz 2018-02-19 11:12:58 +01:00
parent 1263fc4e6e
commit 35501c0fa7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 31 additions and 17 deletions

View File

@ -147,11 +147,11 @@ See the [docker guide](/support/doc/docker.md)
See the [production guide](/support/doc/production.md).
## Contributing
## Contributing/Test
See the [contributing
guide](/.github/CONTRIBUTING.md)
to see how to contribute to PeerTube. Spoiler alert: you don't need to be a
to see how to test or contribute to PeerTube. Spoiler alert: you don't need to be a
coder to help!
## API REST documentation
@ -161,6 +161,10 @@ For now only on Github:
* HTML version: [/support/doc/api/html/index.html](/support/doc/api/html/index.html)
* Swagger/OpenAPI schema: [/support/doc/api/openapi.yaml](/support/doc/api/openapi.yaml)
## Tools
* [YouTube import](/support/doc/import-youtube.md)
## Architecture
See [ARCHITECTURE.md](/ARCHITECTURE.md) for a more detailed explanation.

View File

@ -52,10 +52,16 @@ async function run () {
youtubeDL.getInfo(program['youtubeUrl'], options, processOptions, async (err, info) => {
if (err) throw err
// Normalize utf8 fields
info = info.map(i => normalizeObject(i))
let infoArray: any[]
const videos = info.map(i => {
// Normalize utf8 fields
if (Array.isArray(info) === true) {
infoArray = info.map(i => normalizeObject(i))
} else {
infoArray = [ normalizeObject(info) ]
}
const videos = infoArray.map(i => {
return { url: 'https://www.youtube.com/watch?v=' + i.id, name: i.title }
})

View File

@ -10,7 +10,7 @@
```
$ sudo apt update
$ sudo apt install nginx ffmpeg postgresql openssl g++ make redis-server git
$ sudo apt install nginx ffmpeg postgresql openssl g++ make redis-server
```
## Arch Linux
@ -36,7 +36,7 @@ $ sudo pacman -S nodejs yarn ffmpeg postgresql openssl redis
$ sudo yum update
$ sudo yum install epel-release
$ sudo yum update
$ sudo yum install nginx postgresql postgresql-server openssl gcc make redis git
$ sudo yum install nginx postgresql postgresql-server openssl gcc make redis
```
## Other distributions

View File

@ -11,19 +11,20 @@ Be sure you own the videos or have the author's authorization to do so.
## Prerequisites
You need at least 512MB RAM to run the script.
Importation can be launched directly from a peertube server (in this case you already have dependencies installed :+1:) or from a separate server, even a dekstop PC.
Importation can be launched directly from a PeerTube server (in this case you already have dependencies installed :+1:) or from a separate server, even a dekstop PC.
### Dependencies
If you do not run the script from a Peertube server, you need to follow the steps of the [dependencies guide](dependencies.md).
* [PeerTube dependencies](dependencies.md)
* git
### Installation
Clone the Peertube repo to get the latest version inside your server:
Clone the PeerTube repo to get the latest version:
```
git clone https://github.com/Chocobozzz/PeerTube.git
CLONE="$(pwd)/Peertube"
CLONE="$(pwd)/PeerTube"
```
Run ``yarn install``
@ -48,10 +49,13 @@ cd ${CLONE}
node dist/server/tools/import-youtube.js -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD" -y "YOUTUBE_URL"
```
- PEERTUBE_URL : the full URL of your peertube server where you want to import, eg: https://peertube.cpy.re/
- PEERTUBE_USER : your peertube account where videos will be uploaded
- PEERTUBE_PASSWORD : password of your peertube account
- YOUTUBE_URL : the youtube channel you want to import. Supports Youtube channel (eg https://www.youtube.com/channel/ChannelId) or Youtube user (eg: https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName)
* PEERTUBE_URL : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re/
* PEERTUBE_USER : your PeerTube account where videos will be uploaded
* PEERTUBE_PASSWORD : password of your PeerTube account
* YOUTUBE_URL : the youtube video/user/channel/playlist you want to import. Examples:
* Channel: https://www.youtube.com/channel/ChannelId
* User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName
* Video https://www.youtube.com/watch?v=blabla
The script will get all public videos from Youtube, download them, then upload to Peertube.
Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection, ... without problem.
The script will get all public videos from Youtube, download them and upload to PeerTube.
Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection...