# Buggy code
def real_download(self, filename, info_dict):
    self.report_destination(filename)
    tmpfilename = self.temp_name(filename)

    try:
        retval = self._call_downloader(tmpfilename, info_dict)
    except KeyboardInterrupt:
        if not info_dict.get("is_live"):
            raise
        # Live stream downloading cancellation should be considered as
        # correct and expected termination thus all postprocessing
        # should take place
        retval = 0
        self.to_screen("[%s] Interrupted by user" % self.get_basename())

    if retval == 0:
        fsize = os.path.getsize(encodeFilename(tmpfilename))
        self.to_screen("\r[%s] Downloaded %s bytes" % (self.get_basename(), fsize))
        self.try_rename(tmpfilename, filename)
        self._hook_progress(
            {
                "downloaded_bytes": fsize,
                "total_bytes": fsize,
                "filename": filename,
                "status": "finished",
            }
        )
        return True
    else:
        self.to_stderr("\n")
        self.report_error("%s exited with code %d" % (self.get_basename(), retval))
        return False


# Traceback (UnavailableVideoError)
pb3:Downloads jhawk$ youtube-dl --get-filename 'http://www.cbs.com/shows/the-late-show-with-stephen-colbert/video/Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ/the-late-show-9-29-2016-morgan-freeman-judith-light-jimmy-eat-world-/'
The Late Show - 9_29_2016 (Morgan Freeman, Judith Light, Jimmy Eat World)-Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ.mp4
pb3:Downloads jhawk$ youtube-dl -v -o - 'http://www.cbs.com/shows/the-late-show-with-stephen-colbert/video/Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ/the-late-show-9-29-2016-morgan-freeman-judith-light-jimmy-eat-world-/' | tee 'The Late Show - 9_29_2016 (Morgan Freeman, Judith Light, Jimmy Eat World)-Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ.mp4' | /Applications/VLC.app/Contents/MacOS/VLC -
VLC media player 2.2.4 Weatherwax (revision 2.2.4-3-g2fc51dd)
[0000000100219ee8] core libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'-o', u'-', u'http://www.cbs.com/shows/the-late-show-with-stephen-colbert/video/Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ/the-late-show-9-29-2016-morgan-freeman-judith-light-jimmy-eat-world-/']
[debug] Encodings: locale UTF-8, fs utf-8, out None, pref UTF-8
[debug] youtube-dl version 2016.09.27
[debug] Python version 2.7.10 - Darwin-14.5.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 3.1.3, ffprobe 3.1.3, rtmpdump 2.4
[debug] Proxy map: {}
[CBS] Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ: Downloading XML
[CBS] Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ: Downloading StreamPack SMIL data
[CBS] Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ: Downloading m3u8 information
[CBS] Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ: Downloading RTMP SMIL data
[CBS] Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ: Downloading OnceURL SMIL data
[CBS] Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ: Checking video URL
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: Downloading m3u8 information
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: Checking http-1200 video format URL
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: http-1200 video format URL is invalid, skipping
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: Checking http-4400 video format URL
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: http-4400 video format URL is invalid, skipping
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: Checking http-2000 video format URL
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: http-2000 video format URL is invalid, skipping
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: Checking http-764 video format URL
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: http-764 video format URL is invalid, skipping
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: Checking http-512 video format URL
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: http-512 video format URL is invalid, skipping
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: Checking http-264 video format URL
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: http-264 video format URL is invalid, skipping
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: Checking http-60 video format URL
[CBS] b7c06387-13d6-4f72-b6f6-b8719eeb8a9f: http-60 video format URL is invalid, skipping
[CBS] Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ: Downloading JSON metadata
[debug] Invoking downloader on u'http://once-aws-us-east-1-lb.unicornmedia.com/now/media/playlist/bb0b18ba-64f5-4b1b-a29f-0ac252f06b68/77a785f3-5188-4806-b788-0893a61634ed/468fb310-a585-11e4-bfdb-005056837bc7/b7c06387-13d6-4f72-b6f6-b8719eeb8a9f/0/0/2483/content.m3u8?visitguid=f266b2cd-c23d-4e80-9d95-5974e1bd323c&amp;segmentlength=10&amp;adsegmentlength=0&amp;protocolversion=3'
[download] Destination: -
[debug] ffmpeg command line: ffmpeg -y -headers 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)
' -i 'http://once-aws-us-east-1-lb.unicornmedia.com/now/media/playlist/bb0b18ba-64f5-4b1b-a29f-0ac252f06b68/77a785f3-5188-4806-b788-0893a61634ed/468fb310-a585-11e4-bfdb-005056837bc7/b7c06387-13d6-4f72-b6f6-b8719eeb8a9f/0/0/2483/content.m3u8?visitguid=f266b2cd-c23d-4e80-9d95-5974e1bd323c&amp;segmentlength=10&amp;adsegmentlength=0&amp;protocolversion=3' -c copy -f mpegts -
ffmpeg version 3.1.3 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.1.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-openssl --disable-lzma --enable-nonfree --enable-vda
libavutil      55. 28.100 / 55. 28.100
libavcodec     57. 48.101 / 57. 48.101
libavformat    57. 41.100 / 57. 41.100
libavdevice    57.  0.101 / 57.  0.101
libavfilter     6. 47.100 /  6. 47.100
libavresample   3.  0.  0 /  3.  0.  0
libswscale      4.  1.100 /  4.  1.100
libswresample   2.  1.100 /  2.  1.100
libpostproc    54.  0.100 / 54.  0.100
Input #0, hls,applehttp, from 'http://once-aws-us-east-1-lb.unicornmedia.com/now/media/playlist/bb0b18ba-64f5-4b1b-a29f-0ac252f06b68/77a785f3-5188-4806-b788-0893a61634ed/468fb310-a585-11e4-bfdb-005056837bc7/b7c06387-13d6-4f72-b6f6-b8719eeb8a9f/0/0/2483/content.m3u8?visitguid=f266b2cd-c23d-4e80-9d95-5974e1bd323c&amp;segmentlength=10&amp;adsegmentlength=0&amp;protocolversion=3':
Duration: 00:41:22.51, start: 1.466733, bitrate: 0 kb/s
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 263 kb/s
[mpegts @ 0x7faf5c048200] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'pipe:':
Metadata:
encoder         : Lavf57.41.100
Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, 263 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[00000001077d4598] ts demux: MPEG-4 descriptor not found for pid 0x101 type 0xf
[00000001008df0b8] packetizer_mpeg4audio packetizer: AAC channels: 2 samplerate: 48000
shader program 1: WARNING: Output of vertex shader 'TexCoord1' not read by fragment shader
WARNING: Output of vertex shader 'TexCoord2' not read by fragment shader

[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 300 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[h264 @ 0x101886800] Missing reference picture, default is 0
[h264 @ 0x101886800] Missing reference picture, default is 0
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1159 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[0000000102876eb8] clock decoder error: Timestamp conversion failed (delay 1159346, buffering 100000, bound 3000000)
[0000000102876eb8] core decoder error: Could not convert timestamp 2175695376599
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1235 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 04718.2kbits/s speed=0.963x
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1322 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1347 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1418 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1504 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[h264 @ 0x101886800] Missing reference picture, default is 0
[h264 @ 0x101886800] decode_slice_header error
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1616 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1667 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[h264 @ 0x101886800] Missing reference picture, default is 0
[h264 @ 0x101886800] decode_slice_header error
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1884 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[h264 @ 0x101886800] Missing reference picture, default is 0
[h264 @ 0x101886800] decode_slice_header error
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 1950 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 2530 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[0000000102876eb8] clock decoder error: Timestamp conversion failed (delay 2530271, buffering 100000, bound 3000000)
[0000000102876eb8] core decoder error: Could not convert timestamp 2177570154622
[0000000102876eb8] clock decoder error: Timestamp conversion failed (delay 2530271, buffering 100000, bound 3000000)
[0000000102876eb8] core decoder error: Could not convert timestamp 2177668052247
[00000001077c27c8] core input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 3252 ms)
[00000001077c27c8] core input error: ES_OUT_RESET_PCR called
[00000001018b50b8] core decoder error: Could not convert timestamp 0
[0000000102876eb8] clock decoder error: Timestamp conversion failed (delay 3252327, buffering 100000, bound 3000000)
[0000000102876eb8] core decoder error: Could not convert timestamp 2178285079164
frame=74401 fps= 29 q=-1.0 Lsize= 1428642kB time=00:41:22.53 bitrate=4714.3kbits/s speed=0.954x
video:1236706kB audio:78588kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.617682%
ERROR: unable to download video
Traceback (most recent call last):
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1791, in download
url, force_generic_extractor=self.params.get('force_generic_extractor', False))
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 705, in extract_info
return self.process_ie_result(ie_result, download, extra_info)
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 751, in process_ie_result
return self.process_video_result(ie_result, download=download)
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1435, in process_video_result
self.process_info(new_info)
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1704, in process_info
raise UnavailableVideoError(err)
UnavailableVideoError: [Errno 2] No such file or directory: '-'



^Z
[1]+  Stopped                 youtube-dl -v -o - 'http://www.cbs.com/shows/the-late-show-with-stephen-colbert/video/Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ/the-late-show-9-29-2016-morgan-freeman-judith-light-jimmy-eat-world-/' | tee 'The Late Show - 9_29_2016 (Morgan Freeman, Judith Light, Jimmy Eat World)-Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ.mp4' | /Applications/VLC.app/Contents/MacOS/VLC -
pb3:Downloads jhawk$ jobs
[1]+  Stopped                 youtube-dl -v -o - 'http://www.cbs.com/shows/the-late-show-with-stephen-colbert/video/Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ/the-late-show-9-29-2016-morgan-freeman-judith-light-jimmy-eat-world-/' | tee 'The Late Show - 9_29_2016 (Morgan Freeman, Judith Light, Jimmy Eat World)-Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ.mp4' | /Applications/VLC.app/Contents/MacOS/VLC -
pb3:Downloads jhawk$ jobs -l
[1]+ 25017 Exit 1                  youtube-dl -v -o - 'http://www.cbs.com/shows/the-late-show-with-stephen-colbert/video/Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ/the-late-show-9-29-2016-morgan-freeman-judith-light-jimmy-eat-world-/'
25018 Done                    | tee 'The Late Show - 9_29_2016 (Morgan Freeman, Judith Light, Jimmy Eat World)-Kj139uP5fQfkmaoQ4tMW2BSq7vPfhmnJ.mp4'
25019 Suspended: 18           | /Applications/VLC.app/Contents/MacOS/VLC -
pb3:Downloads jhawk$

# Fixed code
def real_download(self, filename, info_dict):
    self.report_destination(filename)
    tmpfilename = self.temp_name(filename)

    try:
        retval = self._call_downloader(tmpfilename, info_dict)
    except KeyboardInterrupt:
        if not info_dict.get("is_live"):
            raise
        # Live stream downloading cancellation should be considered as
        # correct and expected termination thus all postprocessing
        # should take place
        retval = 0
        self.to_screen("[%s] Interrupted by user" % self.get_basename())

    if retval == 0:
        if filename == "-":
            self._hook_progress(
                {
                    "filename": filename,
                    "status": "finished",
                }
            )
        else:
            fsize = os.path.getsize(encodeFilename(tmpfilename))
            self.to_screen("\r[%s] Downloaded %s bytes" % (self.get_basename(), fsize))
            self.try_rename(tmpfilename, filename)
            self._hook_progress(
                {
                    "downloaded_bytes": fsize,
                    "total_bytes": fsize,
                    "filename": filename,
                    "status": "finished",
                }
            )
        return True
    else:
        self.to_stderr("\n")
        self.report_error("%s exited with code %d" % (self.get_basename(), retval))
        return False