diff options
author | Chocobozzz <me@florianbigard.com> | 2022-12-29 10:24:06 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-12-29 10:24:06 +0100 |
commit | 0daaab0c0eb560793534856add6c737782431e7e (patch) | |
tree | 8da47957e5d40725d95ae567c0c959846cfd1a70 | |
parent | 4fe7cde283b9b88a2917824e34e23356849b33b8 (diff) | |
download | PeerTube-0daaab0c0eb560793534856add6c737782431e7e.tar.gz PeerTube-0daaab0c0eb560793534856add6c737782431e7e.tar.zst PeerTube-0daaab0c0eb560793534856add6c737782431e7e.zip |
Try to fix github api rate limit
-rw-r--r-- | .github/workflows/test.yml | 1 | ||||
-rw-r--r-- | server/helpers/youtube-dl/youtube-dl-cli.ts | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65e1acec6..678b0674b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml | |||
@@ -48,6 +48,7 @@ jobs: | |||
48 | ENABLE_OBJECT_STORAGE_TESTS: true | 48 | ENABLE_OBJECT_STORAGE_TESTS: true |
49 | OBJECT_STORAGE_SCALEWAY_KEY_ID: ${{ secrets.OBJECT_STORAGE_SCALEWAY_KEY_ID }} | 49 | OBJECT_STORAGE_SCALEWAY_KEY_ID: ${{ secrets.OBJECT_STORAGE_SCALEWAY_KEY_ID }} |
50 | OBJECT_STORAGE_SCALEWAY_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_SCALEWAY_ACCESS_KEY }} | 50 | OBJECT_STORAGE_SCALEWAY_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_SCALEWAY_ACCESS_KEY }} |
51 | YOUTUBE_DL_DOWNLOAD_BEARER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
51 | 52 | ||
52 | steps: | 53 | steps: |
53 | - uses: actions/checkout@v3 | 54 | - uses: actions/checkout@v3 |
diff --git a/server/helpers/youtube-dl/youtube-dl-cli.ts b/server/helpers/youtube-dl/youtube-dl-cli.ts index a2f630953..765038cea 100644 --- a/server/helpers/youtube-dl/youtube-dl-cli.ts +++ b/server/helpers/youtube-dl/youtube-dl-cli.ts | |||
@@ -6,6 +6,7 @@ import { VideoResolution } from '@shared/models' | |||
6 | import { logger, loggerTagsFactory } from '../logger' | 6 | import { logger, loggerTagsFactory } from '../logger' |
7 | import { getProxy, isProxyEnabled } from '../proxy' | 7 | import { getProxy, isProxyEnabled } from '../proxy' |
8 | import { isBinaryResponse, peertubeGot } from '../requests' | 8 | import { isBinaryResponse, peertubeGot } from '../requests' |
9 | import { OptionsOfBufferResponseBody } from 'got/dist/source' | ||
9 | 10 | ||
10 | const lTags = loggerTagsFactory('youtube-dl') | 11 | const lTags = loggerTagsFactory('youtube-dl') |
11 | 12 | ||
@@ -28,7 +29,16 @@ export class YoutubeDLCLI { | |||
28 | 29 | ||
29 | logger.info('Updating youtubeDL binary from %s.', url, lTags()) | 30 | logger.info('Updating youtubeDL binary from %s.', url, lTags()) |
30 | 31 | ||
31 | const gotOptions = { context: { bodyKBLimit: 20_000 }, responseType: 'buffer' as 'buffer' } | 32 | const gotOptions: OptionsOfBufferResponseBody = { |
33 | context: { bodyKBLimit: 20_000 }, | ||
34 | responseType: 'buffer' as 'buffer' | ||
35 | } | ||
36 | |||
37 | if (process.env.YOUTUBE_DL_DOWNLOAD_BEARER_TOKEN) { | ||
38 | gotOptions.headers = { | ||
39 | authorization: 'Bearer ' + process.env.YOUTUBE_DL_DOWNLOAD_BEARER_TOKEN | ||
40 | } | ||
41 | } | ||
32 | 42 | ||
33 | try { | 43 | try { |
34 | let gotResult = await peertubeGot(url, gotOptions) | 44 | let gotResult = await peertubeGot(url, gotOptions) |