code: def _finish_frag_download(ffd_self, ctx):
      '''
      We monkey-patch this youtube-dl internal method `_finish_frag_download()`
      because it gets called after downloading the last segment of a segmented
      video, which is a good time to upload the stitched-up video that youtube-dl
      creates for us to warcprox. We have it call a thread-local callback
      since different threads may be youtube-dl'ing at the same time.
      '''
      result = _orig__finish_frag_download(ffd_self, ctx)
      if hasattr(thread_local, 'finish_frag_download_callback'):
          thread_local.finish_frag_download_callback(ffd_self, ctx)
      return resulf _finish_frag_download(ffd_self, ctx):
      '''
      We monkey-patch this youtube-dl internal method `_finish_frag_download()`
      because it gets called after downloading the last segment of a segmented
      video, which is a good time to upload the stitched-up video that youtube-dl
      creates for us to warcprox. We have it call a thread-local callback
      since different threads may be youtube-dl'ing at the same time.
      '''
      result = _orig__finish_frag_download(ffd_self, ctx)
      if hasattr(thread_local, 'finish_frag_download_callback'):
          thread_local.finish_frag_download_callback(ffd_self, ctx)
      return result
docs: We monkey-patch this youtube-dl internal method `_finish_frag_download()`
      because it gets called after downloading the last segment of a segmented
      video, which is a good time to upload the stitched-up video that youtube-dl
      creates for us to warcprox. We have it call a thread-local callback
      since different threads may be youtube-dl'ing at the same time.