title: How to get filename of file downloaded with Youtube-dl
body: <p>I am using youtube-dl with a flask app to download a file and return the file. When I download the filename is changed slightly from the video title. Looking through the source code I thought I found it with the function <code>encodeFilename</code> in <code>utils.py</code>. However, this is still not a match and I can't return the file.</p>
  <p>How could I get the filename, or alternatively change the filename that is downloaded?</p>
  <p>This is my code at the moment:</p>
  <pre><code>def preferredencoding():
      try:
          pref = locale.getpreferredencoding()
          'TEST'.encode(pref)
      except Exception:
          pref = 'UTF-8'
  
      return pref
  
  
  def get_subprocess_encoding():
      if sys.platform == 'win32' and sys.getwindowsversion()[0] &gt;= 5:
          encoding = preferredencoding()
      else:
          encoding = sys.getfilesystemencoding()
      if encoding is None:
          encoding = 'utf-8'
      return encoding
  
  
  @app.route('/api/v1/videos', methods=['GET'])
  def api_id():
      if 'link' in request.args:
          link = request.args['link']
          print(&quot;Getting YouTube video&quot;)
          try:
              title = youtube_dl.YoutubeDL().extract_info(link, download=False)[&quot;title&quot;]
              print(title.encode(get_subprocess_encoding(), 'ignore'))
              print(title)
              code=link.split('v=')[1]
              youtube_dl.YoutubeDL().download([link])
              return send_from_directory(r'C:\Users\User123', title+'-'+code+'.mp4')
          except:
              return &quot;&lt;h1&gt;Error&lt;/h1&gt;
  </code></pre>