]> jfr.im git - yt-dlp.git/commitdiff
[tiktok] fix regex
authorAakash Gajjar <redacted>
Sat, 15 Feb 2020 07:00:12 +0000 (12:30 +0530)
committerAakash Gajjar <redacted>
Sat, 15 Feb 2020 07:00:12 +0000 (12:30 +0530)
youtube_dl/extractor/tiktok.py

index d4f6d90555f1f193c3ebffb7934d1e94c09a14f5..613ac9cc836d01ec65624eb393dbbff9c75e742e 100644 (file)
@@ -65,16 +65,7 @@ def _extract_aweme(self, video_data, webpage):
 
 
 class TikTokIE(TikTokBaseIE):
-    _VALID_URL = r'''(?x)
-                 https?://
-                 (?:
-                    (?:www|vm)\.
-                    (?:tiktok.com)\/
-                    (@(?P<username>[\w\.]+))\/
-                    (?:video)\/
-                 )
-                 (?P<id>[\d]{6,})
-                 '''
+    _VALID_URL = r'https?://www\.tiktok\.com/@[\w\._]+/video/(?P<id>\d+)'
 
     _TESTS = [{
         'url': 'https://www.tiktok.com/@leenabhushan/video/6748451240264420610',
@@ -133,8 +124,8 @@ def _real_extract(self, url):
 
         webpage = self._download_webpage(url, video_id, note='Downloading video webpage')
         json_string = self._search_regex(
-            r'id=\"__NEXT_DATA__\"\s+type=\"application\/json\"\s*[^>]+>\s*(?P<json_string>[^<]+)',
-            webpage, 'json_string', group='json_string')
+            r'id=\"__NEXT_DATA__\"\s+type=\"application\/json\"\s*[^>]+>\s*(?P<json_string_ld>[^<]+)',
+            webpage, 'json_string', group='json_string_ld')
         json_data = self._parse_json(json_string, video_id)
         video_data = try_get(json_data, lambda x: x['props']['pageProps'], expected_type=dict)