@@ -14,13 +14,12 @@ suspend fun main(args: Array<String>) {
1414 val javaScriptRunner = JavaScriptRunner ()
1515 val cryptoHelper = CryptoHelper (javaScriptRunner)
1616 val scraperService = ScraperService (cryptoHelper)
17+ val cliArguments = CliArguments (args)
1718
1819
19- val outputFileName = if (args.isNotEmpty() && args[0 ] == " -o" ) {
20- args.getOrNull(1 )
21- } else {
22- null
23- }
20+ val outputFileName = cliArguments.getOutputFileName(args)
21+ val headers = cliArguments.getHeaders()
22+
2423
2524 if (outputFileName != null && ! isValidPath(outputFileName)) {
2625 exitProcess(0 )
@@ -34,7 +33,7 @@ suspend fun main(args: Array<String>) {
3433 val videoID = scanner.nextLine().getVideoID()
3534
3635 val url = " https://abysscdn.com/?v=$videoID "
37- val videoSources = scraperService.getVideoMetaData(url)?.sources
36+ val videoSources = scraperService.getVideoMetaData(url, headers )?.sources
3837 ?.sortedBy { it?.label?.filter { char -> char.isDigit() }?.toInt() }
3938
4039 if (videoSources == null ) {
@@ -56,9 +55,9 @@ suspend fun main(args: Array<String>) {
5655
5756 val config = if (outputFileName == null ) {
5857 println (" \n Output file not specified. The video will be saved in the 'Downloads' folder as '${url.getVideoID()} _$resolution .mp4'." )
59- Config (url, resolution)
58+ Config (url, resolution, header = headers )
6059 } else {
61- Config (url, resolution, File (outputFileName))
60+ Config (url, resolution, File (outputFileName), header = headers )
6261 }
6362 println (" \n video with id $videoID and resolution $resolution being processed...." )
6463 scraperService.downloadVideo(config)
0 commit comments