1+ import path from 'path'
12import fs from 'fs'
23import _ from 'lodash'
34import nodeCleanup from 'node-cleanup'
@@ -12,6 +13,8 @@ import { ContentProcessingClient, ContentProcessingService } from '../services/s
1213import { YoutubePollingService } from '../services/syncProcessing/YoutubePollingService'
1314import { IYoutubeApi , YoutubeApi } from '../services/youtube/api'
1415import { Config , DisplaySafeConfig } from '../types'
16+ import { Socks5ProxyService } from '../services/proxy/Socks5ProxyService'
17+ import { THUMBNAILS_SUBDIR } from '../services/syncProcessing/ContentDownloadService'
1518
1619export class Service {
1720 private config : Config
@@ -25,15 +28,17 @@ export class Service {
2528 private youtubePollingService : YoutubePollingService
2629 private contentProcessingService : ContentProcessingService
2730 private contentProcessingClient : ContentProcessingClient
31+ private socks5ProxyService ?: Socks5ProxyService
2832 private isStopping = false
2933
3034 constructor ( config : Config ) {
3135 this . config = config
3236 this . logging = LoggingService . withAppConfig ( config . logs )
3337 this . logger = this . logging . createLogger ( 'Server' )
38+ this . socks5ProxyService = config . proxy ? new Socks5ProxyService ( config . proxy , this . logging ) : undefined
3439 this . queryNodeApi = new QueryNodeApi ( config . endpoints . queryNode , this . logging )
3540 this . dynamodbService = new DynamodbService ( this . config . aws )
36- this . youtubeApi = YoutubeApi . create ( this . config , this . dynamodbService . repo . stats , this . logging )
41+ this . youtubeApi = YoutubeApi . create ( this . config , this . dynamodbService . repo . stats , this . logging , this . socks5ProxyService )
3742 this . runtimeApi = new RuntimeApi ( config . endpoints . joystreamNodeWs , this . logging )
3843 this . joystreamClient = new JoystreamClient ( config , this . runtimeApi , this . queryNodeApi , this . logging )
3944 this . contentProcessingClient = new ContentProcessingClient ( { ...config . sync , ...config . endpoints } )
@@ -69,10 +74,15 @@ export class Service {
6974 private checkConfigDirectories ( ) : void {
7075 if ( this . config . sync . enable ) {
7176 this . checkConfigDir ( 'sync.downloadsDir' , this . config . sync . downloadsDir )
77+ const thumbsDir = path . join ( this . config . sync . downloadsDir , THUMBNAILS_SUBDIR )
78+ this . checkConfigDir ( 'thumbnails' , thumbsDir )
7279 }
7380 if ( this . config . logs ?. file ) {
7481 this . checkConfigDir ( 'logs.file.path' , this . config . logs . file . path )
7582 }
83+ if ( this . config . proxy ?. chain ) {
84+ this . checkConfigDir ( 'proxy.chain.configDir' , this . config . proxy . chain . configDir )
85+ }
7686 }
7787
7888 private async startSync ( ) : Promise < void > {
@@ -84,7 +94,8 @@ export class Service {
8494 this . youtubeApi ,
8595 this . runtimeApi ,
8696 this . joystreamClient ,
87- this . queryNodeApi
97+ this . queryNodeApi ,
98+ this . socks5ProxyService
8899 )
89100
90101 const {
0 commit comments