# Buggy code
def _real_extract(self, url):
    url, data = unsmuggle_url(url)
    headers = std_headers
    if data is not None:
        headers = headers.copy()
        headers.update(data)
    if "Referer" not in headers:
        headers["Referer"] = url

    # Extract ID from URL
    mobj = re.match(self._VALID_URL, url)
    video_id = mobj.group("id")
    orig_url = url
    if mobj.group("pro") or mobj.group("player"):
        url = "http://player.vimeo.com/video/" + video_id

    password = self._downloader.params.get("videopassword", None)
    if password:
        headers["Cookie"] = "%s_password=%s" % (
            video_id,
            hashlib.md5(password.encode("utf-8")).hexdigest(),
        )

    # Retrieve video webpage to extract further information
    request = compat_urllib_request.Request(url, None, headers)
    try:
        webpage = self._download_webpage(request, video_id)
    except ExtractorError as ee:
        if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
            errmsg = ee.cause.read()
            if (
                b"Because of its privacy settings, this video cannot be played here"
                in errmsg
            ):
                raise ExtractorError(
                    "Cannot download embed-only video without embedding "
                    "URL. Please call youtube-dl with the URL of the page "
                    "that embeds this video.",
                    expected=True,
                )
        raise

    # Now we begin extracting as much information as we can from what we
    # retrieved. First we extract the information common to all extractors,
    # and latter we extract those that are Vimeo specific.
    self.report_extraction(video_id)

    # Extract the config JSON
    try:
        try:
            config_url = self._html_search_regex(
                r' data-config-url="(.+?)"', webpage, "config URL"
            )
            config_json = self._download_webpage(config_url, video_id)
            config = json.loads(config_json)
        except RegexNotFoundError:
            # For pro videos or player.vimeo.com urls
            # We try to find out to which variable is assigned the config dic
            m_variable_name = re.search("(\w)\.video\.id", webpage)
            if m_variable_name is not None:
                config_re = r"%s=({[^}].+?});" % re.escape(m_variable_name.group(1))
            else:
                config_re = [r" = {config:({.+?}),assets:", r"(?:[abc])=({.+?});"]
            config = self._search_regex(
                config_re, webpage, "info section", flags=re.DOTALL
            )
            config = json.loads(config)
    except Exception as e:
        if re.search(
            "The creator of this video has not given you permission to embed it on this domain.",
            webpage,
        ):
            raise ExtractorError(
                'The author has restricted the access to this video, try with the "--referer" option'
            )

        if re.search(r'<form[^>]+?id="pw_form"', webpage) is not None:
            if data and "_video_password_verified" in data:
                raise ExtractorError("video password verification failed!")
            self._verify_video_password(url, video_id, webpage)
            return self._real_extract(
                smuggle_url(url, {"_video_password_verified": "verified"})
            )
        else:
            raise ExtractorError("Unable to extract info section", cause=e)
    else:
        if config.get("view") == 4:
            config = self._verify_player_video_password(url, video_id)

    # Extract title
    video_title = config["video"]["title"]

    # Extract uploader and uploader_id
    video_uploader = config["video"]["owner"]["name"]
    video_uploader_id = (
        config["video"]["owner"]["url"].split("/")[-1]
        if config["video"]["owner"]["url"]
        else None
    )

    # Extract video thumbnail
    video_thumbnail = config["video"].get("thumbnail")
    if video_thumbnail is None:
        video_thumbs = config["video"].get("thumbs")
        if video_thumbs and isinstance(video_thumbs, dict):
            _, video_thumbnail = sorted(
                (int(width if width.isdigit() else 0), t_url)
                for (width, t_url) in video_thumbs.items()
            )[-1]

    # Extract video description

    video_description = self._html_search_regex(
        r'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>',
        webpage,
        "description",
        default=None,
    )
    if not video_description:
        video_description = self._html_search_meta("description", webpage, default=None)
    if not video_description and mobj.group("pro"):
        orig_webpage = self._download_webpage(
            orig_url, video_id, note="Downloading webpage for description", fatal=False
        )
        if orig_webpage:
            video_description = self._html_search_meta(
                "description", orig_webpage, default=None
            )
    if not video_description and not mobj.group("player"):
        self._downloader.report_warning("Cannot find video description")

    # Extract video duration
    video_duration = int_or_none(config["video"].get("duration"))

    # Extract upload date
    video_upload_date = None
    mobj = re.search(r'<time[^>]+datetime="([^"]+)"', webpage)
    if mobj is not None:
        video_upload_date = unified_strdate(mobj.group(1))

    try:
        view_count = int(self._search_regex(r"UserPlays:(\d+)", webpage, "view count"))
        like_count = int(self._search_regex(r"UserLikes:(\d+)", webpage, "like count"))
        comment_count = int(
            self._search_regex(r"UserComments:(\d+)", webpage, "comment count")
        )
    except RegexNotFoundError:
        # This info is only available in vimeo.com/{id} urls
        view_count = None
        like_count = None
        comment_count = None

    # Vimeo specific: extract request signature and timestamp
    sig = config["request"]["signature"]
    timestamp = config["request"]["timestamp"]

    # Vimeo specific: extract video codec and quality information
    # First consider quality, then codecs, then take everything
    codecs = [("vp6", "flv"), ("vp8", "flv"), ("h264", "mp4")]
    files = {"hd": [], "sd": [], "other": []}
    config_files = config["video"].get("files") or config["request"].get("files")
    for codec_name, codec_extension in codecs:
        for quality in config_files.get(codec_name, []):
            format_id = "-".join((codec_name, quality)).lower()
            key = quality if quality in files else "other"
            video_url = None
            if isinstance(config_files[codec_name], dict):
                file_info = config_files[codec_name][quality]
                video_url = file_info.get("url")
            else:
                file_info = {}
            if video_url is None:
                video_url = (
                    "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=%s&type=moogaloop_local&embed_location="
                    % (video_id, sig, timestamp, quality, codec_name.upper())
                )

            files[key].append(
                {
                    "ext": codec_extension,
                    "url": video_url,
                    "format_id": format_id,
                    "width": file_info.get("width"),
                    "height": file_info.get("height"),
                }
            )
    formats = []
    for key in ("other", "sd", "hd"):
        formats += files[key]
    if len(formats) == 0:
        raise ExtractorError("No known codec found")

    subtitles = {}
    text_tracks = config["request"].get("text_tracks")
    if text_tracks:
        for tt in text_tracks:
            subtitles[tt["lang"]] = [
                {
                    "ext": "vtt",
                    "url": "http://vimeo.com" + tt["url"],
                }
            ]

    return {
        "id": video_id,
        "uploader": video_uploader,
        "uploader_id": video_uploader_id,
        "upload_date": video_upload_date,
        "title": video_title,
        "thumbnail": video_thumbnail,
        "description": video_description,
        "duration": video_duration,
        "formats": formats,
        "webpage_url": url,
        "view_count": view_count,
        "like_count": like_count,
        "comment_count": comment_count,
        "subtitles": subtitles,
    }


# Traceback (RegexNotFoundError)
benjaminmikiten@benjaminmikiten ~/Dropbox/printing_vids $ youtube-dl --batch-file batch.txt --video-password dcp2015 -v
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['--batch-file', 'batch.txt', '--video-password', u'PRIVATE', '-v']
[debug] Batch file urls: [u'https://vimeo.com/118076403', u'https://vimeo.com/118062456', u'https://vimeo.com/118072708', u'https://vimeo.com/118079046', u'https://vimeo.com/118080059', u'https://vimeo.com/118081777', u'https://vimeo.com/118085658', u'https://vimeo.com/118073801', u'https://vimeo.com/118086390', u'https://vimeo.com/118092186', u'https://vimeo.com/118092776']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.02.19.3
[debug] Python version 2.7.6 - Darwin-14.1.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 2.5.4, ffprobe 2.5.4
[debug] Proxy map: {}
[vimeo] 118076403: Downloading webpage
[vimeo] 118076403: Extracting information
[vimeo] 118076403: Verifying the password
[vimeo] 118076403: Downloading webpage
[vimeo] 118076403: Extracting information
ERROR: video password verification failed!; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
File "/usr/local/bin/youtube-dl/youtube_dl/extractor/vimeo.py", line 264, in _real_extract
flags=re.DOTALL)
File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 531, in _search_regex
raise RegexNotFoundError('Unable to extract %s' % _name)
RegexNotFoundError: Unable to extract info section; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 643, in extract_info
ie_result = ie.extract(url)
File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 269, in extract
return self._real_extract(url)
File "/usr/local/bin/youtube-dl/youtube_dl/extractor/vimeo.py", line 275, in _real_extract
smuggle_url(url, {'_video_password_verified': 'verified'}))
File "/usr/local/bin/youtube-dl/youtube_dl/extractor/vimeo.py", line 272, in _real_extract
raise ExtractorError('video password verification failed!')
ExtractorError: video password verification failed!; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

# Fixed code
def _real_extract(self, url):
    url, data = unsmuggle_url(url)
    headers = std_headers
    if data is not None:
        headers = headers.copy()
        headers.update(data)
    if "Referer" not in headers:
        headers["Referer"] = url

    # Extract ID from URL
    mobj = re.match(self._VALID_URL, url)
    video_id = mobj.group("id")
    orig_url = url
    if mobj.group("pro") or mobj.group("player"):
        url = "http://player.vimeo.com/video/" + video_id

    # Retrieve video webpage to extract further information
    request = compat_urllib_request.Request(url, None, headers)
    try:
        webpage = self._download_webpage(request, video_id)
    except ExtractorError as ee:
        if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
            errmsg = ee.cause.read()
            if (
                b"Because of its privacy settings, this video cannot be played here"
                in errmsg
            ):
                raise ExtractorError(
                    "Cannot download embed-only video without embedding "
                    "URL. Please call youtube-dl with the URL of the page "
                    "that embeds this video.",
                    expected=True,
                )
        raise

    # Now we begin extracting as much information as we can from what we
    # retrieved. First we extract the information common to all extractors,
    # and latter we extract those that are Vimeo specific.
    self.report_extraction(video_id)

    # Extract the config JSON
    try:
        try:
            config_url = self._html_search_regex(
                r' data-config-url="(.+?)"', webpage, "config URL"
            )
            config_json = self._download_webpage(config_url, video_id)
            config = json.loads(config_json)
        except RegexNotFoundError:
            # For pro videos or player.vimeo.com urls
            # We try to find out to which variable is assigned the config dic
            m_variable_name = re.search("(\w)\.video\.id", webpage)
            if m_variable_name is not None:
                config_re = r"%s=({[^}].+?});" % re.escape(m_variable_name.group(1))
            else:
                config_re = [r" = {config:({.+?}),assets:", r"(?:[abc])=({.+?});"]
            config = self._search_regex(
                config_re, webpage, "info section", flags=re.DOTALL
            )
            config = json.loads(config)
    except Exception as e:
        if re.search(
            "The creator of this video has not given you permission to embed it on this domain.",
            webpage,
        ):
            raise ExtractorError(
                'The author has restricted the access to this video, try with the "--referer" option'
            )

        if re.search(r'<form[^>]+?id="pw_form"', webpage) is not None:
            if data and "_video_password_verified" in data:
                raise ExtractorError("video password verification failed!")
            self._verify_video_password(url, video_id, webpage)
            return self._real_extract(
                smuggle_url(url, {"_video_password_verified": "verified"})
            )
        else:
            raise ExtractorError("Unable to extract info section", cause=e)
    else:
        if config.get("view") == 4:
            config = self._verify_player_video_password(url, video_id)

    # Extract title
    video_title = config["video"]["title"]

    # Extract uploader and uploader_id
    video_uploader = config["video"]["owner"]["name"]
    video_uploader_id = (
        config["video"]["owner"]["url"].split("/")[-1]
        if config["video"]["owner"]["url"]
        else None
    )

    # Extract video thumbnail
    video_thumbnail = config["video"].get("thumbnail")
    if video_thumbnail is None:
        video_thumbs = config["video"].get("thumbs")
        if video_thumbs and isinstance(video_thumbs, dict):
            _, video_thumbnail = sorted(
                (int(width if width.isdigit() else 0), t_url)
                for (width, t_url) in video_thumbs.items()
            )[-1]

    # Extract video description

    video_description = self._html_search_regex(
        r'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>',
        webpage,
        "description",
        default=None,
    )
    if not video_description:
        video_description = self._html_search_meta("description", webpage, default=None)
    if not video_description and mobj.group("pro"):
        orig_webpage = self._download_webpage(
            orig_url, video_id, note="Downloading webpage for description", fatal=False
        )
        if orig_webpage:
            video_description = self._html_search_meta(
                "description", orig_webpage, default=None
            )
    if not video_description and not mobj.group("player"):
        self._downloader.report_warning("Cannot find video description")

    # Extract video duration
    video_duration = int_or_none(config["video"].get("duration"))

    # Extract upload date
    video_upload_date = None
    mobj = re.search(r'<time[^>]+datetime="([^"]+)"', webpage)
    if mobj is not None:
        video_upload_date = unified_strdate(mobj.group(1))

    try:
        view_count = int(self._search_regex(r"UserPlays:(\d+)", webpage, "view count"))
        like_count = int(self._search_regex(r"UserLikes:(\d+)", webpage, "like count"))
        comment_count = int(
            self._search_regex(r"UserComments:(\d+)", webpage, "comment count")
        )
    except RegexNotFoundError:
        # This info is only available in vimeo.com/{id} urls
        view_count = None
        like_count = None
        comment_count = None

    # Vimeo specific: extract request signature and timestamp
    sig = config["request"]["signature"]
    timestamp = config["request"]["timestamp"]

    # Vimeo specific: extract video codec and quality information
    # First consider quality, then codecs, then take everything
    codecs = [("vp6", "flv"), ("vp8", "flv"), ("h264", "mp4")]
    files = {"hd": [], "sd": [], "other": []}
    config_files = config["video"].get("files") or config["request"].get("files")
    for codec_name, codec_extension in codecs:
        for quality in config_files.get(codec_name, []):
            format_id = "-".join((codec_name, quality)).lower()
            key = quality if quality in files else "other"
            video_url = None
            if isinstance(config_files[codec_name], dict):
                file_info = config_files[codec_name][quality]
                video_url = file_info.get("url")
            else:
                file_info = {}
            if video_url is None:
                video_url = (
                    "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=%s&type=moogaloop_local&embed_location="
                    % (video_id, sig, timestamp, quality, codec_name.upper())
                )

            files[key].append(
                {
                    "ext": codec_extension,
                    "url": video_url,
                    "format_id": format_id,
                    "width": file_info.get("width"),
                    "height": file_info.get("height"),
                }
            )
    formats = []
    for key in ("other", "sd", "hd"):
        formats += files[key]
    if len(formats) == 0:
        raise ExtractorError("No known codec found")

    subtitles = {}
    text_tracks = config["request"].get("text_tracks")
    if text_tracks:
        for tt in text_tracks:
            subtitles[tt["lang"]] = [
                {
                    "ext": "vtt",
                    "url": "http://vimeo.com" + tt["url"],
                }
            ]

    return {
        "id": video_id,
        "uploader": video_uploader,
        "uploader_id": video_uploader_id,
        "upload_date": video_upload_date,
        "title": video_title,
        "thumbnail": video_thumbnail,
        "description": video_description,
        "duration": video_duration,
        "formats": formats,
        "webpage_url": url,
        "view_count": view_count,
        "like_count": like_count,
        "comment_count": comment_count,
        "subtitles": subtitles,
    }