Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/tmz.py (Python)

Code before:
                "uploader": "The Mac Life",
                "description": "md5:56e6009bbc3d12498e10d08a8e1f1c69",
                "upload_date": "20201119",
                "uploader_id": "TheMacLife",
                "timestamp": 1605800556,
                "thumbnail": "https://pbs.twimg.com/media/EnMmfT8XYAExgxJ.jpg?name=small",
                "like_count": int,
                "duration": 11.812,
                "uploader_url": "https://twitter.com/TheMacLife",
                "age_limit": 0,
                "repost_count": int,
                "tags": [],
                "comment_count": int,
            },
        },
    ]

    def _real_extract(self, url):
        webpage = self._download_webpage(url, url)
        jsonld = self._search_json_ld(webpage, url)
        if not jsonld or "url" not in jsonld:
            # try to extract from YouTube Player API
            # see https://developers.google.com/youtube/iframe_api_reference#Video_Queueing_Functions
            match_obj = re.search(
                r'\.cueVideoById\(\s*(?P<quote>[\'"])(?P<id>.*?)(?P=quote)', webpage
            )
            if match_obj:
                res = self.url_result(match_obj.group("id"))
                return res
            # try to extract from twitter
            blockquote_el = get_element_by_attribute("class", "twitter-tweet", webpage)
            if blockquote_el:
                matches = re.findall(
                    r'<a[^>]+href=\s*(?P<quote>[\'"])(?P<link>.*?)(?P=quote)',
                    blockquote_el,
                )
                if matches:
                    for _, match in matches:
                        if "/status/" in match:
                            res = self.url_result(match)
                            return res
            raise ExtractorError("No video found!")
        if id not in jsonld:
            jsonld["id"] = url
        return jsonld


Review comment (suggestion):
```suggestion
            match_obj = re.search(r'\.cueVideoById\(\s*(?P<quote>[\'"])(?P<id>.*?)(?P=quote)', webpage)
```

Code after:
                "tags": [],
                "comment_count": int,
            },
        },
    ]

    def _real_extract(self, url):
        webpage = self._download_webpage(url, url)
        jsonld = self._search_json_ld(webpage, url)
        if not jsonld or "url" not in jsonld:
            # try to extract from YouTube Player API
            # see https://developers.google.com/youtube/iframe_api_reference#Video_Queueing_Functions
            match_obj = re.search(r'\.cueVideoById\(\s*(?P<quote>[\'"])(?P<id>.*?)(?P=quote)', webpage)
            if match_obj:
                res = self.url_result(match_obj.group("id"))
                return res
            # try to extract from twitter
            blockquote_el = get_element_by_attribute("class", "twitter-tweet", webpage)
            if blockquote_el:
                matches = re.findall(
                    r'<a[^>]+href=\s*(?P<quote>[\'"])(?P<link>.*?)(?P=quote)',
                    blockquote_el)
                if matches:
                    for _, match in matches:
                        if "/status/" in match:
                            res = self.url_result(match)
                            return res
            raise ExtractorError("No video found!")
        if id not in jsonld:
            jsonld["id"] = url
        return jsonld