TypeError [ERR_INVALID_CHAR]:标头内容[“ Content-disposition”]中的字符无效

时间:2020-10-05 15:40:19

标签: javascript node.js

我尝试下载此视频https://www.youtube.com/watch?v=gdZLi9oWNZg,但出现错误 TypeError [ERR_INVALID_CHAR]:标头内容[“ Content-disposition”]中的无效字符

视频标题中包含这样的字符(방탄소년단),这就是视频发生此错误 我的代码

         ytdl('https://www.youtube.com/watch?v=MBdVXkSdhwU', {
          format: 'mp4'
          }).pipe(res);
      ytdl.getInfo('https://www.youtube.com/watch?v=MBdVXkSdhwU').then(info => {
            console.log('title:', info.videoDetails.title);
            console.log('rating:', info.player_response.videoDetails.averageRating);
            console.log('uploaded by:', info.videoDetails.author.name);
            const json = JSON.stringify(info, null, 2)
            res.header('Content-Disposition', `attachment; filename=${info.videoDetails.title}
  });
  });

0 个答案:

没有答案